Registering Errors on Smart Contract Calls

Since we cannot determine if a gas estimation fails on the integrator's side—particularly when called from the integrator's smart contract—we provide an endpoint to register errors that occur during on-chain calls. This information is highly valuable to us for maintaining service quality, allowing us to analyze and review failed trades (e.g., tokens involved, DEX used, and other relevant details).

Endpoint: POST /api/register-error

This endpoint allows clients to register errors that occur during smart contract calls when conducting a trade. The provided information can include various transaction-related details, though all fields are optional.


Request

  • Method: POST

  • Content-Type: application/json

Request Body Parameters

Field
Type
Description

input_data

string

(Optional) The raw input data of the transaction.

value

string

(Optional) The value of the transaction in wei (smallest unit of the native token).

sender

string

(Optional) The address of the sender initiating the transaction (0x...).

to_address

string

(Optional) The address to which the transaction is sent (0x...).

api_key

string

(Optional) The API key for authentication and tracking.

chain_id

number

(Optional) The ID of the blockchain network where the transaction was conducted.

block_number

number

(Optional) The block number where the transaction was attempted.

transaction_hash

string

(Optional) The hash of the transaction (0x...).


Response

Successful Response

  • HTTP Status: 200 OK

  • Response Body:

    {
      "status": "success",
      "message": "Error registered successfully."
    }

Error Response

  • HTTP Status: 400 Bad Request

  • Response Body (example):

    {
      "status": "error",
      "message": "Invalid request body."
    }

Example Request

Request Body

{
  "input_data": "0xa9059cbb000000000000000000000000d8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  "value": "1000000000000000000",
  "sender": "0xAbcd1234Ef567890abcd1234Ef567890Abcd1234",
  "to_address": "0xDefg5678Gh901234defg5678Gh901234Defg5678",
  "api_key": "my-secret-api-key",
  "chain_id": 1,
  "block_number": 12345678,
  "transaction_hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
}

Response

jsonCopiar código{
  "status": "success",
  "message": "Error registered successfully."
}

Notes

  1. Optional Fields: All fields in the request are optional; the backend should handle missing fields gracefully.

  2. Error Logging: This endpoint is used to collect transaction details when an error occurs, providing valuable insights for debugging and analytics.

  3. Authentication: If the api-key is required for security, ensure it is validated against your system.

  4. Chain-Specific Handling: The chainId should correspond to the appropriate blockchain network (e.g., Ethereum Mainnet = 1).

This documentation entry provides clear guidelines for developers to use the POST /api/register-error endpoint effectively.

Last updated

Was this helpful?