The code is below, but the tx is empty after sendTransfer.
import { WalletContractV4, beginCell, internal, TonClient4, toNano, Address } from 'ton';
const packed_msg = beginCell().store(
storeMsg({
$$type: MSG_TYPE,
}),
)
.endCell();
const tx = await contract.sendTransfer({
seqno,
secretKey,
messages: [
internal({
to: this.contractAddress,
value: gasFee: toNano('0.02'),
body: packed_msg,
}),
],
});
Dec 18, 2023, 3:32 PM
I said sendTransfer code and valid one. this is not valid.
// create client
const client = new TonClient({
endpoint: 'https://toncenter.com/api/v2/jsonRPC',
apiKey: 'YOUR_API_KEY'
});
// get sender
let workchain = 0;
let keyPair = await mnemonicToPrivateKey(mnemonics.split(" "));
let secretKey = keyPair.secretKey;
let wallet_contract = WalletContractV4.create({ workchain, publicKey: keyPair.publicKey });
let my_wallet = client.open(wallet_contract);
let seqno: number = await my_wallet.getSeqno();
// send and get TX
// your code from prv msg
const packed_msg = beginCell().store(
storeMsg({
$$type: MSG_TYPE,
}),
)
.endCell();
await my_wallet.sendTransfer({
seqno,
secretKey,
messages: [
internal({
to: this.contractAddress,
value: gasFee: toNano('0.02'),
body: packed_msg,
}),
],
});
// get transactions from API
let transactions = await client.getTransactions(my_wallet.address);
console.log(transactions);
you can use blueprint to run your scripts with built-in providers or if it's a web app you should use tonconnect sdk
// create client
const client = new TonClient({
endpoint: 'https://toncenter.com/api/v2/jsonRPC',
apiKey: 'YOUR_API_KEY'
});
// get sender
let workchain = 0;
let keyPair = await mnemonicToPrivateKey(mnemonics.split(" "));
let secretKey = keyPair.secretKey;
let wallet_contract = WalletContractV4.create({ workchain, publicKey: keyPair.publicKey });
let my_wallet = client.open(wallet_contract);
let seqno: number = await my_wallet.getSeqno();
// send and get TX
// your code from prv msg
const packed_msg = beginCell().store(
storeMsg({
$$type: MSG_TYPE,
}),
)
.endCell();
await my_wallet.sendTransfer({
seqno,
secretKey,
messages: [
internal({
to: this.contractAddress,
value: gasFee: toNano('0.02'),
body: packed_msg,
}),
],
});
// get transactions from API
let transactions = await client.getTransactions(my_wallet.address);
console.log(transactions);
you can use blueprint to run your scripts with built-in providers or if it's a web app you should use tonconnect sdk
Dec 18, 2023, 4:14 PM
I use the getTransactions before, but can’t find the field of txId, and how to make sure the latest transaction is the one we are looking for if it’s a tx list.
I figured out how to solve it. Thanks
Dec 19, 2023, 2:50 AM