DAPP 开发
2024年12月23日小于 1 分钟
DAPP 开发
TON DAPP 文档
npm install tonweb
HelloWorld
// 导入连接TON网络库
const TonWeb = require("tonweb");
// 实例化
const tonweb = new TonWeb();
// 获取账户余额
function getBalance(addr = "EQChB2eMoFG4ThuEsZ6ehlBPKJXOjNxlR5B7qKZNGIv256Da") {
tonweb
.getBalance(addr)
.then((balance) => {
console.log("余额:", balance, "TON");
})
.catch((error) => {
console.log(error);
});
}
getBalance();
// 获取交易
function getTransactions(
addr = "EQChB2eMoFG4ThuEsZ6ehlBPKJXOjNxlR5B7qKZNGIv256Da"
) {
tonweb
.getTransactions(addr)
.then((tran) => {
console.log(tran);
})
.catch((error) => {
console.log(error);
});
}
getTransactions();
获取交易
async function getLatestTransactions(address) {
try {
const transactions = await tonweb.provider.getTransactions(address, 1); // 获取最近的1笔交易
console.log(transactions);
} catch (error) {
console.error("Error fetching transactions:", error);
}
}
获取地址合约
获取 Block 信息

思 维 教程: