We can utilize the triggersmartcontract function to invoke constant functions in the contract and obtain the result directly without broadcasting. Please ensure that supportConstant = true is set in your node configuration.
name
Invoke the name function to retrieve the token's name.
HTTP API :
/wallet/triggerconstantcontract
Description: Invoke the smart contract's constant function without broadcasting the transaction off the blockchain.
Demo:
curl -X POST https://127.0.0.1:8090/wallet/triggerconstantcontract -d '{
"contract_address": "379E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector": "name()",
"owner_address": "37977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'
symbol
Invoke the symbol function to retrieve the token symbol.
HTTP API :
/wallet/triggerconstantcontract
Description: Trigger the constant of the smart contract, the transaction is off the blockchain
demo: curl -X POST https://127.0.0.1:8090/wallet/triggerconstantcontract -d '{
"contract_address":"379E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"symbol()",
"owner_address":"37977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'
decimals
Execute the decimals function to obtain the token precision.
HTTP API :
/wallet/triggerconstantcontract
Description: Trigger the constant of the smart contract, the transaction is off the blockchain
demo: curl -X POST https://127.0.0.1:8090/wallet/triggerconstantcontract -d '{
"contract_address":"379E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"decimals()",
"owner_address":"37977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'
totalSupply
Call the totalSupply function to get the total supply of the token.
HTTP API :
/wallet/triggerconstantcontract
Description: Trigger the constant of the smart contract, the transaction is off the blockchain
demo: curl -X POST https://127.0.0.1:8090/wallet/triggerconstantcontract -d '{
"contract_address":"379E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"totalSupply()",
"owner_address":"37977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'
balanceOf
Invoke the balanceOf function to retrieve the token balance associated with the designated account.
HTTP API :
/wallet/triggerconstantcontract
Description: Trigger the constant of the smart contract, the transaction is off the blockchain
demo: curl -X POST https://127.0.0.1:8090/wallet/triggerconstantcontract -d '{
"contract_address":"379E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"balanceOf(address)",
"parameter":"000000000000000000000041977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB",
"owner_address":"37977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'
transfer
Initiate the transfer function to facilitate the transfer of tokens.
Please note that after utilizing this HTTP API, subsequent calls to the signature and broadcast APIs are also required.
allowance
Authorized addresses can use the allowance function to inquire about the authorized amount's balance.
HTTP API :
/wallet/triggerconstantcontract
Description: Trigger the constant of the smart contract, the transaction is off the blockchain
demo: curl -X POST https://127.0.0.1:8090/wallet/triggersmartcontract -d '{
"contract_address":"379E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"allowance(address,address)",
"parameter":"00000000000000000000004109669733965A37BA3582E70CCC5302F8D254675D000000000000000000000041A245B99ECB47B18C6A90ED1D51100C5A9F0641A7",
"owner_address":"37977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'