I am trying contract-update transaction in nodeJs on Testnet. all data is real(Testnet Account).
client is not sending transaction.
what should be the amount in non payable function?
Error:
const sendUpdateTransaction = async () => {
let TestnetAccountaddress = new AccountAddress("32Ee8mYD9aqa93gbrv5Yno29SUx4FoRb34YEMgBz2TNBa1KVv7")
// const nonce = await client.getNextAccountNonce(new AccountAddress("32Ee8mYD9aqa93gbrv5Yno29SUx4FoRb34YEMgBz2TNBa1KVv7"));
const nonce = await client.getNextAccountNonce(TestnetAccountaddress);
console.log(BigInt(nonce.nonce));
const header = {
expiry: new TransactionExpiry(new Date(Date.now() + 3600000)),
nonce: BigInt(nonce.nonce), // the next nonce for this account, can be found using getNextAccountNonce
sender: TestnetAccountaddress,
};
const contractAddress = { index: BigInt(1785n), subindex: BigInt(0n) };
const receiveName = "backgammon.transfer_prize"
const parameters = {
"match_id": 1,
"winner": "32Ee8mYD9aqa93gbrv5Yno29SUx4FoRb34YEMgBz2TNBa1KVv7"
}
const rawModuleSchema = Buffer.from(fs.readFileSync(
'schema.bin'
));
const schemaVersion = SchemaVersion.V1;
const serializedparams = serializeUpdateContractParameters(
"backgammon",
"transfer_prize",
parameters,
rawModuleSchema,
schemaVersion);
console.log(serializedparams.toString("hex"));
const updateModule ={
amount: new GtuAmount(BigInt(0n)),
contractAddress: contractAddress,
receiveName: receiveName,
parameter: serializedparams,
maxContractExecutionEnergy: BigInt(5000n)};
const updateContractTransaction= {
header: header,
payload: updateModule,
type: AccountTransactionType.UpdateSmartContractInstance,
};
const signer = buildBasicAccountSigner("19de5a445db896cfdb51482b4327cf305c5b31f0d5704c7daa2e382a6c9641ea");
// const signer = buildBasicAccountSigner(mainetkey);
// console.log(await signer.sign());
console.log(signer);
const transactionSignature = await signTransaction(updateContractTransaction, signer);
console.log(transactionSignature);
const send = await client.sendAccountTransaction(updateContractTransaction,transactionSignature);
// const signature = Buffer.from(await sign(hashToSign, signingKey)).toString("hex");
console.log(666)
console.log(send)
}
i tried both mainnet and testnet account.
all i can think of wrong signing key:
here is schema :