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

Callbacks Promises Events

Previousmeterify.module.optionsNextjson interface

Last updated 4 years ago

Was this helpful?

PromiEvent

To help web3 integrate into all kind of projects with different standards, we provide multiple ways to act on asynchronous functions.

Most web3.js objects allow a callback as the last parameter, as well as returning promises to chain functions.

Meter as a blockchain has different levels of finality and therefore needs to return multiple "stages" of an action.

To cope with this requirement, we return a "PromiEvent" for functions like or contract methods. These stages are encapsulated into a "PromiEvent", which combines a promise with an event emitter.

The event emitter fires an event for each of the finality stages.

An example of a function that benefits from a PromiEvent is the method:


    web3.eth.sendTransaction({from: '0x123...', data: '0x432...'})
    .once('transactionHash', function(hash){ ... })
    .once('receipt', function(receipt){ ... })
    .on('confirmation', function(confNumber, receipt){ ... })
    .on('error', function(error){ ... })
    .then(function(receipt){
        // will be fired once the receipt is mined
    });
web3.eth.sendTransaction
web3.eth.sendTransaction