npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@okxweb3/coin-ton

v1.0.8

Published

TON SDK is used to interact with the TON/Venom blockchain, it contains various functions can be used to web3 wallet.

Downloads

318

Readme

@okxweb3/coin-ton

TON SDK is used to interact with the TON/Venom blockchain, it contains various functions can be used to web3 wallet.

Installation

Npm

To obtain the latest version, simply require the project using npm :

npm install @okxweb3/coin-ton

Usage

TON

Generate address

import { TonWallet } from "@okxweb3/coin-ton";

const wallet = new TonWallet();
const param = {
  privateKey: "fc81e6f42150458f53d8c42551a8ab91978a55d0e22b1fd890b85139086b93f8"
};
const address = await wallet.getNewAddress(param);

Verify address

import { TonWallet } from "@okxweb3/coin-ton";

const wallet = new TonWallet();
const param = {
    address: "EQA3_JIJKDC0qauDUEQe2KjQj1iLwQRtrEREzmfDxbCKw9Kr"
};
const isValid = await wallet.validAddress(param);

Transfer TON

import { TonWallet } from "@okxweb3/coin-ton";

const wallet = new TonWallet();
const param = {
  privateKey: "fc81e6f42150458f53d8c42551a8ab91978a55d0e22b1fd890b85139086b93f8",
  data: {
    to: "EQA3_JIJKDC0qauDUEQe2KjQj1iLwQRtrEREzmfDxbCKw9Kr",
    amount: "10000000",
    seqno: 2,
    toIsInit: true,
    memo: "",
  },
};
const tx = await wallet.signTransaction(param);

parameters

  • to, address, TON token接收地址
  • amount, number, TON转账的数量,TON精度是9
  • seqno, number, nonce or sequence of from address,
  • toIsInit, boolean, destination address init or not
  • memo, string, comment for this tx
  • expireAt, number, timeout at seconds eg, 1718863283n, default now + 60s
  • sendMode, SendMode, 用于控制交易的行为和模式,决定了消息(通常是转账交易)的处理方式,不同的mode可以组合使用,有以下取值
    • CARRY_ALL_REMAINING_BALANCE = 128, 用于指示将账户的所有剩余余额发送出去。这在某些情况下非常有用,比如清空账户余额时。
    • CARRY_ALL_REMAINING_INCOMING_VALUE = 64, 用于指示所有剩余的传入价值(比如剩余的资金)应该被携带并发送出去,而不是留下来。
    • DESTROY_ACCOUNT_IF_ZERO = 32,它确保在交易完成后,如果目标账户的余额为零,则销毁该账户。这种方式可以用于自动清理不再需要的账户,从而减少存储使用
    • 16, 在动作失败的情况下 - 弹回交易。如果使用+2,则无效。
    • PAY_GAS_SEPARATELY = 1, 用于指示消息的 gas 费用应该从发送者账户中单独支付,而不是从消息附带的金额中扣除。
    • IGNORE_ERRORS = 2, 当启用此标志时,即使在处理消息时发生错误,也会继续处理该消息,而不会将错误传播给调用者。这在某些情况下非常有用,例如在发送非关键性消息或进行非重要操作时,你希望保证消息的发送而不关心处理中的错误。
    • NONE = 0 ,在转账的时候,如果目标账户没有足够的余额支付传输费用,消息会失败

Venom

Generate address

import { VenomWallet } from "@okxweb3/coin-ton";

const wallet = new VenomWallet();
const param = {
  privateKey: "fc81e6f42150458f53d8c42551a8ab91978a55d0e22b1fd890b85139086b93f8"
};
const address = await wallet.getNewAddress(param);

Verify address

import { VenomWallet } from "@okxweb3/coin-ton";

const wallet = new VenomWallet();
const param = {
    address: "0:6bef7d76e46fd1f308f0bf0b59f1ca6318aa6d950ea00aecc7d162218acaaa36"
};
const isValid = await wallet.validAddress(param);

Transfer Venom

import { VenomWallet } from "@okxweb3/coin-ton";

const wallet = new VenomWallet();
const param = {
  privateKey: "fc81e6f42150458f53d8c42551a8ab91978a55d0e22b1fd890b85139086b93f8",
  data: {
    to: "0:6bef7d76e46fd1f308f0bf0b59f1ca6318aa6d950ea00aecc7d162218acaaa36",
    amount: "10000000",
    seqno: 2,
    toIsInit: true,
    memo: "",
    globalId: 1000,
  },
};
const tx = await wallet.signTransaction(param);

License

Most packages or folder are MIT licensed, see package or folder for the respective license.