Skip to content

prepareTransaction

Prepare transaction that need to be executed through meta transaction.

ParamDefault valueDescription
contractObjArray with Bcode NFT ContractArray of interested contract addresses
functionNameCurrent user addressWallet address of NFT owner
paramsArrayArray of original prams for contract function
optionalsObjectOptionals element, like nonce
⚠️

It's important to set name and version as the one setted in the deployed smart contract.

If they are not setted correctly an error will be visible in polygonscan explorer. The error will be:


Error: Signer and signature do not match

Usage

const tx = await sdk.prepareTransaction(
  {
    address: config[`TEST_META_TX_${env}`],
    abi: testMetaTxAbi,
    name: "TestMetaTransaction",
    version: "0.0.1",
  },
  "increment",
  [],
  optionals
));

The variable optionals includes the nonce that can be used for implementing concurrent transaction logic.

Basically, if the wallet is going to execute more transaction in sequence, is suggested to keep track of the blockchain's nonce and the current pending transactions, in this way you can use the nonce and add the number of current pending transaction to prepare transaction without using duplicate nonce.