Skip to content
This repository has been archived by the owner on Dec 30, 2023. It is now read-only.

Latest commit

 

History

History
61 lines (44 loc) · 1.95 KB

README.md

File metadata and controls

61 lines (44 loc) · 1.95 KB

💎 ton3-providers

TypeScript TON

This package is a part of ton3.

⚠️ Work in progress, API can (and most likely will) be changed! This is not production ready version yet.

How to install

npm i ton3-providers

Simple usage

import { Mnemonic, Address, Coins, Builder, BOC } from 'ton3-core'
import { ProviderRESTV2 } from 'ton3-providers'
import { Wallets } from 'ton3-contracts'

const highloadWalletExample = async () => {
    const provider = new ProviderRESTV2('https://testnet.toncenter.com/api/v2')
    const client = await provider.client()

    const mnemonic = new Mnemonic()
    const highload = new Wallets.ContractHighloadWalletV2(0, mnemonic.keys.public)

    console.log(mnemonic.words) // Get mnemonic phrase
    console.log(highload.address.toString()) // Get contract address

    // You need to deposit 1 ton to your contract address before deployment

    // Contract deployment
    const deploy = highload
        .createDeployMessage()
        .sign(mnemonic.keys.private)

    const { data: deployData } = await client.sendBoc(null, { boc: BOC.toBase64Standard(deploy) })

    console.log(deployData)

    // Create and send payments
    const transfers = Array(5).fill(null).reduce((acc, _el) => acc.concat({
        destination: new Address('xxx'),
        amount: new Coins('0.01'),
        body: new Builder().storeUint(0, 32).storeString('My message').cell(),
        mode: 3
    }), [])

    const payments = highload
        .createTransferMessage(transfers)
        .sign(mnemonic.keys.private)

    const { data: paymentsData } = await client.sendBoc(null, { boc: BOC.toBase64Standard(payments) })

    console.log(paymentsData)
}

License

MIT License