@ -1,57 +1,22 @@
import { beginCell , contractAddress , toNano , TonClient , TonClient4 , Address , WalletContractV4 , internal , fromNano , Cell } from "ton" ;
import { beginCell , contractAddress , toNano , TonClient , TonClient4 , Address , WalletContractV4 , internal , fromNano , Cell } from "ton" ;
import { mnemonicToPrivateKey } from "ton-crypto" ;
import { mnemonicToPrivateKey } from "ton-crypto" ;
import { buildOnchainMetadata } from "./utils/jetton- helpers" ;
import { buildOnchainMetadata } from "./utils/helpers" ;
import { TONB } from "./output/jetton_TONB" ;
import { TONB } from "./output/jetton_TONB" ;
import { client , wallet_data , workchain , owner , jettonParams , default_content } from "./utils/config" ;
( async ( ) = > { //need changes for jetton
( async ( ) = > { //need changes for jetton
//create client for testnet Toncenter API
const client = new TonClient ( {
endpoint : 'https://testnet.toncenter.com/api/v2/jsonRPC' ,
apiKey : 'bb38df0c2756c66e2ab49f064e2484ec444b01244d2bd49793bd5b58f61ae3d2'
} )
//create client for testnet sandboxv4 API - alternative endpoint
//create client for testnet sandboxv4 API - alternative endpoint
const client4 = new TonClient4 ( {
const client4 = new TonClient4 ( {
endpoint : "https://sandbox-v4.tonhubapi.com"
endpoint : "https://sandbox-v4.tonhubapi.com"
} )
} )
let { my_wallet , secretKey } = await wallet_data ( ) ;
// Insert your test wallet's 24 words, make sure you have some test Toncoins on its balance. Every deployment spent 0.5 test toncoin.
let mnemonics = "basic security merge opera inject core melody polar become force cool glance history order warfare consider company slim twice balcony scare shoot winner rude" ;
// read more about wallet apps https://ton.org/docs/participate/wallets/apps#tonhub-test-environment
let keyPair = await mnemonicToPrivateKey ( mnemonics . split ( " " ) ) ;
let secretKey = keyPair . secretKey ;
//workchain = 1 - masterchain (expensive operation cost, validator's election contract works here)
//workchain = 0 - basechain (normal operation cost, user's contracts works here)
let workchain = 0 ; //we are working in basechain.
//Create deployment wallet contract
let wallet = WalletContractV4 . create ( { workchain , publicKey : keyPair.publicKey } ) ;
let contract = client . open ( wallet ) ;
// Get deployment wallet balance
// Get deployment wallet balance
let balance : bigint = await contract . getBalance ( ) ;
let balance : bigint = await my_wallet . getBalance ( ) ;
// This is example data - Modify these params for your own jetton
// - Data is stored on-chain (except for the image data itself)
const jettonParams = {
name : "TactJet" ,
description : "This is description of Test tact jetton" ,
image : "https://ipfs.io/ipfs/QmbPZjC1tuP6ickCCBtoTCQ9gc3RpkbKx7C1LMYQdcLwti" // Image url
} ;
// Owner should usually be the deploying wallet's address.
let owner = Address . parse ( 'EQAuAiFGgkxoQvBWXjXQcLYb8BW4fO6UJkt6_uCONJ2y5VUk' ) ;
// Create content Cell
let content = buildOnchainMetadata ( jettonParams ) ;
// Compute init data for deployment
// Compute init data for deployment
let init = await TONB . init ( owner , content ) ;
let init = await TONB . init ( owner , default_content ) ;
let destination_address = contractAddress ( workchain , init ) ;
let destination_address = contractAddress ( workchain , init ) ;
@ -61,15 +26,13 @@ import {TONB} from "./output/jetton_TONB";
// send a message on new address contract to deploy it
// send a message on new address contract to deploy it
let seqno : number = await contrac t. getSeqno ( ) ;
let seqno : number = await my_walle t. getSeqno ( ) ;
//TL-B mint#01fb345b amount:int257 = Mint
let msg = beginCell ( ) . storeBuffer ( Buffer . from ( "01fb345b" , "hex" ) ) . storeInt ( amount , 257 ) . endCell ( ) ;
console . log ( '🛠️ Preparing new outgoing massage from deployment wallet. Seqno = ' , seqno ) ;
console . log ( '🛠️ Preparing new outgoing massage from deployment wallet. Seqno = ' , seqno ) ;
console . log ( 'Current deployment wallet balance = ' , fromNano ( balance ) . toString ( ) , '💎TON' ) ;
console . log ( 'Current deployment wallet balance = ' , fromNano ( balance ) . toString ( ) , '💎TON' ) ;
console . log ( 'Totally supply for deployed Token = ' , supply , ', amount = ' , amount . toString ( ) ) ;
console . log ( 'Totally supply for deployed Token = ' , supply , ', amount = ' , amount . toString ( ) ) ;
await contrac t. sendTransfer ( {
await my_walle t. sendTransfer ( {
seqno ,
seqno ,
secretKey ,
secretKey ,
messages : [ internal ( {
messages : [ internal ( {
@ -78,8 +41,7 @@ import {TONB} from "./output/jetton_TONB";
init : {
init : {
code : init.code ,
code : init.code ,
data : init.data
data : init.data
} ,
}
body : msg
} ) ]
} ) ]
} ) ;
} ) ;
console . log ( '======deployment message sent to ' , destination_address , ' ======' ) ;
console . log ( '======deployment message sent to ' , destination_address , ' ======' ) ;