Skip to content

Meta Transaction

This example rappresent the case of calling a smart contract function through meta transaction.

const { BcodeSDK, Hash, QRCode } = require("@bcode-tech/bcode-sdk");

const sdk = new BcodeSDK({
  apiKey: "<your-api-key>",
  config: {
    env: "MUMBAI",
    debugMode: true,
  },
});

async () => {
  await sdk.init();

  const res = await sdk.prepareTransaction(
    {
      address: "0xE518725c53B4272d72c10b623A8443B62D19Ef1E",
      abi: [
        {
          inputs: [],
          name: "decrement",
          outputs: [],
          stateMutability: "nonpayable",
          type: "function",
        },
      ],
      name: "TestMetaTransaction",
      version: "0.1.0",
    },
    "decrement",
    []
  );

  const requestId = await sdk.executeAsyncTransaction(res);

  console.log(requestId);

  console.log(
    await sdk.getMetaTxStatus(requestId)
  );

});