Links

Binance

Develop Binance dApps

Transfer request

const { asset, from, recipient, amount, memo } = {
asset: {
chain: "BNB",
symbol: "BNB",
ticker: "BNB",
},
from: 'xxxx',
recipient: 'yyyy',
amount: {
amount: 500,
decimals: 8
},
memo: 'hint'
};
window.xfi.binance.request(
{
method: "transfer",
params: [
{
asset,
from,
recipient,
amount,
memo,
},
],
},
(error, result) => {
console.debug(error, result);
this.lastResult = { error, result };
}
);

Accounts request

if (window.xfi && window.xfi.binance) {
window.xfi.binance.request(
{method: 'request_accounts', params: []},
(error, accounts) => console.log(`Binance accounts ${accounts}`)
);
}

Result example

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

Events

chainChanged

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

accountsChanged

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