Transaction Preview API

Transaction Preview is an extension of our Simulation Platform for on-demand simulations of unsigned transactions against the current block height.

Overview

Transaction Preview lets you preview the outputs of any custom transactions that you submit to it. By harnessing the power of our network of Ethereum nodes, with our existing decoding and transaction lifecycle knowledge, we hope to give users of Transaction Preview even greater comfort when interacting in the Web3 space. Previewing a transaction is particularly useful for:
  • Wallets: Help users preview net-balance changes & identify malicious contract behavior or buggy smart contracts before interacting with them.
  • DEXs & Swaps: Report accurate slippage, Accurate tokens received, and accurate failing calls
  • Traders: Preview many iterations of the same trade and execute only the most profitable one
  • Lending Protocols: Tell whether a Borrow / Repay / Claim transaction will go through
  • Auctions: Tell whether your bid or listing will go through and its accuracy & effects
  • NFTs: Tell whether your NFT mint, purchase, or transfer will go through
& much more without spending a single wei in gas!

How it works

Transaction Preview comes in the form of both REST and Websocket endpoints, to which you can outline the basics of a single or multiple transactions, and you will receive a payload detailing the execution of the transactions in the latest block height. We simulate the proposed transactions by executing it on one of our dedicated simulator nodes on the current block height. The returned payload includes:
  1. 1.
    Any EVM execution errors
  2. 2.
    A list of Decoded Internal Transactions
  3. 3.
    A collection of all balance changes of tokens across all involved addresses
  4. 4.
    End to end performance metrics of the simulation

Authentication

Include the header credentials with your apiKey:secretKey. Information on secret keys can be found here and here.

Quick Start: Example single sim cURL call

cURL Request
🖥
Response
🎉

How-to: Simulate Multiple Transactions

post
https://api.blocknative.com
/simulate
Endpoint Spec

Example: Multiple unsigned simulations cURL call

cURL Request
🖥
Response
🎉

How-to: Websocket Endpoint

wss://api.blocknative.com/v0

Example websocket call

ws.send(JSON.stringify({
"timeStamp": new Date().toISOString(),
"dappId": <API KEY>,
"version": "1",
"blockchain": {
"system": "ethereum",
"network": "main"
},
"categoryCode": "simulate",
"eventCode": "txSimulation",
"transaction": {
"from": "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B",
"to": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d",
"gas": 332160,
"gasPrice": 0,
"input": "0xfb3bdb4100000000000000000000000000000000000000000000003635c9adc5dea000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000746dff22206ce4e3da6d7eb4d537398be8f236d600000000000000000000000000000000000000000000000000000000624FD77D0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000094d916873b22c9c1b53695f1c002f78537b9b3b2",
"value": 28981678599856503
}
}))

JSON Response Fields

Name
Type
Description
internalTransactions
[JSON object]
A collection of internal transactions made by the activated contract. Supported calls are decoded. If you wish for your contract to be decoded, contact us on Discord.
netBalanceChanges
[JSON object]
Contains details of all the balance changes resulting from the internal transactions details in the internalTransactions array. The object is an array with an entry for each address involved in the internal transactions.
simDetails
JSON object
This object contains details about the simulation, such as blockHeight at the time of calculation, key action timestamps, and end-to-end latency value, in milliseconds.
contractCall
[JSON object]
This is the top level contract call decoded. If we do not support decoding for this contract, this field will be null.
gasUsed
Number
Gas used during transaction execution.

Supported Networks

Transaction Preview is currently only supported for Ethereum: Main. Please stay tuned for its availability on other networks supported by Blocknative.

Rate Limits

Usage rate limit for the Transaction Preview API is 100 requests per 60-second window. Transaction Preview consumes the same daily limits on your Blocknative plan as pending simulated transactions in Simulation Platform. You can view your current consumption on your Blocknative Account Page.