Skip to content

Meta Transaction

BcodeSDK uses EIP712 compatible meta transaction system to enable user gasless transaction. Executing meta transaction require you to sign a specific formatted transaction, but the SDK allows developers to forget about complexity by preparing and sending the transaction.

To send a meta transaction you need to prepare a transaction with the following fields:

type MetaTransaction = {
  contractAddress: string;
  userAddress: string;
  functionSignature: string;
  r: string;
  s: string;
  v: any;

const tx: MetaTransaction = await sdk.prepareTransaction(
    address: "contract_address",
    abi: testMetaTxAbi,
    name: "contract",
    version: "0.0.1",

Keep in mind that meta transactions are like other transactions, so there's a nonce for everyone that has to be incremental and not be skipped or duplicated. So, in case of concurrent meta transaction execution the developer can specify the correnct nonce. If more transaction have to be sended in a short period of time, it can be done by manually incrementing the nonce with a counter.

The current blockchain nonce for the meta transaction can be fetched with getNonce function

After obtained the tx object, the transaction can be sent to BCode API service.

const requestId = await sdk.executeAsyncTransaction(tx, optionals);

The return value is an id usefull to query transaction status.

Webhook can be used to get notified when transaction is completed with success or failed status. In the webhook call can be included a metadata key with data passed in executeAsyncTransaction call.

Otherwise if webhook is not needed, transaction status can be queried with:

const res = await sdk.getMetaTxStatus(requestId);

The return value contains:

  • status: "success" | "failed" | "pending" | "queued" | "mined"
  • tx: EVM transaction object
  • receipt: EVM receipt object
  • ethTx: EVM receipt object

This procedure allows the developer to send a transaction without caring about gas price or network problem.

To any other implementation doubts refer to function documentation and example