Develop Bitcoincash dApps

Transfer request

window.xfi.bitcoincash.request(
  {
    method: "transfer",
    params: [
      {
        feeRate,
        from,
        recipient,
        amount,
        memo,
      },
    ],
  },
  (error, result) => {
    console.debug(error, result);
    this.lastResult = { error, result };
  }
);

Accounts request

if (window.xfi && window.xfi.bitcoincash) {
  window.xfi.bitcoincash.request(
    {method: 'request_accounts'},
    (error, accounts) => console.log(`Bitcoincash accounts ${accounts}`)
  );
}

Result example

{
  "error": null,
  "result": [ "bitcoincash:qzxr6zwfhez9g06xmpe4n8xxls36rlkqlyv606v7zh" ]
}

Events

chainChanged

if (window.xfi && window.xfi.bitcoincash) {
  const provider = window.xfi.bitcoincash;
  provider.on("chainChanged", (obj) => {
    console.log(`chainChanged::${obj.chainId}`, obj);
  });
}

accountsChanged

if (window.xfi && window.xfi.bitcoincash) {
  const provider = window.xfi.bitcoincash
  provider.on("accountsChanged", (obj) => {
      console.log(`accountsChanged::${obj.chainId}`, obj);
  });
}