@lessenter/tonpay
v1.0.9
Published
A ton payment plugin implemented by combining tonconnect/ui, ton/ton.
Downloads
561
Maintainers
Readme
This is a ton payment public component encapsulated based on @tonconnect/ui and @ton/ton.
The main methods are:
- connect
- disconnect
- pay
- isConnecting
- getbalance
- decodeBoc
- getWalletInfo
- decodeAddress
How to use:
npm install @lessenter/tonpay
import $ton from '@lessenter/tonpay';
# Must first init and manifestUrl is required
$ton.init("your manifestUrl");
# Return wallet information
const walletInfo = await $ton.connect();
# Disconnect Wallet
$ton.disconnect();
# Transfer, the parameters are the target address, transfer amount, and remarks. If the wallet is not connected, the connection will be called first and then the transfer will be called
# back boc,hash,walletInfo
const { boc, hash, walletInfo } = await $ton.pay(address, amount, remark);
#is Connecting, back true/false
$ton.isConnecting();
#back wallet balance (address is required)
const balance = await $ton.getbalance(address);
# back transfer hash (boc is required)
const hash = $ton.decodeBoc(boc);
# back current wallet info
cont walletInfo = $ton.getWalletInfo();
# decode address (address is required)
cont address = $ton.decodeAddress(address);