Back to All News

Everything You Need To Know About Ontology EVM Contract Development Part 1


Today, Ontology, the high speed, low cost public blockchain bringing decentralized identity and data solutions to Web 3.0, announced the official deployment of a TestNet supporting EVM and opened the EVM compatible public beta to developers around the world. At the same time, the “Ontology Security Vulnerability and Threat Intelligence Bounty Programme” was officially launched in cooperation with SlowMist, a well-known code auditing agency. The top reward for reporting a vulnerability is $12,000 in ONG.


Through the integration of the Ethereum virtual machine, Ontology has achieved full compatibility with the Ethereum ecosystem. At present, the Ontology TestNet already supports EVM contracts and the node call method of the Ethereum chain. Developers can directly use EVM development tools such as Truffle, Remix and Web3.js on the Ontology TestNet for dApp deployment.


In order to encourage community developers to quickly and easily familiarize themselves with the Ontology EVM development environment, we specially prepared a “Handbook for Dummies”, which explains the essentials of Ontology EVM contract development.


1. Network Details


Before using the Ontology EVM, let’s first look at its configuration information including ChainID, RPC URL, and blockchain explorer address. Based on this information, you can configure your MetaMask wallet to connect to the Ontology network.


Due to the difference between the ONG precision (9 bits) in the Ontology EVM and the precision supported by Metamask (18 bits), the display in Metamask may experience errors. We recommended using the Ontology Bridge to check the ONG balance or make a transfer.


1.1 Node Network


MainNet Information


TestNet Information 



Note: When using MetaMask to connect to the Ontology network, please select “Custom RPC” in the MetaMask network settings, and then enter and save the configuration information according to the network type. 


 


1.2 EVM assets on the Ontology chain


TestNet



1.3 Gas Fee


The deployment of the EVM contract on the Ontology chain requires ONG as a handling fee. You can click here to receive the ONG test coin. 


1.4 Ontology Bridge


Ontology Network has achieved compatibility with the Ethereum ecosystem through the Ontology EVM virtual machine. Therefore, in addition to native contracts, the contract types supported by Ontology now include NeoVM contracts, Wasm contracts, and EVM contracts. This also means that NeoVM-based OEP-4 Tokens and EVM-based ORC-20 Tokens can exist on the Ontology blockchain. Since the address format and signature method supported by EVM are different from those supported by NeoVM/WasmVM, ORC-20 assets (EVM contract implementation, similar to ERC-20 assets), the Ontology system must be stored in the Ethereum private key corresponding address (beginning with 0x), OEP-4 assets (implemented by NeoVM contract) must be stored in the address corresponding to the Ontology private key (beginning with A). As the transaction fee of the Ontology network ONG is an exception, ONG can also exist in the Ethereum account address and Ontology account address.


In order to facilitate the mutual circulation of ORC-20 assets and OEP-4 assets within Ontology network between Ethereum accounts and Ontology accounts, Ontology provides the Ontology Bridge service, which is used in Ontology network deploys a Bridge contract (implemented by Wasm contract) to realize the mutual exchange of ORC-20 assets and OEP-4 assets between two different types of accounts. For ONG, users can use Ontology Bridge to transfer money between different types of addresses. 


Ontology Bridge contract implementation logic


  • Exchange OEP-4 for ORC-20
  • The user calls the oep4ToErc20 method of the Bridge contract through the Ontology private key signature. This method transfers the user’s OEP-4 assets to the Bridge contract address, and then transfers the corresponding amount of ERC-20 assets in the Bridge contract address to the user’s Ethereum private key generated address.
  • Exchange ORC-20 for OEP-4
  • The user needs to first use the Ethereum private key to call the approve method of the ORC-20 assets to authorize the address corresponding to the user’s Ontology private key to be able to transfer the ORC-20 assets.
  • The user uses the authorized Ontology private key to call the ERC-20 to OEP-4 method of the Bridge contract. This method will transfer the asset in the user’s Ethereum address to the Bridge contract address, and then transfer the corresponding amount of OEP-4 assets to the user’s Ontology address.  


Note that in either of the aforementioned two asset exchange processes, the user always uses the Ontology private key to interact with the Bridge contract in order to transfer the asset in the user’s Ethereum address (the user is required to use the Ethereum private key for authorization operations). During the redemption process, remember that ORC-20 assets always have the address corresponding to the Ethereum private key, and OEP-4 assets always have the address corresponding to the Ontology private key.