merkle
Ask or search…
K

Guide

In order to simulate bundles, first you need an API key, sign up on the Merkle Blockchain Services and grab an API key from the Keys page.
post
https://api.merkle.io/v1
/simulate
Simulate a bundle of calls

Request examples:

Re-simulate a swap without the wrapping sandwich to understand the impact. Let's take this transaction for example.

{
"chainId": 1,
"calls": [
{
"from": "0x3b42a0ed9050A79d8F35B07021272B3ef073266A",
"to": "0x881D40237659C251811CEC9c364ef91dC08D300C",
"data": "0x5f5755290000000000000000000000000000000000000000000000000000000000000080000000000000000000000000b2617246d0c6c0087f18703d576831899ca94f0100000000000000000000000000000000000000000000152d02c7e14af680000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000136f6e65496e6368563546656544796e616d6963000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000b2617246d0c6c0087f18703d576831899ca94f01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000152d02c7e14af68000000000000000000000000000000000000000000000000000001464a6568a138eed0000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000002f063f978aab00000000000000000000000000f326e4de8f66a0bdc0970b79e0924e33c79f1915000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c80502b1c5000000000000000000000000b2617246d0c6c0087f18703d576831899ca94f0100000000000000000000000000000000000000000000152d02c7e14af68000000000000000000000000000000000000000000000000000001492bbd24caad01b0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000140000000000000003b6d0340b36ec83d844c0579ec2493f10b2087e96bb65460ab4991fe00000000000000000000000000000000000000000000000000a0"
}
],
"blockNumber": 19078685
}
Response:
{
"chainId": 1,
"blockNumber": "0x1231e1d",
"processTime": 246,
"calls": [
{
"logs": [
{
"address": "0xb2617246d0c6c0087f18703d576831899ca94f01",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000003b42a0ed9050a79d8f35b07021272b3ef073266a",
"0x00000000000000000000000074de5d4fcbf63e00296fd95d33236b9794016631"
],
"data": "0x00000000000000000000000000000000000000000000152d02c7e14af6800000"
},
{
"address": "0xb2617246d0c6c0087f18703d576831899ca94f01",
"topics": [
"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
"0x0000000000000000000000003b42a0ed9050a79d8f35b07021272b3ef073266a",
"0x000000000000000000000000881d40237659c251811cec9c364ef91dc08d300c"
],
"data": "0xffffffffffffffffffffffffffffffffffffffffffff419e36568544b173efff"
},
{
"address": "0xb2617246d0c6c0087f18703d576831899ca94f01",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x00000000000000000000000074de5d4fcbf63e00296fd95d33236b9794016631",
"0x000000000000000000000000b36ec83d844c0579ec2493f10b2087e96bb65460"
],
"data": "0x00000000000000000000000000000000000000000000152d02c7e14af6800000"
},
{
"address": "0xb2617246d0c6c0087f18703d576831899ca94f01",
"topics": [
"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
"0x00000000000000000000000074de5d4fcbf63e00296fd95d33236b9794016631",
"0x0000000000000000000000001111111254eeb25477b68fb85ed929f73a960582"
],
"data": "0xffffffffffffffffffffffffffffffffffffffffffedda9b1acfa1ddded9990a"
},
{
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000b36ec83d844c0579ec2493f10b2087e96bb65460",
"0x0000000000000000000000001111111254eeb25477b68fb85ed929f73a960582"
],
"data": "0x00000000000000000000000000000000000000000000000014fe37d15de7c4ae"
},
{
"address": "0xb36ec83d844c0579ec2493f10b2087e96bb65460",
"topics": [
"0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1"
],
"data": "0x0000000000000000000000000000000000000000000903660c63774976aeb38e000000000000000000000000000000000000000000000008e14f01ad7087435a"
},
{
"address": "0xb36ec83d844c0579ec2493f10b2087e96bb65460",
"topics": [
"0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822",
"0x0000000000000000000000001111111254eeb25477b68fb85ed929f73a960582",
"0x0000000000000000000000001111111254eeb25477b68fb85ed929f73a960582"
],
"data": "0x00000000000000000000000000000000000000000000152d02c7e14af68000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014fe37d15de7c4ae"
},
{
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"topics": [
"0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65",
"0x0000000000000000000000001111111254eeb25477b68fb85ed929f73a960582"
],
"data": "0x00000000000000000000000000000000000000000000000014fe37d15de7c4ae"
},
{
"address": "0xf326e4de8f66a0bdc0970b79e0924e33c79f1915",
"topics": [
"0x3d0ce9bfc3ed7d6862dbb28b2dea94561fe714a1b4d019aa8af39730d1ad7c3d",
"0x00000000000000000000000074de5d4fcbf63e00296fd95d33236b9794016631"
],
"data": "0x000000000000000000000000000000000000000000000000002f063f978aab00"
},
{
"address": "0x881d40237659c251811cec9c364ef91dc08d300c",
"topics": [
"0xbeee1e6e7fe307ddcf84b0a16137a4430ad5e2480fc4f4a8e250ab56ccd7630d",
"0xf35f348d53012d52a5d39f9390d246956ac932d5778d2bb49e359dba4fa0896d",
"0x0000000000000000000000003b42a0ed9050a79d8f35b07021272b3ef073266a"
],
"data": "0x"
}
],
"gasUsed": "0x38646",
"result": "",
"status": 1,
"internalTransfers": [
{
"from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"to": "0x1111111254eeb25477b68fb85ed929f73a960582",
"amount": "0x14fe37d15de7c4ae"
},
{
"from": "0x1111111254eeb25477b68fb85ed929f73a960582",
"to": "0x74de5d4fcbf63e00296fd95d33236b9794016631",
"amount": "0x14fe37d15de7c4ae"
},
{
"from": "0x74de5d4fcbf63e00296fd95d33236b9794016631",
"to": "0xf326e4de8f66a0bdc0970b79e0924e33c79f1915",
"amount": "0x2f063f978aab00"
},
{
"from": "0x74de5d4fcbf63e00296fd95d33236b9794016631",
"to": "0x3b42a0ed9050a79d8f35b07021272b3ef073266a",
"amount": "0x14cf3191c65d19ae"
}
]
}
]
}

