hi i want create secret key and address and deploy and send transaction by node js
please help me when i use this code showing me error wallet.deploy is not a function
const { getHttpEndpoint }=require("@orbs-network/ton-access")
const { mnemonicToWalletKey }= require( "ton-crypto")
const { TonClient, WalletContractV4, internal } =require("ton")
async function main() {
// open wallet v4 (notice the correct wallet version here)
const mnemonic = "direct draft victory insane daring train fog advice mail metal movie more diary because brick second trophy screen seat solar valid orient tiger news"; // your 24 secret words (replace ... with the rest of the words)
const key = await mnemonicToWalletKey(mnemonic.split(" "));
const wallet = WalletContractV4.create({ publicKey: key.publicKey, workchain: 0 });
// initialize ton rpc client on testnet
const endpoint = await getHttpEndpoint({ network: "mainnet" });
const client = new TonClient({ endpoint });
await wallet.deploy(key.secretKey).send(); // deploy wallet to blockchain
// make sure wallet is deployed
if (!await client.isContractDeployed(wallet.address)) {
return console.log("wallet is not deployed");
}
// send 0.05 TON to EQA4V9tF4lY2S_J-sEQR7aUj9IwW-Ou2vJQlCn--2DLOLR5e
const walletContract = client.open(wallet);
const seqno = await walletContract.getSeqno();
await walletContract.sendTransfer({
secretKey: key.secretKey,
seqno: seqno,
messages: [
internal({
to: "EQA4V9tF4lY2S_J-sEQR7aUj9IwW-Ou2vJQlCn--2DLOLR5e",
value: "0.05", // 0.05 TON
body: "Hello", // optional comment
bounce: false,
})
]
});
// wait until confirmed
let currentSeqno = seqno;
while (currentSeqno == seqno) {
console.log("waiting for transaction to confirm...");
currentSeqno = await walletContract.getSeqno();
}
console.log("transaction confirmed!");
}
main();
Sep 11, 2023, 9:25 AM