3

I would like to use the rpc call to query a contract.

I try to use the method "call" from the endpoint "state" with the first parameter "ContractsApi_call" but I am not able to fully build the second parameter (data).

Here an example:

enter image description here

In this example the data bytes are:

0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d1200ccd8b1a8f39b6d1d69463f5c4281bf9ec5ddfd80eedbba0ee221a30a02a600000000000000000000000000000000000020ba48eafe0c313233

From my understanding the data bytes are decomposed like this:

  - the origin address :  d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d
  - the contract address: 1200ccd8b1a8f39b6d1d69463f5c4281bf9ec5ddfd80eedbba0ee221a30a02a6
  - the missing piece: 00000000000000000000000000000000000020 
  - the selector of the method to call : ba48eafe
  - the args of the method: 0c313233

I would like to understand how is build the missing piece (00000000000000000000000000000000000020), in particular last part(20).

Anyone could help me to understand?

1 Answer 1

0

I found myself the answer and I put it there if it can help anyone else.

I need to create the following struct:

ContractCall { origin : AccountId, dest : AccountId, value : Balance, gas_limit : Option, storage_deposit_limit : Option, data: Vec, } In my case the data is the concatenation of:

  • the selector of the method: [u8;4]
  • the args of the method: Vec

and encode the whole struct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.