Circular SDK
  • Getting Started
    • Circular APIs
      • Setting Up a Wallet
      • Get you NAG Access Key
      • Select a Programming Language
  • API Docs
    • APIs
      • Check Wallet Existence
      • Get Wallet Content
      • Get Wallet Balance
      • Get Wallet Nonce
      • Call a Smart Contract Function
      • Get a Domain
      • Get the Asset List
      • Get Asset
      • Get the Asset Supply
      • Get a range of Blocks
      • Get a Block
      • Get the number of Blocks
      • Get the Blockchain Analytics
      • Get the available blockchains
      • Get a Transaction by its TxID
      • Get transactions processed by a node
      • Get a transaction by an involved address
      • Get transactions by a range of dates
      • Submit a new Transaction
      • Registering a New Wallet
      • Transferring an Asset
    • Node.js
      • Mainnet Integration
      • checkWallet()
      • getWallet()
      • getWalletBalance()
      • getWalletNonce()
      • callContract()
      • testContract()
      • registerWallet()
      • getDomain()
      • getAssetList()
      • getAsset()
      • getAssetSupply()
      • getBlockRange()
      • getBlock()
      • getBlockCount()
      • getAnalytics()
      • getBlockchains()
      • getTransactionbyID()
      • getTransactionbyNode()
      • getTransactionbyAddress()
      • getTransactionbyDate()
      • getTransactionOutcome()
      • getPendingTransaction()
      • sendTransaction()
      • signMessage()
      • verifySignature()
      • getPublicKey()
      • stringToHex()
      • hexToString()
      • hexFix()
      • setNAGKey()
      • setNAGURL()
      • getFormattedTimestamp()
    • Javascript
      • Mainnet Integration
      • checkWallet()
      • getWallet()
      • getWalletBalance()
      • getWalletNonce()
      • callContract()
      • testContract()
      • registerWallet()
      • getDomain()
      • getAssetList()
      • getAsset()
      • getAssetSupply()
      • getBlockRange()
      • getBlock()
      • getBlockCount()
      • getAnalytics()
      • getBlockchains()
      • getTransactionbyID()
      • getTransactionbyNode()
      • getTransactionbyAddress()
      • getTransactionbyDate()
      • getTransactionOutcome()
      • getPendingTransaction()
      • sendTransaction()
      • signMessage()
      • verifySignature()
      • getPublicKey()
      • stringToHex()
      • hexToString()
      • hexFix()
      • setNAGKey()
      • setNAGURL()
      • getFormattedTimestamp()
    • Typescript
      • Including TypeScript Library
      • SetNAGKey & SetNAGURL
      • GetWallet
      • RegisterWallet
      • GetAsset
      • GetAssetSupply
      • GetBlock
      • SendTransaction
      • SignMessage
      • getFormattedTimestamp
      • Transferring an Asset
    • Python
      • Mainnet Integration
      • checkWallet()
      • getWallet()
      • getWalletBalance()
      • getWalletNonce()
      • callContract()
      • registerWallet()
      • getDomain()
      • getAssetList()
      • getAsset()
      • getAssetSupply()
      • getBlockRange()
      • getBlock()
      • getBlockCount()
      • getAnalytics()
      • getBlockchains()
      • getTransactionByID()
      • getTransactionByNode()
      • getTransactionByAddress()
      • getTransactionByDate()
      • getTransactionOutcome()
      • sendTransaction()
    • Dart
      • checkWallet()
      • getWallet()
      • getWalletBalance()
      • getWalletNonce()
      • callContract()
      • callContractWithPlainConsoleOutput()
      • registerWallet()
      • getDomain()
      • getAssetList()
      • getAsset()
      • getAssetSupply()
      • getBlockRange()
      • getBlock()
      • getBlockCount()
      • getAnalytics()
      • getBlockchains()
      • getTransactionByID()
      • getTransactionByNode()
      • getTransactionByAddress()
      • getTransactionByDate()
      • sendTransaction()
      • signMessage()
      • verifySignature()
      • getPublicKey()
      • getKeysFromString()
      • getKeysFromListOfStrings()
    • Go
      • Mainnet Integration
      • CheckWallet()
      • GetWallet()
      • GetWalletBalance()
      • GetWalletNonce()
      • CallContract()
      • RegisterWallet()
      • GetDomain()
      • GetAssetList()
      • GetAsset()
      • GetAssetSupply()
      • GetBlockRange()
      • GetBlock()
      • GetBlockCount()
      • GetAnalytics()
      • GetBlockchains()
      • GetTransactionByID()
      • GetTransactionByNode()
      • GetTransactionByAddress()
      • GetTransactionByDate()
      • GetTransactionOutcome()
      • SendTransaction()
      • SignMessage()
      • VerifySignature()
      • GetPublicKey()
      • GetKeysFromString()
    • PHP
      • Mainnet Integration
      • checkWallet()
      • getWallet()
      • getWalletBalance()
      • getWalletNonce()
      • callContract()
      • registerWallet()
      • getDomain()
      • getAssetList()
      • getAsset()
      • getAssetSupply()
      • getBlockRange()
      • getBlock()
      • getBlockCount()
      • getAnalytics()
      • getBlockchains()
      • getTransactionByID()
      • getTransactionByNode()
      • getTransactionByAddress()
      • getTransactionByDate()
      • getTransactionOutcome()
      • sendTransaction()
      • signMessage()
      • verifySignature()
      • getPublicKey()
      • stringToHex()
      • hexToString()
      • hexFix()
      • setNAGKey()
      • setNAGURL()
      • getFormattedTimestamp()
    • C++
    • C#
    • Rust
    • Arduino
Powered by GitBook
On this page
  1. API Docs
  2. Python

callContract()

Call a smart contract function and get the output

Method Signature

def callContract(self, blockchain, sender, address, request)

Parameters

Name
Type
Description

blockchain

string or hexadecimal

Blockchain address

sender

string or hexadecimal

User's wallet address

address

string or hexadecimal

Smart Contract's address

Request

string

Requested function in string format (include the parenthesis and the semicolumn e.g. CRC_Contract.__GetContractName();).

Example

from circular_protocol_api import CircularProtocolAPI

blockhain = 0x8a20baa40c45dc5055aeb26197c203e576ef389d9acb171bd62da11dc5ad72b2
sender = 0x8b20bda40c45dc2908aeb26197c203e576ef389d9acb171bd62da15af5ad72b4
contract_address = 0x2f0bda40c45dc2908aeb26197c203e576ef389aacb171bd62da15af5ad72b1
request = "CRC_Contract.__GetContractName();"

circular = CircularProtocolAPI()
result = circular.callContract(blockchain, sender, contract_address, request)

Result

{
    "Result": 200,
    "Response": "7b20225f506572666f726d616e636522203a2022487970657220436f646520457865637574696f6e2054696d653a20313130307573222c200a0a225f436f6e736f6c655f4f757470757422203a202235343635373337343230373336643631373237343230363336663665373437323631363337343061227d",
    "Node": "7bb5bd50729d6857942701d5673ea70ca1625f883230d8543970a452d1abe1c4"
}

Remember to convert the response from Hex to String if you want to get the result in plain text.

Wrong function call. Remember to pass the request in Hex format as shown in the body section or to verify that the smart contract address is the right one.

{
    "Result": 117,
    "Response": "4552524f523a57726f6e672046756e6374696f6e2043616c6c3a200a",
    "Node": "7bb5bd50729d6857942701d5673ea70ca1625f883230d8543970a452d1abe1c4"
}

Last updated 7 months ago