@openproduct/web-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.23.0 • Public • Published

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");
}

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.23.0489latest

Version History

VersionDownloads (Last 7 Days)Published
0.23.0489
0.22.00
0.21.00
0.20.00
0.19.00
0.18.00
0.17.00
0.16.00
0.15.00
0.14.00
0.13.00
0.12.00
0.11.00
0.10.01
0.9.00
0.8.00
0.7.00
0.6.00
0.5.00
0.4.00
0.3.00
0.2.00
0.1.00

Package Sidebar

Install

npm i @openproduct/web-sdk

Weekly Downloads

490

Version

0.23.0

License

GPL-3.0

Unpacked Size

581 kB

Total Files

214

Last publish

Collaborators

  • openproduct