CallContract()
Use this method if you want to execute a function writte in a smart contract.
Method Signature
func CallContract(blockchain string, from string, project string, request string) map[string]interface{}
Parameters
Name
Type
Description
blockchain
String
Blockchain address in hex
from
String
User's wallet address in hex
project
String
Smart Contract's address in hex
request
String
Requested function in string format (include the parenthesis and the semicolumn e.g. CRC_Contract.__GetContractName();).
Example
package main
import (
"fmt"
"github.com/circular-protocol/circular-go/circular_protocol_api"
)
func main() {
var blockchain = "0x8a20baa40c45dc5055aeb26197c203e576ef389d9acb171bd62da11dc5ad72b2"
var test_addr = "0x8b1dd25076c04c5139acba458f86c69cd2d322c61d19bc28daa3bbd945083738"
var contract_addr = "0x9f20baa40c45dc4125aeb26197c203e576ef389d9acb171bd62da11dc5ad72b3"
result := circular_protocol_api.CallContract(blockchain, test_addr, contract_addr, "CRC_Contract.__GetContractName();")
fmt.Println(result)
}
Result
The result will be of type Map
, but for easier readability, here is the equivalent in JSON.
{
"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.
Last updated