Meter Docs
Learn
  • Welcome to Meter!
  • 中文版文档
  • Overview of Meter
    • Introduction to Meter
    • Hybrid PoV Consensus Mechanism
    • MTR - The Metastable Coin
    • MTRG - Meter Governance Coin
    • On-Chain Auctions
    • The Meter Reserve
    • Meter's Ethereum Emulation Mode
  • Wallet Setup
    • Interacting with Meter Mainnet Using MetaMask
    • Interacting with Meter Mainnet Using Ledger
    • Adding Custom Tokens to MetaMask
    • Getting MTR for Gas
    • Revoking Contract Spend Limits
    • Specifying gas (GWEI) for transactions
    • Speeding Up/ Canceling Transactions
  • Meter Passport V2.0
    • Meter Passport Architecture
    • Salient Features
    • Bridge Fee
    • Programming Meter Passport
    • Tutorials for Using Meter Passport
    • MTRG Crosschain Info
    • Onboarding Passport for Your Project
    • Technical Guideline for Meter Passport
    • Security Audit for Meter Passport V2.0
  • Staking and Validation
    • Staking MTRG
      • How to Stake MTRG
        • Choosing Candidates
        • Factors affecting Staking Rewards
      • How to Stake Incremental MTRG
      • How to Undelegate MTRG
      • How to Unbound MTRG
      • Frequently Asked Questions
    • Running a Full Node on Meter Mainnet
    • Configure the Full Node to Validator Node
    • Meter Incentive Programs to promote decentralization
  • Mining
    • Meter Mining Guide
  • NFT Collections
    • Meter Community NFTs
  • Developer Documentation
    • Meter Developer Incentives
      • Meter Developer Grant Program
      • Meter TVL Incentive Program
      • Meter Gas Monetization Program
      • Meter Co-marketing Program
      • Meter DAPP Referral Program
    • Introduction to Developer Documentation
    • Developing with Remix, Ethers.js and Web3.js
    • Index Data with SubQuery
    • Meter Native TX RESTful APIs
    • Meterify API Documentation
      • meterify.eth
      • meterify.eth.Contract
      • meterify.eth.accounts
      • meterify.utils
      • meterify.module.options
      • Callbacks Promises Events
      • json interface
    • Meterify DApp Tutorials
    • Meterify Code Examples
    • Contributing to Meter and Our Documentation
      • Documentation Guidelines
        • API Documentation Guidelines
        • Tutorial Creation Guidelines
        • Code Example Guidelines
        • Article Writing Guidelines
Powered by GitBook
On this page

Was this helpful?

  1. Developer Documentation
  2. Meterify API Documentation

json interface

The json interface is a json object describing the Application Binary Interface (ABI) for a smart contract. Using this json interface, web3.js is able to create JavaScript object representing the smart contract and its methods and events using the web3.eth.Contract object.

Specification

Functions:

  1. type: "function", "constructor" (can be omitted, defaulting to "function"; "fallback" also possible but not relevant in web3.js).

  2. name: the name of the function (only present for function types).

  3. constant: true if function is specified to not modify the blockchain state.

  4. payable: true if function accepts ether, defaults to false

  5. stateMutability: a string with one of the following values:

    1. pure (specified to not read blockchain state)

    2. view (same as constant above)

    3. nonpayable and payable (same as payable above)

  6. inputs: an array of objects, each of which contains:

    1. name: the name of the parameter

    2. type: the canonical type of the parameter

  7. outputs: an array of objects same as inputs, can be omitted if no outputs exist.

Events:

  1. type: always "event"

  2. name: the name of the event.

  3. inputs: an array of objects, each of which contains:

    1. name: the name of the parameter.

    2. type: the canonical type of the parameter.

    3. indexed: true if the field is part of the log's topics, false if it one of the log's data segment.

  4. anonymous: true if the event was declared as anonymous.

Example:

contract Test {
        uint a;
        address d = 0x12345678901234567890123456789012;

        function Test(uint testInt)  { a = testInt;}

        event Event(uint indexed b, bytes32 c);

        event Event2(uint indexed b, bytes32 c);

        function foo(uint b, bytes32 c) returns(address) {
            Event(b, c);
            return d;
        }
    }

    // would result in the JSON:
    [{
        "type":"constructor",
        "payable":false,
        "stateMutability":"nonpayable"
        "inputs":[{"name":"testInt","type":"uint256"}],
      },{
        "type":"function",
        "name":"foo",
        "constant":false,
        "payable":false,
        "stateMutability":"nonpayable",
        "inputs":[{"name":"b","type":"uint256"}, {"name":"c","type":"bytes32"}],
        "outputs":[{"name":"","type":"address"}]
      },{
        "type":"event",
        "name":"Event",
        "inputs":[{"indexed":true,"name":"b","type":"uint256"}, {"indexed":false,"name":"c","type":"bytes32"}],
        "anonymous":false
      },{
        "type":"event",
        "name":"Event2",
        "inputs":[{"indexed":true,"name":"b","type":"uint256"},{"indexed":false,"name":"c","type":"bytes32"}],
        "anonymous":false
    }]
PreviousCallbacks Promises EventsNextMeterify DApp Tutorials

Last updated 4 years ago

Was this helpful?