4

Take for example this action belonging to a newaccount transaction:

{
      "account": "eosio",
      "name": "newaccount",
      "authorization": [{
          "actor": "eosio",
          "permission": "active"
        }
      ],
      "data": "0000000000ea305510c255191ba9b23f010000000100030a5d4c7f7d35c16028563c8ec58406bb084acf5ff95d386ada1de045b1d23dd501000000010000000100030a5d4c7f7d35c16028563c8ec58406bb084acf5ff95d386ada1de045b1d23dd501000000"
}

How is the data field encoded?

1

The action's ABI describes how to encode it. e.g. here's the newaccount ABI:

{
  "name": "newaccount",
  "base": "",
  "fields": [
    {"name":"creator", "type":"account_name"},
    {"name":"name",    "type":"account_name"},
    {"name":"owner",   "type":"authority"},
    {"name":"active",  "type":"authority"}
  ]
}

account_name is an alias for the built-in name type:

{
  "new_type_name": "account_name",
  "type": "name"
}

authority is another structure:

{
  "name": "authority",
  "base": "",
  "fields": [
    {"name":"threshold", "type":"uint32"},
    {"name":"keys",      "type":"key_weight[]"},
    {"name":"accounts",  "type":"permission_level_weight[]"},
    {"name":"waits",     "type":"wait_weight[]"}
  ]
}

The contract's ABI has defintions for all types it uses, except for the built-in types. e.g. name is a built-in type that contains up to 12 characters packed into a uint64. See this answer for name's encoding.

0

Here is how EOSDevHelper serialize data in new account. In fact, it serializing block num, block expiration, creator, permission and new name. You can see details of it from link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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