EVM & Token Decimals Upgrade

Introduction

To provide better support for dApps on Ontology, the network now is EVM compatible. Transaction fees are still paid in ONG. However, now ONT has 9 decimals, and ONG has 18 decimals.
This guide introduces the upgrade work needed on your end to enjoy these features.

Ontology Nodes

The Ontology MainNet will be upgraded at the block height of 13920000, please finish the local node upgrade before that (but after Ontology MainNet consensus nodes upgrade).

Changes to ONT & ONG Deposit Events (required)

The events and logs for ONT / ONG transactions will be different after the upgrade, which affects your event listeners.

ONT Transaction Events

Contract address: "0100000000000000000000000000000000000000"
The array held by States can have 4 or 5 elements.
a. When the transaction amount is an integer, the event remains the same.
Example
Transfer 1 ONT:
1
{
2
"ContractAddress": "0100000000000000000000000000000000000000",
3
"States": [
4
"transfer",
5
"AdeTj6K9UUmz5yfyc8SLX7mJSmCqDKK6yT",
6
"AdeTj6K9UUmz5yfyc8SLX7mJSmCqDKK6yT",
7
1
8
]
9
},
Copied!
States[0]: "transfer" (fixed)
States[1]: from address
States[2]: to address
States[3]: amount (integer, no decimal place)
b. When the transaction amount is a decimal number, States looks like the below example.
Example
Transfer 1.052999999 ONT:
1
{
2
"ContractAddress": "0100000000000000000000000000000000000000",
3
"States": [
4
"transfer",
5
"AdeTj6K9UUmz5yfyc8SLX7mJSmCqDKK6yT",
6
"AdeTj6K9UUmz5yfyc8SLX7mJSmCqDKK6yT",
7
1,
8
52999999
9
]
10
}
Copied!
States[0]: "transfer" (fixed)
States[1]: from address
States[2]: to address
States[3]: amount (integer representing digits before the decimal point, no decimal place)
States[4]: amount (integer representing digits after the decimal point, 9 digits maximum)

ONG Transaction Events

Contract address ”0200000000000000000000000000000000000000“
The array held by States can have 4 or 5 elements.
a. When the number of the transaction amount only have 1 - 9 decimal places, the event remains the same.
Example
Transfer 0.000000001 ONG:
1
{
2
"ContractAddress": "0200000000000000000000000000000000000000",
3
"States": [
4
"transfer",
5
"AdeTj6K9UUmz5yfyc8SLX7mJSmCqDKK6yT",
6
"AdeTj6K9UUmz5yfyc8SLX7mJSmCqDKK6yT",
7
1
8
]
9
}
Copied!
States[0]: "transfer" (fixed)
States[1]: from address
States[2]: to address
States[3]: amount (integer representing digits after the decimal point, 9 digits maximum)
b. When the number of the transaction amount have 10 - 18 decimal places, States looks like the below example.
Example
Transfer 0.00000000105 ONG:
1
{
2
"ContractAddress": "0200000000000000000000000000000000000000",
3
"States": [
4
"transfer",
5
"AdeTj6K9UUmz5yfyc8SLX7mJSmCqDKK6yT",
6
"AdeTj6K9UUmz5yfyc8SLX7mJSmCqDKK6yT",
7
1,
8
50000000
9
]
10
}
Copied!
States[0]: "transfer" (fixed)
States[1]: from address
States[2]: to address
States[3]: amount (integer representing digits on the 1st - 9th decimal places, 9 digits maximum)
States[4]: amount (integer representing digits on the 10th - 18th decimal places, 9 digits maximum)

Withdraw ONT & ONG Using tranferV2 (optional)

Previously, the transfer method is used for ONT and ONG withdrawals, which only takes an integer for the ONT withdrawal amount, or a decimal with 9 places for the ONG withdrawal amount (the smallest number is 0.000000001). The tranferV2 method is created to accommodate the decimals upgrade.
The transfer method still functions as before, you can continue using the method and related code if you don't change existing withdrawal rules. If you want to adapt to the decimals upgrade, you need to make below changes:

Ontology SDKs

Please use the latest SDKs:
SDK
Demo
Golang
Demo
Java
Demo 1, Demo 2
Demo

Signature Server

There are two ways to sign a transaction:
  1. 1.
    First, invoke the Ontology SDK method transferV2 to construct a transaction, and get the raw transaction in hex format. Then call the Ontology signature server method sigrawtx to sign the transaction, and get the signed transaction in hex format. Last, call the node's sendrawtx method to broadcast the transaction.
  2. 2.
    Invoke the Ontology signature server method sigtransfertxV2 to construct a transaction and sign it, and call the node's sendrawtx method to broadcast the transaction.
Please read the detailed doc for Ontology Signature Server here.