ONTO Wallet Plugin Integration

This doc describes the integration process for using the ONTO provider with the Web3 JS SDK and invoking the Ontology dAPI.

The chains that are currently supported:

  • Ethereum

  • Ontology

  • BNB Smart Chain (BSC)

  • OKXChain (OKC)

  • Polygon

  • Huobi ECO Chain

  • Arbitrum

  • IoTex

  • Avalanche-C

  • Harmony

The dAPI has been implemented for Ethereum and other homogeneous chains using the EIP-1193 API protocol. However, there are some differences to be noted.

  1. There are certain APIs that Metamask supports but are not supported by ONTO right now.

  2. There are differences in the way certain errors are handled.

  3. Legacy APIs are not supported.

Also, the dAPI methods that are currently available via the provider are limited and listed below.

Resources

Name: ONTO Wallet

Resource kit: https://www.onto.app/ONTO Media Kits.zip

Ethereum and Other Homogeneous Chains

import Web3 from "web3";

// Initialize web3 object by passing window.onto as the provider
const web3 = new Web3(window.onto);

// Request connection
web3.eth.requestAccounts().then((res) => {
  console.log(res[0]);
});

// Listen for accountsChanged and other events
window.onto.on("accountsChanged", (e) => {
  console.log(e.accounts[0]);
});

Ontology dAPI

import { client, provider } from "@ont-dev/ontology-dapi";

// Initialization
client.registerClient({
  extension: provider.ExtensionType.Onto, // or 'onto'
});

Refer to these docs for more API method details.

Available dAPI Methods

Currently available dAPI methods are limited to the ones listed below. Refer to the dAPI docs for details on each method.

Method name

asset.getAccount

asset.getPublicKey

network.getNetwork

network.getBalance

network.getBlock

network.getTransaction

network.getNodeCount

network.getBlockHeight

network.getMerkleProof

network.getStorage

network.getAllowance

network.getUnboundOng

network.getContract

network.getSmartCodeEvent

network.getBlockHeightByTxHash

network.getBlockHash

network.getBlockTxsByHeight

network.getGasPrice

network.getGrantOng

network.getMempoolTxCount

network.getMempoolTxState

network.getVersion

smartContract.invoke (doesn't support requireIdentity:true)

smartContract.invokeWasm (doesn't support requireIdentity:true)

smartContract.invokeRead (doesn't support requireIdentity:true)

smartContract.invokeWasmRead (doesn't support requireIdentity:true)

provider.getProvider

Last updated