npm i -S git+https://github.com/klouskingsley/bsv-web-wallet.git
import webWallet from "bsv-web-wallet";
const { Bsv } = webWallet;
const bsv = new Bsv();
// 连接到钱包
await bsv.requestAccount().then();
// 获取钱包账户信息
const accountInfo = await bsv.getAccount();
// 获取bsv 余额
const bsvBalance = await bsv.getBsvBalance();
// 发送bsv
const transferBsvRes = await bsv.transferBsv({
receivers: [{ address: "xxx", amount: 333 }],
});
// 发送 sensible ft
const transferFtTres = await bsv.transferSensibleFt({
receivers: [{ address: "xxx", amount: 344 }],
codehash: "codehash",
genesis: "genesis",
rabinApis: [
"https://s1.satoplay.com"
]
});
const transferAll = await bsv.transferAll([{
receivers: [{ address: "xxx", amount: 344 }],
codehash: "codehash",
genesis: "genesis",
rabinApis: [
"https://s1.satoplay.com"
]
}])
连接到钱包
退出登录
获取钱包账户信息
获取钱包地址
获取钱包 bsv 余额,balance 单位为 satoshi
获取钱包 sensible ft 余额
interface SensibleFt {
genesis: string;
codehash: string;
tokenName: string;
tokenSymbol: string;
tokenDecimal: number;
balance: number;
}
bsv 转账
interface Receiver {
address: string;
amount: number;
}
bsv.transferSensibleFt({receivers: Array, codehash: string, genesis: string, rabinApis: Array}): Promise<{txid: string}>
sensible ft 转账
interface Receiver {
address: string;
amount: number;
}
bsv.transferAll([{receivers: Array, codehash: string, genesis: string, rabinApis: Array}): Promise<{txid: string}]>
bsv 和 sensible ft 混合转账
interface Receiver {
address: string;
amount: number;
}