0.23.0 • Published 1 year ago

@openproduct/web-sdk v0.23.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
1 year ago

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

1 year ago

0.22.0

1 year ago

0.21.0

1 year ago

0.20.0

1 year ago

0.19.0

1 year ago

0.13.0

1 year ago

0.14.0

1 year ago

0.15.0

1 year ago

0.16.0

1 year ago

0.17.0

1 year ago

0.18.0

1 year ago

0.12.0

2 years ago

0.11.0

2 years ago

0.10.0

2 years ago

0.9.0

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago