Ontology Developer Center
DISCOVERCOMMUNITYSUPPORT
  • Introduction
  • Discover Ontology
  • Getting Started
  • Glossary
  • Decentralized Identity and Data
    • ONT ID
      • Decentralized Identifiers
        • Method Specification for Ontology
        • Method Specification for Ethereum
        • Method Specification for BSC
      • Verifiable Credentials
        • Anonymous Credentials
      • ONT Login
        • Scenarios
        • Protocol Specification
        • Front-end JavaScript SDK
          • Integration and Usage
          • API Reference
        • Front-end UI SDK
          • Integration and Usage
          • API Reference
        • Back-end Go SDK
          • Integration and Usage
          • API Reference
        • Back-end Java SDK
          • Integration and Usage
          • API Reference
      • ONT TAG
        • Workflow
        • API Reference
      • Mercury
      • OScore
    • DDXF
      • Components and Interfaces
      • GREP
      • Overall Scheme
      • Solutions
        • Marketplace
          • Deployment
          • Scenarios
          • SaaS Tenant
          • Java SDK
        • Data Storage
          • Deployment
          • Java SDK
        • Resource Auditor
        • Offline Judge
      • Use Cases
        • E-Shops
  • ONTOLOGY ELEMENTS
    • Smart Contracts
      • Types of smart contracts
    • Token Protocols
    • Consensus Mechanism
    • Ontology Oracle
      • Oracle Process Flow
  • GUIDES & TUTORIALS
    • Development Guides
      • dApp Development
        • Using the dAPI
        • Data Synchronization
      • Smart Contract Development
        • EVM Contract
          • Development Environment and Tools
          • Wallet Setup
          • Contract Development
          • How to Deploy a Smart Contract with GetBlock
        • NeoVM Contract
          • Development tools and environment
          • Launching the IDE
          • Writing and editing program logic
          • Deploying and testing on private net
        • WASM Contract
          • Development Environment
          • Project Initiation - Hello World
          • Creating your own project
          • Development using SmartX
          • Runtime API
          • Contract Fundamentals
          • Inter-contract Interaction
          • Developing Contracts in C++
        • Publish Contract Source Code
    • Integration Guides
      • dApp Integration
        • dAPI Integration
          • Chrome Plugin
          • Mobile wallet dApp
          • QR code mechanism
          • Wake call mechanism
        • Cocos 2D-x
        • Unity 3D applications
      • Mobile Wallet Integration
        • SDK integration
        • dAPI Integration
          • In-wallet applications
          • QR code mechanism
          • Wake call mechanism
        • Stake
      • Using ONT ID
      • Exchange Integration
        • Exchange Docking Guide
        • Exchange API
      • Ontology for dApp Stores
    • EVM & Token Decimals Upgrade
  • ONTOLOGY NODE
    • Abstract
    • Node Deployment
      • Standard Node
      • Rosetta Node
    • Interacting with a Public Node
  • DEVELOPER TOOLS
    • dApp Development Framework
      • Punica CLI
      • Punica boxes
      • Solo Chain
    • IDE
    • APIs
      • HTTP API
        • Restful
        • WebSocket
        • Remote Procedure Call (RPC)
      • Explorer v2 API
        • Block
        • Address
        • Contract
        • Token
        • Transactions
        • ONT ID
        • Summary
        • Node
      • Native Token API
        • ONT Contract API
        • ONG Contract API
      • ONT ID Contract API
      • Web3 API
      • OScore Open API
      • Rosetta Node API
        • Data API
        • Construction API
      • DToken Contract API
      • DDXF
        • Marketplace Contract API
        • Storage API
      • Governance API
    • Digital Wallet
      • Chrome Plugin provider
      • Chrome Plugin dAPI
      • Mobile version provider
      • Mobile version dAPI
    • SDKs
    • Signing Server
      • Installation
      • API reference
  • COMMUNITY
    • Ecosystem Programs
    • Community Libraries
    • Community Events
    • Community Channels
    • Core Contributors
  • SUPPORT
    • FAQ
      • Basic blockchain concepts
      • Ontology Nodes
      • Ontology token protocols
      • Smart contracts
      • SDKs and APIs
    • Contact Us
Powered by GitBook
On this page
  • Index
  • Methods
  • BalanceOf
  • BalanceOfV2
  • Transfer
  • TransferV2
  • MultiTransfer
  • MultiTransferV2
  • Approve
  • ApproveV2
  • Allowance
  • AllowanceV2
  • TransferFrom
  • TransferFromV2
  • WithdrawONG
  • UnboundONG

Was this helpful?

  1. DEVELOPER TOOLS
  2. APIs
  3. Native Token API

ONG Contract API

PreviousONT Contract APINextONT ID Contract API

Last updated 8 months ago

Was this helpful?

Please install Ontology before using the APIs introduced below.

Index

Methods

BalanceOf

Fetch the balance of a specific address.

ontSdk.Native.Ong.BalanceOf(address common.Address) (uint64, error)

BalanceOfV2

Fetch the balance of a specific address.

ONG has 18 decimals.

ontSdk.Native.Ong.BalanceOfV2(address common.Address) (*big.Int, error)

Transfer

Initiate a transaction.

ontSdk.Native.Ong.Transfer(gasPrice, gasLimit uint64, from *Account, to common.Address, amount uint64) (common.Uint256, error)

Emit a corresponding contract event. For example:

{
"ContractAddress": "0200000000000000000000000000000000000000",
"States": [
"transfer",
"APS1wGGVUjsJYLUvncckzgsdqGT3KRqMtx",
"AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK",
50000000
]
}

TransferV2

Initiate a transaction.

ONG has 18 decimals.

ontSdk.Native.Ong.TransferV2(gasPrice, gasLimit uint64, from *Account, to common.Address, amount *big.Int) (common.Uint256, error)

If the transfer amount is divisible by 10^9, the event emitted will be the same as the one by Transfer.

Otherwise, the amount consists of two integers. The first one represents amount/10^9, and the second one represents amount%10^9. For example, if the transaction amount is 0.050000000123456789 ONG, the event looks like:

{
"ContractAddress": "0200000000000000000000000000000000000000",
"States": [
"transfer",
"APS1wGGVUjsJYLUvncckzgsdqGT3KRqMtx",
"AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK",
50000000,
123456789
]
}

MultiTransfer

Initiate a batch transfer from one address to multiple addresses.

ontSdk.Native.Ong.MultiTransfer(gasPrice, gasLimit uint64, states []*ont.State, signer *Account) (common.Uint256, error)

MultiTransferV2

Initiate a batch transfer from one address to multiple addresses.

ONG has 18 decimals.

ontSdk.Native.Ong.MultiTransferV2(gasPrice, gasLimit uint64, states []*ont.State, signer *Account) (common.Uint256, error)

Approve

Approve tokens to be withdrawn as allowance.

ontSdk.Native.Ong.Approve(gasPrice, gasLimit uint64, from *Account, to common.Address, amount uint64) (common.Uint256, error)

ApproveV2

Approve tokens to be withdrawn as allowance.

ONG has 18 decimals.

ontSdk.Native.Ong.ApproveV2(gasPrice, gasLimit uint64, from *Account, to common.Address, amount *big.Int) (common.Uint256, error)

Allowance

Return the allowance from the from account to the to account.

ontSdk.Native.Ong.Allowance(from, to common.Address) (uint64, error)

AllowanceV2

Return the allowance from the from account to the to account.

ONG has 18 decimals.

ontSdk.Native.Ong.AllowanceV2(from, to common.Address) (*big.Int, error)

TransferFrom

Allow tokens to be transferred from allowance.

ontSdk.Native.Ong.TransferFrom(gasPrice, gasLimit uint64, sender *Account, from, to common.Address, amount uint64) (common.Uint256, error)

TransferFromV2

Allow tokens to be transferred from allowance.

ONG has 18 decimals.

ontSdk.Native.Ong.TransferFrom(gasPrice, gasLimit uint64, sender *Account, from, to common.Address, amount *big.Int) (common.Uint256, error)

WithdrawONG

Withdraw generated ONG.

ontSdk.Native.Ong.WithdrawONG(gasPrice, gasLimit uint64, address *Account, amount uint64) (common.Uint256, error)

UnboundONG

Calculate the amount of ONG generated.

ontSdk.Native.Ong.UnboundONG(address common.Address) (uint64, error)
SDKs
BalanceOf
BalanceOfV2
Transfer
TransferV2
MultiTransfer
MultiTransferV2
Approve
ApproveV2
Allowance
AllowanceV2
TransferFrom
TransferFromV2
WithdrawONG
UnboundONG