# Portals Foresight — DeFi Transaction Simulation API

> Portals Foresight — DeFi Transaction Simulation API is a paid API for AI agents from foresight.portals.fi, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-12).

Simulate any EVM transaction on 31+ chains to preview asset changes, gas costs, and DeFi outcomes without executing on-chain

## Facts

- Endpoint: POST https://foresight.portals.fi/v1/simulate?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-12
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/portals-foresight-defi-transaction-simulation-api-35def172
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_IT36RW9VEMXzWokpATJAw

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability portals-foresight-defi-transaction-simulation-api-35def172 -d '<json body>'
```

Example prompt: Before I actually submit this transaction, can you simulate it for me — I'm sending 1 ETH (1000000000000000000 wei) from 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 to 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 with calldata 0xd0e30db0, input token is native ETH (0x0000000000000000000000000000000000000000), and I want to see exactly what asset changes and gas costs I'd get without actually executing on-chain.

## When to prefer this

Use this endpoint when you need to dry-run any EVM transaction — especially DeFi operations like swaps, deposits, borrows, or wraps — and want to preview exact asset changes, output token amounts, and gas costs before committing on-chain. Prefer it over DEX quote APIs when you need verified simulation results across 31+ chains including full event decoding, or when you need to validate that a transaction will succeed without holding a balance or paying gas.

## Known failure modes

- Transaction reverts on simulation — success:false returned with revert reason
- Invalid or non-checksummed contract address — 400 bad request
- Unsupported chain — endpoint returns error for chains outside the 31+ supported
- Malformed calldata hex string — 400 validation error
- inputAmount as non-decimal string (e.g. hex) — parsing error
- Payment not included or insufficient — 402 payment required
- Rate limiting or Pro plan required for customEvents without x402 — 402/403 error

## How this service works

Simulate any EVM transaction on 31+ chains. Compare DEX quotes, validate DeFi deposits/borrows, preview swaps, and verify transfers — no gas or balance needed.

## Output

Returns a JSON object with: success flag, gas used and gas cost in wei, decoded events (e.g. wrap/swap), inputTokens and outputTokens with addresses/amounts/standards, assetChanges with direction (sent/received) for each token, sender address, and tokenMetadata (name, symbol, decimals) for all involved tokens.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "bodyType",
    "body",
    "method"
   ],
   "properties": {
    "body": {
     "required": [
      "tx",
      "inputToken",
      "inputAmount"
     ],
     "properties": {
      "tx": {
       "type": "object",
       "required": [
        "from",
        "to",
        "data",
        "value"
       ],
       "properties": {
        "to": {
         "type": "string",
         "description": "Target contract address"
        },
        "data": {
         "type": "string",
         "description": "Hex-encoded calldata"
        },
        "from": {
         "type": "string",
         "description": "Sender address"
        },
        "value": {
         "type": "string",
         "description": "Native token value in wei"
        }
       }
      },
      "recipient": {
       "type": "string",
       "description": "Optional recipient address (defaults to tx.from)"
      },
      "inputToken": {
       "type": "string",
       "description": "Address of the input token (0x0 for the chain native token)"
      },
      "inputAmount": {
       "type": "string",
       "description": "Input amount in token base units"
      }
     }
    },
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "POST"
     ],
     "type": "string"
    },
    "bodyType": {
     "enum": [
      "json",
      "form-data",
      "text"
     ],
     "type": "string"
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "events": [
   {
    "type": "wrap",
    "token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "amount": "1000000000000000000"
   }
  ],
  "sender": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  "gasCost": "838140000000000",
  "gasUsed": "27938",
  "success": true,
  "inputTokens": [
   {
    "token": "0x0000000000000000000000000000000000000000",
    "amount": "1000000000000000000",
    "standard": "native"
   }
  ],
  "assetChanges": [
   {
    "token": "0x0000000000000000000000000000000000000000",
    "amount": "1000000000000000000",
    "standard": "native",
    "direction": "sent"
   },
   {
    "token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "amount": "1000000000000000000",
    "standard": "erc20",
    "direction": "received"
   }
  ],
  "outputTokens": [
   {
    "token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    "amount": "1000000000000000000",
    "standard": "erc20"
   }
  ],
  "tokenMetadata": {
   "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": {
    "name": "Wrapped Ether",
    "symbol": "WETH",
    "decimals": 18
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/portals-foresight-defi-transaction-simulation-api-35def172/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from foresight.portals.fi](https://www.zero.xyz/host/foresight.portals.fi/llms.txt)
