Passer au contenu principal

Batch Operations

This endpoint supports batch operations, allowing you to estimate network fees for multiple contract operations from a specific child address in a single API call.

Batch Request Format

To estimate fees for multiple operations, use the calls array:
{
  "calls": [
    {
      "address": "0xTokenContract...",
      "method": "approve",
      "parameters": ["0xSpender...", "1000000000000000000"],
      "abi": [...]
    },
    {
      "address": "0xProtocolContract...",
      "method": "deposit",
      "parameters": ["1000000000000000000"],
      "abi": [...]
    }
  ]
}

Batch Response Format

Returns individual fees plus totals:
{
  "message": "Batch network fee retrieved (2/2 successful)",
  "statusCode": 200,
  "data": {
    "fees": [
      {
        "index": 0,
        "method": "approve",
        "fee": "0.00001247904",
        "networkFee": "0.00001247904",
        "networkFeeInUSD": "0.01",
        "nativeBalance": "0.5",
        "nativeBalanceInUSD": "450.00",
        "estimatedArrivalTime": 30,
        "transactionFee": "0"
      },
      {
        "index": 1,
        "method": "deposit",
        "fee": "0.00000504",
        "networkFee": "0.00000504",
        "networkFeeInUSD": "0.005",
        "nativeBalance": "0.5",
        "nativeBalanceInUSD": "450.00",
        "estimatedArrivalTime": 30,
        "transactionFee": "0"
      }
    ],
    "totalFee": "0.00001751904",
    "estimatedArrivalTime": 60,
    "errors": []
  }
}

Response Fields

FieldDescription
feesArray of individual fee estimates
totalFeeSum of all network fees
estimatedArrivalTimeTotal time (sum of individual times, 30s each)
errorsArray of any failed estimations

Validation Rules

RuleValue
Max batch size20 operations
Min batch size1 operation

Use Cases

  • Fee estimation: Calculate total cost before executing batch operations
  • Gas optimization: Compare fees across different operation orderings
  • Budget planning: Estimate costs for multi-step DeFi transactions