mpc-ton
v0.0.1
Published
Cross-platform client for Rangers MPC TON blockchain.
Downloads
45
Readme
MPC TON JS Client
Cross-platform client for Rangers MPC TON blockchain.
Features
- 🚀 Create new wallets
- 🍰 Get balance
- ✈️ Transfers
Install
yarn add mpc-ton @ton/crypto @ton/core buffer
Browser polyfill
// Add before using library
require("buffer");
Usage
To use this library you need HTTP API endpoint, you can use one of the public endpoints:
- Mainnet: https://toncenter.com/api/v2/jsonRPC
- Testnet: https://testnet.toncenter.com/api/v2/jsonRPC
import { TonClient, WalletContractV4, internal } from "mpc-ton";
// Create Client
const client = new TonClient({
endpoint: 'https://testnet.toncenter.com/api/v2/jsonRPC',
});
//init mpc
let signer = new MpcSigner({
private_key,
userTokenFn
});
signer = await signer.init({ sendSmsCodeFn });
// Create wallet contract
const publicKey = await signer.getAddress();
let workchain = 0; // Usually you need a workchain 0
let wallet = WalletContractV4.create({mpcSigner: signer, workchain, publicKey});
let contract = client.open(wallet);
// Get balance
let balance: bigint = await contract.getBalance();
// Create a transfer
let seqno: number = await contract.getSeqno();
let transfer = await contract.createTransfer({
seqno,
sendMode: 3,
messages: [internal({
value: '1.5',
to: 'EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N',
body: 'Hello world',
})]
});
License
MIT