ONG Contract API
Please install Ontology SDKs before using the APIs introduced below.

Index

Methods

BalanceOf

Fetch the balance of a specific address.
1
ontSdk.Native.Ong.BalanceOf(address common.Address) (uint64, error)
Copied!

BalanceOfV2

Fetch the balance of a specific address.
ONG has 18 decimals.
1
ontSdk.Native.Ong.BalanceOfV2(address common.Address) (*big.Int, error)
Copied!

Transfer

Initiate a transaction.
1
ontSdk.Native.Ong.Transfer(gasPrice, gasLimit uint64, from *Account, to common.Address, amount uint64) (common.Uint256, error)
Copied!
Emit a corresponding contract event. For example:
1
{
2
"ContractAddress": "0200000000000000000000000000000000000000",
3
"States": [
4
"transfer",
5
"APS1wGGVUjsJYLUvncckzgsdqGT3KRqMtx",
6
"AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK",
7
50000000
8
]
9
}
Copied!

TransferV2

Initiate a transaction.
ONG has 18 decimals.
1
ontSdk.Native.Ong.TransferV2(gasPrice, gasLimit uint64, from *Account, to common.Address, amount *big.Int) (common.Uint256, error)
Copied!
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:
1
{
2
"ContractAddress": "0200000000000000000000000000000000000000",
3
"States": [
4
"transfer",
5
"APS1wGGVUjsJYLUvncckzgsdqGT3KRqMtx",
6
"AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK",
7
50000000,
8
123456789
9
]
10
}
Copied!

MultiTransfer

Initiate a batch transfer from one address to multiple addresses.
1
ontSdk.Native.Ong.MultiTransfer(gasPrice, gasLimit uint64, states []*ont.State, signer *Account) (common.Uint256, error)
Copied!

MultiTransferV2

Initiate a batch transfer from one address to multiple addresses.
ONG has 18 decimals.
1
ontSdk.Native.Ong.MultiTransferV2(gasPrice, gasLimit uint64, states []*ont.State, signer *Account) (common.Uint256, error)
Copied!

Approve

Approve tokens to be withdrawn as allowance.
1
ontSdk.Native.Ong.Approve(gasPrice, gasLimit uint64, from *Account, to common.Address, amount uint64) (common.Uint256, error)
Copied!

ApproveV2

Approve tokens to be withdrawn as allowance.
ONG has 18 decimals.
1
ontSdk.Native.Ong.ApproveV2(gasPrice, gasLimit uint64, from *Account, to common.Address, amount *big.Int) (common.Uint256, error)
Copied!

Allowance

Return the allowance from the from account to the to account.
1
ontSdk.Native.Ong.Allowance(from, to common.Address) (uint64, error)
Copied!

AllowanceV2

Return the allowance from the from account to the to account.
ONG has 18 decimals.
1
ontSdk.Native.Ong.AllowanceV2(from, to common.Address) (*big.Int, error)
Copied!

TransferFrom

Allow tokens to be transferred from allowance.
1
ontSdk.Native.Ong.TransferFrom(gasPrice, gasLimit uint64, sender *Account, from, to common.Address, amount uint64) (common.Uint256, error)
Copied!

TransferFromV2

Allow tokens to be transferred from allowance.
ONG has 18 decimals.
1
ontSdk.Native.Ong.TransferFrom(gasPrice, gasLimit uint64, sender *Account, from, to common.Address, amount *big.Int) (common.Uint256, error)
Copied!

WithdrawONG

Withdraw generated ONG.
1
ontSdk.Native.Ong.WithdrawONG(gasPrice, gasLimit uint64, address *Account, amount uint64) (common.Uint256, error)
Copied!

UnboundONG

Calculate the amount of ONG generated.
1
ontSdk.Native.Ong.UnboundONG(address common.Address) (uint64, error)
Copied!