Skip to content

Commit 962b724

Browse files
authored
Merge pull request #483 from AlvaroLuken/al/add-eth-simulatev1-endpoint
add eth_simulateV1 endpoint
2 parents 2ddcf96 + 173d8cd commit 962b724

File tree

5 files changed

+304
-15
lines changed

5 files changed

+304
-15
lines changed

.github/workflows/sync-apis.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,12 @@ jobs:
600600
working-directory: ./ethereum
601601
run: rdme openapi eth_getTransactionByBlockNumberAndIndex.yaml --key=$README_API_KEY --id=62d85761c50d8b00730dc6ce
602602

603+
- name: Update Ethereum API - eth_simulateV1
604+
env:
605+
README_API_KEY: ${{ secrets.README_API_KEY }}
606+
working-directory: ./ethereum
607+
run: rdme openapi eth_simulateV1.yaml --key=$README_API_KEY --id=67f44614304e6c004147ece2
608+
603609
# Update Polygon PoS APIs
604610
- name: Update Polygon PoS API - eth_createAccessList
605611
env:

ethereum/eth_simulateV1.yaml

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
openapi: 3.1.0
2+
info:
3+
title: eth simulate V1 - Ethereum
4+
description: Ethereum API method that enables simulation of complex transactions and state changes without modifying the blockchain. This method is particularly useful for testing and debugging smart contracts, estimating gas costs, and analyzing the potential outcomes of transactions before committing them to the network.
5+
version: '1.0'
6+
servers:
7+
- url: 'https://{network}.g.alchemy.com/v2/'
8+
variables:
9+
network:
10+
enum:
11+
- eth-mainnet
12+
- eth-sepolia
13+
- eth-hoodi
14+
- eth-holesky
15+
- base-mainnet
16+
- base-sepolia
17+
default: eth-mainnet
18+
x-sandbox:
19+
category:
20+
type:
21+
$ref: '../components/sandbox.yaml#/Category'
22+
value: core
23+
paths:
24+
/{apiKey}:
25+
$ref: '#/components/pathItems/path'
26+
components:
27+
pathItems:
28+
path:
29+
post:
30+
operationId: eth_simulateV1
31+
summary: eth_simulateV1 - Ethereum
32+
description: Enables simulation of complex transactions and state changes without modifying the blockchain.
33+
parameters:
34+
- name: apiKey
35+
in: path
36+
schema:
37+
type: string
38+
default: docs-demo
39+
description: |
40+
<style>
41+
.custom-style {
42+
color: #048FF4;
43+
}
44+
</style>
45+
For higher throughput, <span class="custom-style"><a href="https://alchemy.com/?a=docs-demo" target="_blank">create your own API key</a></span>
46+
required: true
47+
requestBody:
48+
description: Accepts the transaction call object, state overrides and the block number / block hash / block tag to execute the call on.
49+
content:
50+
application/json:
51+
schema:
52+
$ref: ../evm_body.yaml#/eth_simulateV1
53+
x-readme:
54+
explorer-enabled: false
55+
samples-languages:
56+
- curl
57+
- javascript
58+
- python
59+
code-samples:
60+
- language: javascript
61+
name: eth_simulateV1
62+
code: |
63+
const request = {
64+
method: "eth_simulateV1",
65+
params: [
66+
{
67+
object: {
68+
blockOverrides: {
69+
baseFeePerGas: "0x2540be400",
70+
},
71+
stateOverrides: {
72+
"0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41": {
73+
balance: "0xde0b6b3a7640000",
74+
},
75+
},
76+
calls: [
77+
{
78+
from: "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
79+
to: "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
80+
maxFeePerGas: "0x9184e72a000",
81+
value: "0x0",
82+
},
83+
],
84+
validation: true,
85+
traceTransfers: false,
86+
},
87+
quantity: "latest",
88+
},
89+
{
90+
object: {
91+
blockOverrides: {
92+
baseFeePerGas: "0x1dcd6500",
93+
},
94+
calls: [
95+
{
96+
from: "0xcccccccccccccccccccccccccccccccccccccccc",
97+
to: "0xdddddddddddddddddddddddddddddddddddddddd",
98+
value: "0x2386f26fc10000",
99+
},
100+
],
101+
validation: false,
102+
traceTransfers: false,
103+
},
104+
quantity: "pending",
105+
},
106+
],
107+
};
108+
109+
console.log(request);
110+
- language: python
111+
code: "from web3 import Web3, HTTPProvider\r\n\r\n#Replace with your Alchemy API key:\r\napiKey = \"demo\"\r\n\r\n# Initialize a Web3.py instance\r\nweb3 = Web3(Web3.HTTPProvider('https://eth-mainnet.g.alchemy.com/v2 /'+apiKey))\r\n\r\n# Query the blockchain (replace example parameters)\r\ndata = web3.eth.call({\r\n\t\t'value': 0, \r\n\t\t'gas': 21736, \r\n\t\t'maxFeePerGas': 2000000000, \r\n\t\t'maxPriorityFeePerGas': 1000000000, \r\n\t\t'to': '0xc305c90',\r\n\t\t'data': '0x477a5c98'\r\n\t\t}) \r\n\r\n# Print the output to console\r\nprint(data)"
112+
name: web3.py
113+
responses:
114+
'200':
115+
description: The result of the call.
116+
content:
117+
application/json:
118+
schema:
119+
$ref: ../evm_responses.yaml#/eth_simulateV1

0 commit comments

Comments
 (0)