PRC-20 Contract Interaction

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.

HTTP API :

wallet/triggersmartcontract
Description: Trigger smart contract
demo: curl -X POST https://127.0.0.1:8090/wallet/triggersmartcontract -d '{
"contract_address":"379E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"transfer(address,uint256)",
"parameter":"00000000000000000000004115208EF33A926919ED270E2FA61367B2DA3753DA0000000000000000000000000000000000000000000000000000000000000032",
"fee_limit":100000000,
"call_value":0,
"owner_address":"37977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'

approve

Invoke the approve function to grant specific token usage permissions to other addresses.

HTTP API :

wallet/triggersmartcontract
Description: Trigger smart contract
demo: curl -X POST https://127.0.0.1:8090/wallet/triggersmartcontract -d '{
"contract_address":"379E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"approve(address,uint256)",
"parameter":"0000000000000000000000410FB357921DFB0E32CBC9D1B30F09AAD13017F2CD0000000000000000000000000000000000000000000000000000000000000064",
"fee_limit":100000000,
"call_value":0,
"owner_address":"37977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'

Please note that after utilizing this HTTP API, subsequent calls to the signature and broadcast APIs are also required.

transferFrom

Authorized addresses can invoke the transferFrom function to transfer tokens from the authorizer's account.

HTTP API :

wallet/triggersmartcontract
Description: Trigger smart contract
demo: curl -X POST https://127.0.0.1:8090/wallet/triggersmartcontract -d '{
"contract_address":"379E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"transferFrom(address,address,uint256)",
"parameter":"00000000000000000000004109669733965A37BA3582E70CCC5302F8D254675D0000000000000000000000410FB357921DFB0E32CBC9D1B30F09AAD13017F2CD0000000000000000000000000000000000000000000000000000000000000032",
"fee_limit":100000000,
"call_value":0,
"owner_address":"37977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'

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"
}'

Last updated