BCH Provider API

createSession (connect to Nabox wallet)

const res = await NaboxWallet.bch.createSession();

// Return value example
 {“selectedAddress”: ’The currently connected account address‘}

getAddress (get the currently connected account address)

const address = await NaboxWallet.bch.getAddress();

// qz4054as682..........6jt75f4dff5ur

getBalance (get the balance of the currently connected account)

const balance = await NaboxWallet.bch.getAddress();

// 1.555

getPub (get the public key of the current account)

const publicKey = await NaboxWallet.bch.getPub();

// 037c92dfbdafb4de8f1.........c6f95146c8233e107879ad

sendTransaction(send Transaction)

const transactionParameters = {
    to: 'Receiving Address',
    amount: 'Transfer amount',
    msg: 'Additional remark'
};

const hash = await NaboxWallet.bch.sendTransaction(transactionParameters);

// Returns the hash after broadcasting

signMessage(Message Signature)

const signature = await NaboxWallet.bch.signMessage('message');

// H1TDp5hWavCX52SajDh8fTKDqsJy2GlOERHEN1+pF4N5Xjb023SUn7DBM8ali8pSjkVYen6cOiX9UNUSbjvFum4=

on(event monitoring)

// Monitor account changes
NaboxWallet.bch.on("accountsChanged", (accounts) => {
  if (accounts.length) {
    console.log(accounts[0])
  }
});

Last updated