Wallet

The WalletProvider follows the EIP-1193 standard and supports the EventEmitter interface defined in it.

sdk.getWalletProvider()

Initializes the walletProvider, allowing developers to use various wallet features.

const walletProvider = sdk.getWalletProvider();

Parameters N/A

Responses

WalletProvider

walletProvider.getWalletType()

Returns the type of the currently connected wallet.

const walletType = walletProvider.getWalletType();

Parameters N/A Responses

enum WalletType {
    Web = "Web",
    Liff = "Liff",
    Extension = "Extension",
    Mobile = "Mobile",
    OKX = "OKX",
    BITGET = "BITGET"
}

walletProvider.request()

This function provides JSON-RPC API format on request. You can send request to retrieve healthy status of chain and sign transaction with wallet. If you send it before wallet connection, user will see a screen to select wallet type to connect.

You can find the available KAIA-related methods, their parameters, and corresponding responses in the table below. RPC methods that are not included in the table will be requested directly to the chain node and please refer to Kaia docs' RPC API Reference.

Parameters RequestArguments *required · object - method *required · string

- params unknown[] Responses

method
params
Responses

kaia_accounts

Returns the list of addresses currently connected to the wallet. If no wallet is connected, an empty array is returned.

null

kaia_requestAccounts Initiates wallet connection. During the process, a window is displayed for the user to select a wallet provider. Returns a list of addresses associated with the selected wallet.

null

personal_sign (EIP-191)

Initiate sign procedure. We recommend to use personal_sign to get compatibility with various wallets including OKX Wallet.

[message: string, account: string]

signature

kaia_connectAndSign (EIP-191) recommended Iniitiates wallet connection and signing. Prompts the user to select a wallet provider, then signs the provided message. Returns [account, signature] as an array.

[message: string]

account and signature as Array

kaia_getBalance Returns the kaia balance.

[account: string, blockNumberOrHash: string] blockNumberOrHash can be set as latest or earliest

  • latest: the most recent block

  • earliest: the genesis block (block 0)

the balance value in kei, the smallest unit of the KAIA blockchain. 1 KAIA = 10^18 kei

kaia_sendTransaction Constructs a transaction with given parameters

[{ from: string, to: string, value: string, gas: string }] from field should be the account that achieved from 'kaia_accounts','kaia_requestAccounts' or 'kaia_connectAndSign'

transactionHash

Error

Code
Description

-32001

-32004

Invalid from address (Please retry methohs after executing walletProvider.disconnectWallet())

-32005

User logged out due to incorrect password input (Please retry methohs after executing walletProvider.disconnectWallet())

-32006

Wallet is not connected yet (If an error occurs while the wallet in connected, Please retry methods after executing walletProvider.disconnectWallet(). If an error occurs while the wallet is not connected, please connect wallet first)

walletProvider.disconnectWallet()

Disconnects the wallet. When this function is called, a confirmation window will appear to confirm the disconnection.

Parameters N/A Responses N/A

walletProvider.getErc20TokenBalance()

Parameters

contactAddress *required · string account *required · string

Responses

64-byte hexadecimal string. The returned value includes the token’s decimal scaling according to its decimals specification.

For example, USDT uses a decimal scale of 10⁶, while DELABS uses a decimal scale of 10¹⁸.

Compatible Libraries

Last updated