Documentation
  • INTRODUCTION
  • USERS
    • White Paper
    • Main features of CyberWay
    • Bandwidth differences between EOS and CyberWay
    • Bandwidth implementation
    • How to Launch EOS dApps on CyberWay
    • Glossary
  • DEVELOPMENT ENVIRONMENT
    • Core Concepts
    • 1 Before You Begin
    • 2 Install the CDT
    • 3 Create Development Wallet
    • 4 Start keosd and nodeos
    • 5 Create Test Accounts
  • SOFTWARE MANUALS
    • Core
      • nodeos
      • cleos
      • keosd
      • cyberway.cdt
    • How To Guides
      • How To Ban An Unwanted Account
      • How To Calculate Reward For An Author
      • How To Calculate Reward For A Beneficiary
      • How To Calculate Reward For A Curator
      • How To Create A Wallet
      • How To Create An Account
      • How To Create A Proxy Account
      • How To Create Key Pair
      • How To Delegate Resources
      • How To Deploy A Node Using A Snapshot
      • How To Deploy A Smart Contract
      • How To Get Account Information
      • How To Get Block Information
      • How To Get Transaction Information
      • How To Import A Key
      • How To Link Permission
      • How To List All Key Pair
      • How To Stake Tokens
      • How To Stop A Node Using Docker
      • How To Submit A Proposal For HardFork
      • How To Transfer Tokens To A Worker
      • How To Undelegate Resources
      • How To Unlink Permission
      • How To Unstake Tokens
      • How To Vote
    • API Reference
      • Nodeos Chain API
      • Nodeos Producer API
      • Nodeos Net API
    • Cleos Command Reference
      • Convert
      • Create
      • Get
      • Multisig
      • Net
      • Push
      • Set
      • Sign
      • System
      • Transfer
      • Version
      • Wallet
    • Explorer Command Reference
      • How To Check Your Balance
      • How To Find Out Account ID
      • How To Convert Golos To Golos Power And Vice Versa
      • How To Stake Tokens CYBER
      • How To Transfer Funds From One Account To Another
      • How To Transfer Funds From Pending to Liquid
      • How To Bay Stake
      • How To Withdraw Stake
      • How To Vote For A Validator
      • How To Revoke Your Vote For A Validator
      • How To Bay Vesting Using Explorer
      • How To Vote For A Witness
      • How To Revoke Your Vote For A Witness
  • DEVPORTAL
    • System Contracts
      • BIOS
      • Domain names
      • Govern
      • Multi-Signature
      • Stake
      • Tokens
    • Application Contracts
      • Golos Contracts
        • Charge
        • Control
        • Emission
        • Publication
        • Referral program
        • Social
        • Vesting
        • Memo-keys
        • Determining Rewards for a Post
    • Guide to Creating and Deploying an Application on CyberWay
      • 1 Preliminary Work
      • 2 Creating a Simple Contract
      • 3 Creating Tokens
      • 4 Understanding ABI Files
      • 5 Data Persistence
      • 6 Secondary Indexes
      • 7 Adding Inline Actions
      • 8 Inline Action to External Contract
      • 9 Conclusion
    • The cyberway_wallet designed for the Bittrex market
    • The Event Model
  • VALIDATORS
    • Testnet Installation Guide
      • 1 General
      • 2 Configuring the Docker Image
      • 3 Create Container
      • 4 Connecting to a Node
      • 5 List of Commands Applicable to Any Kind of Container
    • Mainnet Connection Guide
      • Docker-Compose Start-up Instructions
      • APPENDIX A
      • APPENDIX B
    • Golos Blockchain Transit
    • How to join CyberWay for those who are interested in being validators ?
    • Stake Usage Guide
    • Regulations for CyberWay validators. Voting for Validators
Powered by GitBook
On this page
  • Structs
  • Types
  • Actions
  • Events
  • Tables
  • Vectors’ description
  1. DEVPORTAL
  2. Guide to Creating and Deploying an Application on CyberWay

4 Understanding ABI Files

The Application Binary Interface (ABI) is a JSON-description of the methods for transforming user actions between JSON and binary representations. ABI also describes methods for converting database state to JSON-format and vice versa. After describing the contract through ABI, developers and users can easily interact with it via JSON.

To create an ABI file, use the eosio-cpp utility located in cyberway.cdt. Sometimes, for debugging purposes or for analysis, it is necessary to modify manually an already created ABI file. Therefore, the developers need to familiarize themselves with its structure, as well as with a description of its individual components. The structure of an ABI file is the following:

{
   "version": "cyberway::abi/1.1",
   "structs": [],
   "types": [],
   "actions": [],
   “events”: [],
   "tables": [],
   "variants": [],
   “abi_extensions”: []
}

structs — a description of the structures used to process the actions of the user. The structures can also be used to describe the fields of objects that are stored in tables or the fields (parameters) of functions in actions.

types — a description of user types used as parameters in any public action of the user or structure. It can also be used across public actions or structures. You may also describe your own types by yourself.

actions — a description of the public actions of the user that combines all the functions described in the header file of the contract.

events — a description of events, each of which represents a reaction (response) of a contract to a specific action of the user.

tables — a description of the tables used to process the actions of the user. The tables are objects of the type multi_index or eosio::singleton, which store data in the database of the blockchain node. Inside the table are structs. Creating, receiving, modifying or deleting objects is performed in actions.

abi_extensions — a description of additional ABI features (reserved, not used).

Structs

An example of a structure description in an ABI file:

{
   "name": "issue", // The name 
   "base": "",         // Inheritance, parent struct
   "fields": []        // Array of field objects describing the struct's fields
}

An example of a structure field description in an ABI file:

{
   "name":"",       // The field's name 
   "type":""        // The field's type
}

An example of a structure of a create operation for creating tokens in an ABI file:

{
  "name": "create",      
  "base": "",           

  "fields": [
    {
      "name":"issuer",      // Token creator name
      "type":"name"      
    },
    {
      "name":"maximum_supply", // Maximum number of tokens 
      "type":"asset"
    }
  ]
}

Types

Пример описания типа в ABI-файле:

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

Actions

An example of a type description in an ABI file:

{
  "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
}

Events

An example of the description of events for a publishing contract in an ABI file:

"events": [
    {"name": "poolstate", "type": "pool_event"},
    {"name": "poolerase", "type": "uint64"},
    {"name": "postcreate","type": "create_event"},
    {"name": "poststate", "type": "post_event"},
    {"name": "postclose", "type": "post_close"},
    {"name": "votestate", "type": "vote_event"}
  ],

Tables

An example of the description of a table in an ABI file:

{
    "name": "emitparams",
    "type": "emit_state",
    "indexes" : [{
        "name": "primary",
        "unique": true,
        "orders": [{"field": "id", "order": "asc"}]
    }]
}

Vectors’ description

At first, you have to add a type using [] characters to describe a vector in an ABI-file. The ABI file tables must be accurately described. For example, in the case of cleos when adding a table to a contract with a distorted ABI description data may be lost if there is no error message popping out.

You have to update the ABI file straight after a single change is made in the contract structure, tables, actions or events, as well as after introduction of a new type. In most cases if the ABI file update fails, an error message may not appeared. Such situation is difficult to analyze the work of the contract.

Previous3 Creating TokensNext5 Data Persistence

Last updated 5 years ago