Tekkaman

导航

 

Understanding ABI Files

  ABI files can be generated using the eosio-cpp utility provided by eosio.cdt. The Application Binary Interface (ABI) is a JSON-based description.

1、ABI的基本结构

{
   "version": "eosio::abi/1.0",
   "types": [],
   "structs": [],
   "actions": [],
   "tables": [],
   "ricardian_clauses": [],
   "abi_extensions": [],
   "___comment" : ""
}

2、types describe the custom types that are used as a parameter in any public action or struct that needs to be described in the ABI.

  EOSIO implements a number of custom built-ins. Built-in types don't need to be described in an ABI file. If you would like to familiarize yourself with EOSIO's built-ins, they are defined here

  

3、structs

  action的数据会存在于 structs中。如create action。

{
  "name": "create",
  "base": "",
  "fields": [
    {
      "name":"issuer", 
      "type":"name"
    },
    {
      "name":"maximum_supply", 
      "type":"asset"
    }
  ]
}

  

  struct会被写入 structs中。

{
  "name": "currency_stats",
  "base": "",
  "fields": [
    {
      "name":"supply", 
      "type":"asset"
    },
    {
      "name":"max_supply", 
      "type":"asset"
    },
    {
      "name":"issuer", 
      "type":"account_name"
    }
  ]
}

  

4、actions

{
  "name": "transfer",             //The name of the action as defined in the contract
  "type": "transfer",             //The name of the implicit struct as described in the ABI
  "ricardian_contract": ""     //An optional ricardian clause to associate to this action describing its intended functionality.
}

  每一个action会隐含(implicit)创建一个struct,通过type来指向。action'name struct'name are not required to be equal.

5、tables

6、Every time you 1)change a struct, 2)add a table, 3)add an action or 4)add parameters to an action, 5)use a new type, you will need to remember to update your ABI file. In many cases failure to update your ABI file will not produce any error.

7、

参考:

1、https://developers.eos.io/eosio-home/docs/the-abi

posted on 2018-11-22 17:21  Tekkaman  阅读(277)  评论(0编辑  收藏  举报