> For the complete documentation index, see [llms.txt](https://docs.ont.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ont.io/developer-tools/api/native-token-api/ont-contract-api.md).

# ONT Contract API

{% hint style="info" %}
Please install Ontology [SDKs ](/developer-tools/sdk.md)before using the APIs introduced below.
{% endhint %}

## Index

* [`BalanceOf`](#balanceof)
* [`BalanceOfV2`](#balanceofv2)
* [`Transfer`](#transfer)
* [`TransferV2`](#transferv2)
* [`MultiTransfer`](#multitransfer)
* [`MultiTransferV2`](#multitransferv2)
* [`Approve`](#approve)
* [`ApproveV2`](#approvev2)
* [`Allowance`](#allowance)
* [`AllowanceV2`](#allowancev2)
* [`TransferFrom`](#transferfrom)
* [`TransferFromV2`](#transferv2)

## Methods

### `BalanceOf`

Fetch the balance of a specific address.

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

### `BalanceOfV2`

Fetch the balance of a specific address.&#x20;

ONT has 9 decimals.

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

### `Transfer`

Initiate a transaction.&#x20;

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

Emit a corresponding contract event. For example:

```json
{
"ContractAddress": "0100000000000000000000000000000000000000",
"States": [
"transfer",
"APS1wGGVUjsJYLUvncckzgsdqGT3KRqMtx",
"AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK",
200
]
}
```

### `TransferV2` &#x20;

Initiate a transaction.

ONT has 9 decimals. &#x20;

```
ontSdk.Native.Ont.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 123.4567 ONT, the event looks like:

```json
{
"ContractAddress": "0100000000000000000000000000000000000000",
"States": [
"transfer",
"APS1wGGVUjsJYLUvncckzgsdqGT3KRqMtx",
"AFmseVrdL9f9oyCzZefL9tG6UbviEH9ugK",
123，
4567
]
}
```

### `MultiTransfer`

Initiate a batch transfer from one address to multiple addresses.

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

### `MultiTransferV2`

Initiate a batch transfer from one address to multiple addresses.

ONT has 9 decimals.&#x20;

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

### `Approve`

Approve tokens to be withdrawn as allowance.&#x20;

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

### `ApproveV2`

Approve tokens to be withdrawn as allowance.

ONT has 9 decimals.&#x20;

```
ontSdk.Native.Ont.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.Ont.Allowance(from, to common.Address) (uint64, error)
```

### `AllowanceV2`

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

ONT has 9 decimals.&#x20;

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

### `TransferFrom`

Allow tokens to be transferred from allowance.

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

### `TransferFromV2`

Allow tokens to be transferred from allowance.

ONT has 9 decimals.&#x20;

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

####

####

```
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ont.io/developer-tools/api/native-token-api/ont-contract-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
