2

The image below shows a decoded finalized transaction that deploys a flipper contract on my local substrate network. I am not sure what the data field represents here.

Contract deployment transaction

1 Answer 1

2

It is the data passed to the constructor of the contract.

Pallet contracts docs

4
  • 1
    To expand, data is an encoded message or constructor selector (because you can have multiple constructors) with input for it (if needed). Commented Feb 15, 2023 at 9:32
  • Well in my case the function signature looks like this: pub fn new(init_value: bool) -> Self I believe I initialized it with false. Can you elaborate what encoding or other mechanism led it to be 0x9bae9d5e00?
    – Non-named
    Commented Feb 15, 2023 at 9:37
  • first 4 bytes is the selector (9bae9d5e) then you have the args (00 = false in your case)
    – kriko.eth
    Commented Feb 16, 2023 at 9:17
  • I need to pass the data field through my code using polkadot-js/api library. So can you tell me how I can get the first 4 bytes i.e. the selector, given the function signature and the params passed during the contract instantiation?
    – Non-named
    Commented Feb 20, 2023 at 8:13

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.