Build
Skip to content

Transaction receipts

Transaction Receipts: Transactions return receipts indicating success or failure. Failed receipts are generated without transaction execution.

Successful Transaction Response: A successful transaction provides a SentTransactionResponse. Always verify this response with the isSentTransactionResponse type guard before accessing the transaction hash.

import { Sequence, isSentTransactionResponse } from "@0xsequence/waas";
 
const waas = new SequenceWaaS(
  {
    projectAccessKey: `${process.env.PROJECT_ACCESS_KEY}`,
    waasConfigKey: `${process.env.WAAS_CONFIG_KEY}`,
    network: "arbitrum-nova",
  }
);
 
await waas.signIn({ idToken }, "Session name");
 
const tx = await waas.sendTransaction({
  chainId: 42161,
  transactions: [
    {
      to: "0xD72C236Be524Ec24F72329317e2785E687105B69",
      value: "0",
    },
  ],
});
 
if (isSentTransactionResponse(tx)) {
  console.log(tx);
}
Understanding Transaction Details Fields in Transaction Responses:
  • txHash: The hash of the transaction sent to the network.
  • receipt.logs: Logs emitted during the transaction.
  • receipt.status: Indicates if the transaction SUCCEEDED or FAILED.
  • receipt.revertReason: Explains why a transaction was reverted, if applicable.

To view the full response object, see the Response payloads section.

{
  "code": "transactionReceipt",
  "data": {
    "txHash": "0xf2e9f728abd65089f25efda5852e605ced377f4e2c89dbf143b124623ed09b2c",
    "metaTxHash": "acc36ed4ef40db74137266e48d863083a5c7e85e2735d69adafcb5b362b6cfc0",
    "nativeReceipt": { ... },
    "receipt": {
      "id": "acc36ed4ef40db74137266e48d863083a5c7e85e2735d69adafcb5b362b6cfc0",
      "index": 0,
      "logs": [
        {
          "address": "0x4d4EE1b8583e31fe789eAF2e1b6e011C220c10B6",
          "data": "0x0000000000000000000000001119e72b4af230becebd933d0e07f0eec51d8c2a0000000000000000000000000000000000000000000000000000000000000001",
          "topics": [
            "0x1f180c27086c7a39ea2a7b25239d1ab92348f07ca7bb59d1438fcf527568f881"
          ]
        },
        {
          "address": "0x4d4EE1b8583e31fe789eAF2e1b6e011C220c10B6",
          "data": "0x0000000000000000000000000000000000000000000000000000000000000000",
          "topics": [
            "0x5c4eeb02dabf8976016ab414d617f9a162936dcace3cdef8c69ef6e262ad5ae7",
            "0xacc36ed4ef40db74137266e48d863083a5c7e85e2735d69adafcb5b362b6cfc0"
          ]
        }
      ],
      "receipts": [ ... ],
      "revertReason": null,
      "status": "SUCCEEDED"
    },
    "request": { ... },
    "simulations": [ ... ]
  }
}

Failed transaction response

An In-Game Wallet pre-empts failing transactions by simulating them on the network before actual submission. If the simulation fails, the transaction is not sent, and a FailedTransactionResponse is returned.

To view the full response object, see the wallet Response payloads section.

import { Sequence, isSentTransactionResponse } from "@0xsequence/waas";
 
const waas = new SequenceWaaS(
  {
    projectAccessKey: `${process.env.PROJECT_ACCESS_KEY}`,
    waasConfigKey: `${process.env.WAAS_CONFIG_KEY}`,
    network: "arbitrum-nova",
  }
);
 
await waas.signIn({ idToken }, "Session name");
 
const tx = await waas.sendTransaction({
  chainId: 137,
  transactions: [
    {
      // This address always fails on Polygon, give it a try :D
      to: "0x839eE023B21f4Ffe2294025DE0AC30Ba7278D6Fd",
      value: "0",
    },
  ],
});
 
if (isSentTransactionResponse(tx)) {
  // ... This will never be executed
} else {
  // tx can only be `SentTransactionResponse` or `FailedTransactionResponse`
  console.log(tx);
}
{
  "code": "transactionFailed",
  "data": {
    "error": "This is an error message",
    "request": {
      "code": "sendTransaction",
      "expires": 1699443005,
      "identifier": "ts-sdk-1699442705965-0x153824576D03629b264683B430bBF9AcEA1d0975",
      "issued": 1699442705,
      "network": "137",
      "transactions": [
        {
          "data": "0x",
          "to": "0x839eE023B21f4Ffe2294025DE0AC30Ba7278D6Fd",
          "type": "transaction",
          "value": "0x00"
        }
      ],
      "wallet": "0x4d4EE1b8583e31fe789eAF2e1b6e011C220c10B6"
    },
    "simulations": [
      {
        "executed": true,
        "gasLimit": 7908,
        "gasUsed": 5931,
        "reason": "This is an error message :)",
        "result": null,
        "succeeded": false
      }
    ]
  }
}