0.0.9 • Published 2 years ago

ton3-providers v0.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

💎 ton3-providers

TypeScript TON

This package is a part of ton3.

:warning: 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

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago