"error Error: The given transaction is not valid due to: unable to serialize parameters: Parse error at __.sendTransaction (inject.js:13:7962)"

I am facing this error on sending the txn. It says serialize error which is quite unusual as we can send this same parameter.

here is my serialize string and the parameter seems okay for the current struct …
“FAAIAAAACgAAAHN0YXJ0X3RpbWUNCAAAAGVuZF90aW1lDQgAAABzb2Z0X2NhcBcIAAAAaGFyZF9jYXAXDAAAAHJvY2tldF90b2tlbhQAAgAAAAIAAABpZB0ABwAAAGFkZHJlc3MMCwAAAHRvdGFsX3Rva2VuFxAAAAB0b2tlbl9jb252ZXJzaW9uFwoAAABzZWxsX3Rva2VuFAACAAAAAgAAAGlkHQAHAAAAYWRkcmVzcww”

Hi and welcome to the Concordium community!

I need some more information from you in order to help you:

  • Which contract and entrypoint are you trying to call?
  • The Rust code for the parameter you want to use
  • Where is the parameter currently working?

Looking forward to hearing from you :blush:

/ Kasper

Hi, I have fixed the issue there were a couple of things I missed. I will note it down as it will help others in the future.

  1. Basic way of sending the params is using the string so i replaced the soft_cap, hard_cap, total_token etc as a string “10000” rather then using the BigNumber or anything else

  2. I have changed the sendTransactions as follows

 .sendTransaction(
        wallet,
        AccountTransactionType.Update,
        {
          amount: new CcdAmount(BigInt("0")),
          contractAddress: { index: INDEX.toString(), subindex: "0" },
          receiveName: "contract_name.function_calling",
          maxContractExecutionEnergy: "30",
        },
        { ...parameter },
        RAW_SCHEMA_BASE64.toString("base64"),
        SchemaVersion.V2
      )

We can see the index of the contract and the subindex should always be in the string rather then number or else you will get error on pop up

  1. Another point is you need to always send the RAW_SCHEMA_BASE64 as a string by using .toString(“base64”) functions at list it worked for me please let me know if we have any other thing.

  2. Last thing is to always send the BigInt type to the CcdAmount(BigInt(“0”)) as such otherwise the pop-up will get empty after we get it.

  3. SchemaVersion.V2 is something I kept which is nice to have.

1 Like

Hello rustwizard,
what is RAW_SCHEMA_BASE64, I’m following piggy bank frontend repo and they are passing the empty string for it

    console.log(new CcdAmount(BigInt('1')), contract.name);
    return {
        amount: new CcdAmount(BigInt(1)),
        address: {
            index: BigInt('4836'),
            subindex: BigInt('0'),
        },
        receiveName: `ves-contract.vest`,
        maxContractExecutionEnergy: MAX_CONTRACT_EXECUTION_ENERGY,
    };
}

export async function submitDeposit(connection: WalletConnection, amount: CcdAmount, account: string, contract: Info) {
    return connection.signAndSendTransaction(
        account,
        AccountTransactionType.Update,
        contractUpdatePayload(amount, contract, 'insert'),
        {},
        ''
    );
}```

The raw schema is the schema for the contract.

You can generate it using cargo-concordium by using the --schema-base64 option.

Note that for the piggy-bank contract is not really necessary since endpoints don’t take any parameters.

so we don’t need to provide schema if we don’t use parameter in smart contract?