Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
forked from toncenter/tonweb

TypeScript SDK for TON (The Open Network)

License

Notifications You must be signed in to change notification settings

OpenProduct/openmask-websdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript SDK for The Open Network

NPM

Converted to typescript TonWeb. The library optimise to run in browser.

Install Web

npm install @openproduct/web-sdk

// or

yarn add @openproduct/web-sdk

// or

pnpm add @openproduct/web-sdk

TonHttpProvider

import { TonHttpProvider } from "@openproduct/web-sdk";

const provider = new TonHttpProvider(config.rpcUrl, {
  apiKey: config.apiKey,
});

// Get Wallet Balance
const amount: string = await provider.getBalance(wallet);

// Get Wallet SeqNo
const seqno: BN = await provider.call2(wallet, "seqno");

// Get wallet transactions
const transactions = await ton.getTransactions(wallet, 10);

Send transaction

import { ALL, hexToBytes, toNano } from "@openproduct/web-sdk";

const WalletClass = ALL[wallet.version];
const contract = new WalletClass(provider, {
  publicKey: hexToBytes(wallet.publicKey),
  wc: 0,
});

const params: TransferParams = {
  secretKey: keyPair.secretKey,
  toAddress,
  amount: toNano(amount),
  seqno: seqno,
  payload: comment,
  sendMode: 3,
};

const method = contract.transfer(params);

// Get estimate fee
const fees = await method.estimateFee();

// Send transaction

await method.send();

TonDNS

Resolve ton DNS address:

import { TonDns } from "@openproduct/web-sdk";

const dns = new TonDns(provider, { rootDnsAddress: config.rootDnsAddress });
const address = await dns.getWalletAddress(toAddress);
if (!address) {
  throw new Error("Invalid address");
}
if (!Address.isValid(address)) {
  throw new Error("Invalid address");
}

About

TypeScript SDK for TON (The Open Network)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 70.3%
  • TypeScript 26.9%
  • HTML 2.8%