Overrides

Using the example above, let's apply some overrides:
{
"chainId": 1,
"calls": [
{
"from": "0x3b42a0ed9050A79d8F35B07021272B3ef073266A",
"to": "0x881D40237659C251811CEC9c364ef91dC08D300C",
"nonce": 1,
"data": "0x5f5755290000000000000000000000000000000000000000000000000000000000000080000000000000000000000000b2617246d0c6c0087f18703d576831899ca94f0100000000000000000000000000000000000000000000152d02c7e14af680000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000136f6e65496e6368563546656544796e616d6963000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000b2617246d0c6c0087f18703d576831899ca94f01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000152d02c7e14af68000000000000000000000000000000000000000000000000000001464a6568a138eed0000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000002f063f978aab00000000000000000000000000f326e4de8f66a0bdc0970b79e0924e33c79f1915000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000c80502b1c5000000000000000000000000b2617246d0c6c0087f18703d576831899ca94f0100000000000000000000000000000000000000000000152d02c7e14af68000000000000000000000000000000000000000000000000000001492bbd24caad01b0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000140000000000000003b6d0340b36ec83d844c0579ec2493f10b2087e96bb65460ab4991fe00000000000000000000000000000000000000000000000000a0"
}
],
"overrides": {
// account nonces and balances can be overwritten
"accounts": {
"0x3b42a0ed9050A79d8F35B07021272B3ef073266A": {
"nonce": 0,
"balance": 0,
}
},
// contract codes can be overwritten
"contractCodes": {
"0x881D40237659C251811CEC9c364ef91dC08D300C": "0x....."
},
// storage slots can be overwritten
"storage": {
"0x881D40237659C251811CEC9c364ef91dC08D300C": {
"0x0000000000000000000000000000000000000001": "0x...."
}
}
}
"blockNumber": 19078685
}
Response:
{
"error": true,
"name": "Error",
"message": "Nonce mismatch. Expected 0, got 1 on call #0",
"details": null
}