|
|
import { beginCell, contractAddress, toNano, TonClient, TonClient4, Address, WalletContractV4, internal, fromNano, Cell} from "ton"; |
|
|
import {mnemonicToPrivateKey} from "ton-crypto"; |
|
|
import {buildOnchainMetadata} from "./utils/helpers"; |
|
|
import {Foundation} from "./output/jetton_Foundation"; |
|
|
import {client, wallet_data, workchain} from "./utils/config"; |
|
|
import { createDistribution, createAddressList, getTONBState } from './utils/interactions'; |
|
|
|
|
|
|
|
|
(async () => { |
|
|
|
|
|
//create client for testnet sandboxv4 API - alternative endpoint |
|
|
const client4 = new TonClient4({ |
|
|
endpoint: "https://sandbox-v4.tonhubapi.com" |
|
|
}) |
|
|
let {my_wallet, secretKey} = await wallet_data(); |
|
|
|
|
|
// Get deployment wallet balance |
|
|
let balance: bigint = await my_wallet.getBalance(); |
|
|
// Compute init data for deployment |
|
|
let init = await Foundation.init( |
|
|
createDistribution([my_wallet.address], [100n]), |
|
|
createAddressList([my_wallet.address]), |
|
|
contractAddress(workchain, await getTONBState())); |
|
|
let destination_address = contractAddress(workchain, init); |
|
|
|
|
|
|
|
|
let deployAmount = toNano('0.2'); |
|
|
|
|
|
|
|
|
// send a message on new address contract to deploy it |
|
|
let seqno: number = await my_wallet.getSeqno(); |
|
|
|
|
|
|
|
|
console.log('🛠️Preparing new outgoing massage from deployment wallet. Seqno = ', seqno); |
|
|
console.log('Current deployment wallet balance = ', fromNano(balance).toString(), '💎TON'); |
|
|
await my_wallet.sendTransfer({ |
|
|
seqno, |
|
|
secretKey, |
|
|
messages: [internal({ |
|
|
value: deployAmount, |
|
|
to: destination_address, |
|
|
init: { |
|
|
code : init.code, |
|
|
data : init.data |
|
|
} |
|
|
})] |
|
|
}); |
|
|
console.log('======deployment message sent to ', destination_address, ' ======'); |
|
|
})();
|
|
|
|