Pre-flight / preview
Transaction Preview is an extension of our Transaction 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:
Any EVM execution errors
A list of Decoded Internal Transactions
A collection of all balance changes of tokens across all involved addresses
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
How-to: Simulate Multiple Transactions
Endpoint Spec
POST
https://api.blocknative.com/simulate
Use this endpoint to simulate multiple transactions before you submit it, allowing you to preview its effects! Include the appropriate blockchain and network, for which supported networks are listed below. Include your API key and it's associated secret key in a "credentials" header via the formatting "apiKey:secretKey". Your secret key can be set via your Accounts page where your keys are listed.
Note: You will need to either include gasPrice or maxFeePerGas and maxPriorityFeePerGas to differentiate between a type 0 and type 2 (EIP1559) transaction, for more information check out our blog post here. We recommend using type 2 transactions.
Headers
Name | Type | Description |
---|---|---|
credentials* | String | Here we define an API key and secret key together in the form "apiKey:secretKey" |
Request Body
Name | Type | Description |
---|---|---|
system* | String | Blockchain of this transaction, currently we only support |
network* | String | Network name of this transaction, currently we support
|
transactons* | Array of JSON objects | This is an array of your transaction objects, information about this structure can be found here, however below we describe what is required. |
transactions[0].to* | String | An address from which the transaction would be sent from. |
transactions[0].from* | String | An address to where the transaction is sent to. |
transactions[0].value* | Integer | This is the amount of ETH transferred, if there is none transferred, leave this field as ”value”: 0. This field is in wei units. |
transactions[0].input* | String | This is the input arguments, encoded per the contract specifications. you can find some information detailing this field. |
transactions[0].gas* | Integer | Maximum amount of gas available to the transaction. |
transactions[0].gasPrice | Integer | (Type 0) Amount, in wei, per unit of gas. |
transactions[0].maxFeePerGas | Integer | (Type 2) Max fee per gas in wei. |
transactions[0].maxPriorityFeePerGas | Integer | (Type 2) Max priority fee per gas in wei. |
Example: Multiple unsigned simulations cURL call
How-to: Websocket Endpoint
wss://api.blocknative.com/v0
Example websocket call
JSON Response Fields
Name | Type | Description |
---|---|---|
| [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. |
| [JSON object] | Contains details of all the balance changes resulting from the internal transactions details in the |
| 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. |
| [JSON object] | This is the top level contract call decoded. If we do not support decoding for this contract, this field will be null. |
| Number | Gas used during transaction execution. |
Supported Networks
Transaction Preview currently supports Ethereum Mainnet and Sepolia Testnet. 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.
Last updated