AIN Wallet API

This document describes how to access AIN Wallet in a JavaScript based web app. Before following this article, make sure you have installed the AIN Wallet.

What does AIN Wallet API do?

AIN Wallet injects a JavaScript API into websites using the window.ainetwork object. This API allows websites to request users' AI Network accounts, and assists users in signing messages or sending transactions.

APIs

window.ainetwork.getAddress()

window.ainetwork.getAddress(): Promise<string>

Returns the address of the currently active account.

window.ainetwork.getAccount()

interface Account {
  name: string
  address: string
}

window.ainetwork.getAccount(): Promise<Account>

Returns the address of the currently active account.

window.ainetwork.getNetwork()

Returns the address of the currently active account.

window.ainetwork.getBalance()

Returns the AIN token balance of the currently active account.

window.ainetwork.signMessage()

Returns the signature for message signed with the private key of the currently active account.

window.ainetwork.sendTransaction()

Sends transaction to the AI Network, and returns the transaction hash.

Last updated

Was this helpful?