-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathevm_rpc.did
311 lines (310 loc) · 8.91 KB
/
evm_rpc.did
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
type Block = record {
miner : text;
totalDifficulty : opt nat;
receiptsRoot : text;
stateRoot : text;
hash : text;
difficulty : opt nat;
size : nat;
uncles : vec text;
baseFeePerGas : opt nat;
extraData : text;
transactionsRoot : opt text;
sha3Uncles : text;
nonce : nat;
number : nat;
timestamp : nat;
transactions : vec text;
gasLimit : nat;
logsBloom : text;
parentHash : text;
gasUsed : nat;
mixHash : text;
};
type BlockTag = variant {
Earliest;
Safe;
Finalized;
Latest;
Number : nat;
Pending;
};
type EthMainnetService = variant {
Alchemy;
Ankr;
BlockPi;
Cloudflare;
PublicNode;
Llama;
};
type EthSepoliaService = variant {
Alchemy;
Ankr;
BlockPi;
PublicNode;
Sepolia;
};
type L2MainnetService = variant {
Alchemy;
Ankr;
BlockPi;
PublicNode;
Llama;
};
type FeeHistory = record {
reward : vec vec nat;
gasUsedRatio : vec float64;
oldestBlock : nat;
baseFeePerGas : vec nat;
};
type FeeHistoryArgs = record {
blockCount : nat;
newestBlock : BlockTag;
rewardPercentiles : opt vec nat8;
};
type GetLogsArgs = record {
fromBlock : opt BlockTag;
toBlock : opt BlockTag;
addresses : vec text;
topics : opt vec Topic;
};
type GetTransactionCountArgs = record { address : text; block : BlockTag };
type CallArgs = record {
transaction : TransactionRequest;
block : opt BlockTag;
};
type TransactionRequest = record {
"type" : opt text;
nonce : opt nat;
to : opt text;
from : opt text;
gas : opt nat;
value : opt nat;
input : opt text;
gasPrice : opt nat;
maxPriorityFeePerGas : opt nat;
maxFeePerGas : opt nat;
maxFeePerBlobGas : opt nat;
accessList: opt vec AccessListEntry;
blobVersionedHashes : opt vec text;
blobs : opt vec text;
chainId : opt nat;
};
type AccessListEntry = record {
address : text;
storageKeys : vec text;
};
type HttpHeader = record { value : text; name : text };
type HttpOutcallError = variant {
IcError : record { code : RejectionCode; message : text };
InvalidHttpJsonRpcResponse : record {
status : nat16;
body : text;
parsingError : opt text;
};
};
type InstallArgs = record {
demo : opt bool;
manageApiKeys : opt vec principal;
logFilter : opt LogFilter;
overrideProvider : opt OverrideProvider;
nodesInSubnet : opt nat32;
};
type Regex = text;
type LogFilter = variant {
ShowAll;
HideAll;
ShowPattern : Regex;
HidePattern : Regex;
};
type RegexSubstitution = record {
pattern : Regex;
replacement: text;
};
// Override resolved provider.
// Useful for testing with a local Ethereum developer environment such as foundry.
type OverrideProvider = record {
overrideUrl : opt RegexSubstitution
};
type JsonRpcError = record { code : int64; message : text };
type LogEntry = record {
transactionHash : opt text;
blockNumber : opt nat;
data : text;
blockHash : opt text;
transactionIndex : opt nat;
topics : vec text;
address : text;
logIndex : opt nat;
removed : bool;
};
type Metrics = record {
requests : vec record { record { text; text }; nat64 };
responses : vec record { record { text; text; text }; nat64 };
inconsistentResponses : vec record { record { text; text }; nat64 };
cyclesCharged : vec record { record { text; text }; nat };
errHttpOutcall : vec record { record { text; text; RejectionCode }; nat64 };
};
type MultiFeeHistoryResult = variant {
Consistent : FeeHistoryResult;
Inconsistent : vec record { RpcService; FeeHistoryResult };
};
type MultiGetBlockByNumberResult = variant {
Consistent : GetBlockByNumberResult;
Inconsistent : vec record { RpcService; GetBlockByNumberResult };
};
type MultiGetLogsResult = variant {
Consistent : GetLogsResult;
Inconsistent : vec record { RpcService; GetLogsResult };
};
type MultiGetTransactionCountResult = variant {
Consistent : GetTransactionCountResult;
Inconsistent : vec record { RpcService; GetTransactionCountResult };
};
type MultiGetTransactionReceiptResult = variant {
Consistent : GetTransactionReceiptResult;
Inconsistent : vec record { RpcService; GetTransactionReceiptResult };
};
type MultiSendRawTransactionResult = variant {
Consistent : SendRawTransactionResult;
Inconsistent : vec record { RpcService; SendRawTransactionResult };
};
type MultiCallResult = variant {
Consistent : CallResult;
Inconsistent : vec record { RpcService; CallResult };
};
type ProviderError = variant {
TooFewCycles : record { expected : nat; received : nat };
MissingRequiredProvider;
ProviderNotFound;
NoPermission;
InvalidRpcConfig : text ;
};
type ProviderId = nat64;
type ChainId = nat64;
type Provider = record {
providerId : ProviderId;
chainId : ChainId;
access : RpcAccess;
alias : opt RpcService;
};
type RpcAccess = variant {
Authenticated : record {
auth : RpcAuth;
publicUrl : opt text;
};
Unauthenticated : record {
publicUrl : text;
};
};
type RpcAuth = variant {
BearerToken : record { url : text };
UrlParameter : record { urlPattern : text };
};
type RejectionCode = variant {
NoError;
CanisterError;
SysTransient;
DestinationInvalid;
Unknown;
SysFatal;
CanisterReject;
};
type FeeHistoryResult = variant { Ok : FeeHistory; Err : RpcError };
type GetBlockByNumberResult = variant { Ok : Block; Err : RpcError };
type GetLogsResult = variant { Ok : vec LogEntry; Err : RpcError };
type GetTransactionCountResult = variant { Ok : nat; Err : RpcError };
type GetTransactionReceiptResult = variant {
Ok : opt TransactionReceipt;
Err : RpcError;
};
type SendRawTransactionResult = variant {
Ok : SendRawTransactionStatus;
Err : RpcError;
};
type CallResult = variant { Ok : text; Err : RpcError };
type RequestResult = variant { Ok : text; Err : RpcError };
type RequestCostResult = variant { Ok : nat; Err : RpcError };
type RpcConfig = record { responseSizeEstimate : opt nat64; responseConsensus : opt ConsensusStrategy };
type ConsensusStrategy = variant {
Equality;
Threshold : record {
// Total number of providers to be queried. Can be omitted, if that number can be inferred (e.g., providers are specified in the request).
total : opt nat8;
// Minimum number of providers that must return the same (non-error) result.
min : nat8;
};
};
type RpcError = variant {
JsonRpcError : JsonRpcError;
ProviderError : ProviderError;
ValidationError : ValidationError;
HttpOutcallError : HttpOutcallError;
};
type RpcApi = record { url : text; headers : opt vec HttpHeader };
type RpcService = variant {
Provider : ProviderId;
Custom : RpcApi;
EthSepolia : EthSepoliaService;
EthMainnet : EthMainnetService;
ArbitrumOne : L2MainnetService;
BaseMainnet : L2MainnetService;
OptimismMainnet : L2MainnetService;
};
type RpcServices = variant {
Custom : record {
chainId : ChainId;
services : vec RpcApi;
};
EthSepolia : opt vec EthSepoliaService;
EthMainnet : opt vec EthMainnetService;
ArbitrumOne : opt vec L2MainnetService;
BaseMainnet : opt vec L2MainnetService;
OptimismMainnet : opt vec L2MainnetService;
};
type SendRawTransactionStatus = variant {
Ok : opt text;
NonceTooLow;
NonceTooHigh;
InsufficientFunds;
};
// Each topic is a `vec text` of topic data composed with the "or" operator.
// See https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs
type Topic = vec text;
type TransactionReceipt = record {
to : opt text;
status : opt nat;
transactionHash : text;
blockNumber : nat;
from : text;
logs : vec LogEntry;
blockHash : text;
"type" : text;
transactionIndex : nat;
effectiveGasPrice : nat;
logsBloom : text;
contractAddress : opt text;
gasUsed : nat;
};
type ValidationError = variant {
Custom : text;
InvalidHex : text;
};
service : (InstallArgs) -> {
eth_feeHistory : (RpcServices, opt RpcConfig, FeeHistoryArgs) -> (MultiFeeHistoryResult);
eth_getBlockByNumber : (RpcServices, opt RpcConfig, BlockTag) -> (MultiGetBlockByNumberResult);
eth_getLogs : (RpcServices, opt RpcConfig, GetLogsArgs) -> (MultiGetLogsResult);
eth_getTransactionCount : (RpcServices, opt RpcConfig, GetTransactionCountArgs) -> (MultiGetTransactionCountResult);
eth_getTransactionReceipt : (RpcServices, opt RpcConfig, hash : text) -> (MultiGetTransactionReceiptResult);
eth_sendRawTransaction : (RpcServices, opt RpcConfig, rawSignedTransactionHex : text) -> (MultiSendRawTransactionResult);
eth_call : (RpcServices, opt RpcConfig, CallArgs) -> (MultiCallResult);
request : (RpcService, json : text, maxResponseBytes : nat64) -> (RequestResult);
requestCost : (RpcService, json : text, maxResponseBytes : nat64) -> (RequestCostResult) query;
// DEBUG endpoint to retrieve metrics accumulated by the EVM RPC canister.
// NOTE: this method exists for debugging purposes, backward compatibility is not guaranteed.
getMetrics : () -> (Metrics) query;
getNodesInSubnet : () -> (numberOfNodes : nat32) query;
getProviders : () -> (vec Provider) query;
getServiceProviderMap : () -> (vec record { RpcService; ProviderId }) query;
updateApiKeys : (vec record { ProviderId; opt text }) -> ();
};