{"uid":"cap_m7U6fr0GL7eAoQE8R4Ln6","slug":"portals-foresight-defi-batch-transaction-simulation-api-c391e6d7","name":"Portals Foresight — DeFi Batch Transaction Simulation API","description":"Simulate multi-step DeFi flows (approve+swap, deposit+borrow) with shared state. Validate entire strategies before committing on-chain.","url":"https://foresight.portals.fi/v1/simulate/batch?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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":["sender","steps"],"properties":{"steps":{"type":"array","items":{"type":"object","required":["tx"],"properties":{"tx":{"type":"object","required":["from","to","data","value"],"properties":{"to":{"type":"string"},"data":{"type":"string"},"from":{"type":"string"},"value":{"type":"string"}}},"inputToken":{"type":"string","description":"Address of the input token for this step"},"inputAmount":{"type":"string","description":"Input amount in token base units for this step"}}},"description":"Ordered list of transaction steps to simulate sequentially"},"sender":{"type":"string","description":"Address of the sender executing all steps"},"recipient":{"type":"string","description":"Optional recipient address"}}},"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"}}}}},"responseSchema":{"type":"json","example":{"steps":[{"gasUsed":"46109","success":true,"stepIndex":0},{"gasUsed":"152847","success":true,"stepIndex":1}],"success":true,"aggregate":{"gasCost":"5968680000000000","gasUsed":"198956","success":true,"inputTokens":[{"token":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","amount":"100000000","standard":"erc20"}],"assetChanges":[{"token":"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","amount":"100000000","standard":"erc20","direction":"sent"},{"token":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","amount":"32450000000000000","standard":"erc20","direction":"received"}],"outputTokens":[{"token":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","amount":"32450000000000000","standard":"erc20"}],"tokenMetadata":{"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48":{"name":"USD Coin","symbol":"USDC","decimals":6},"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2":{"name":"Wrapped Ether","symbol":"WETH","decimals":18}}}}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.005","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"settled","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.005/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.005","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_T7s8UDauirXJGnO7ql3_Z","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.005","costPer":"request","priority":0,"asset":null,"unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Simulate multi-step DeFi transaction sequences (e.g. approve+swap, deposit+borrow) with shared state to validate entire strategies before executing on-chain.","exampleAgentPrompt":"Before I execute this on-chain, simulate the two-step DeFi flow where I first approve and then swap 100 USDC (0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, amount 100000000) to WETH from my wallet 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 — use Portals Foresight to validate both steps together and show me the expected asset changes and total gas cost.","exampleUseCases":null,"resultDescription":"Returns per-step results (success flag, gas used, step index) plus an aggregate summary including total gas used, gas cost in wei, input tokens, output tokens, all asset changes with direction (sent/received), and token metadata (name, symbol, decimals) for each token involved.","failureModes":["One or more steps fail simulation — success=false returned per step or at aggregate level","Invalid or malformed contract address or calldata returns a 400 error","Unsupported chain or token address not recognized","Input amount exceeds simulated balance — step fails with revert","customEvents array exceeds 10 entries — only first 10 are decoded","Payment authorization failure via x402 — call not executed"],"whenToPreferThis":"Use this endpoint when you need to validate a sequence of dependent DeFi operations (e.g. approve→swap, deposit→borrow) as a single atomic simulation with shared state, rather than simulating each transaction independently. It is ideal when you need to see aggregate asset changes and gas costs across the full strategy before committing funds on-chain.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-13T00:32:45.687Z","isFirstParty":false,"canonicalSlug":"portals-foresight-defi-batch-transaction-simulation-api-c391e6d7"}