Wallet API

Properties

window.havah

This property is true if the user has HAVAH wallet installed.

Example

if (window.havah) {
  console.log('HAVAH wallet is installed!');
}

Methods

havah.accounts()

Returns the selected account on the HAVAH wallet if it is connected.

Interface

interface AccountResult {
    address: string;
    nid: string;
    error?: string;
}

havah.accounts(): Promise<AccountResult>;

Example

havah.connect()

It requests to connect the selected account on the HAVAH wallet to the caller’s site. If it has not been granted, HAVAH wallet will ask the user to allow it. If the user rejects or closes the wallet, it doesn’t emit an event.

Interface

Example

havah.sign()

It signs the given data and returns it.

Interface

Example

havah.sendTransaction()

It sends a transaction with the given data. Refer to the link for the Transaction structure.

Interface

Parameter

  • to: EOA address to receive coins, or contract address to execute the transaction. It’s required.

  • value: Amount of HVH coin in loop to transfer. When omitted, it assumes 0. (1 HVH = 10 ^ 18 loop). Note that it's number format in HVH.

  • method: name of contract function to call. Equivalent to "method" under "data" for contract function call.

  • params: JSON object of input parameters for the function to call. Equivalent to "params" object under "data" for contract function call.

  • version: Protocol version (0x3 for JSON-RPC V3)

  • stepLimit: Maximum step allowance that can be used by the transaction. If it's not set, wallet estimates TX fee and sets it.

  • timestamp: Transaction creation time in microsecond

  • nonce: An arbitrary number used to prevent transaction hash collision

Example - Contract Call

Wallet will call JSON RPC API as follows.

Example - HVH Transfer

Wallet will call JSON RPC API as follows.

Events

accountsChanged

Emits this event with a new account when the selected account on the HAVAH wallet changes.

networkChanged

Emits this event with a new network ID when the selected network on the HAVAH wallet changes.

Last updated