DAPP 开发

DeeLMind2024年12月23日小于 1 分钟

DAPP 开发

TON DAPP 文档open in new window

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 信息


上次编辑于: 2026/3/11 05:49:26
贡献者: DeeLMind,DeeLMind
课程与服务