Home > Software design >  How TRC-20 Contract Interaction via HTTP?
How TRC-20 Contract Interaction via HTTP?

Time:10-09

trc20-contract-interaction

wallet/triggersmartcontract
Description: Trigger smart contract
demo: curl -X POST https://127.0.0.1:8090/wallet/triggersmartcontract -d '{
"contract_address":"419E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"transfer(address,uint256)",
"parameter":"00000000000000000000004115208EF33A926919ED270E2FA61367B2DA3753DA0000000000000000000000000000000000000000000000000000000000000032",
"fee_limit":100000000,
"call_value":0,
"owner_address":"41977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'
  1. Where put a privateKey?
  2. How generate parameter field?

CodePudding user response:

According to the documentation, the flow is like this

  1. wallet/triggersmartcontract
  2. sign
  3. broadcast

Back to your question:

  1. How to generate the parameter field?

The parameter field can be generated from Parameter and return value encoding and decoding documentation.

An example: the function

transfer (412ed5dd8a98aea00ae32517742ea5289761b2710e, 50000) is then encoded with an output 0000000000000000000000002ed5dd8a98aea00ae32517742ea5289761b2710e0000000000000000000000000000000000000000000000000000000ba43b7400

  1. Where put a privateKey?

The privateKey is inserted during the sign transaction. The first wallet/triggersmartcontract then sign using the /wallet/gettransactionsign call. Then the signed transaction is used to broadcast /wallet/broadcasttransaction.

So instead of making a transaction in this API Signature and Broadcast Flow documentation. Your transaction is actually a triggersmartcontract transaction, the sign and broadcast flow remains.

  • Related