You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Ethereum Environment Interface exposes the core Ethereum API to the eWASM environment. The Ethereum [module](https://github.com/WebAssembly/design/blob/master/Modules.md) will be implemented in the Ethereum client's native language. All parameters and returns are restricted to 32 or 64 bit integers. Floats are disallowed.
4
4
5
-
## Environment
6
-
7
-
The Ethereum Environment Interface exposes the following information.
8
-
9
-
* gasCount - the current amount of gas used
10
-
* gas - The totally amount of gas that the contract instance has to use
11
-
* gasPrice - The price in wei paid for gas
12
-
* gasLimit - The max amount of gas that maybe expended
13
-
* address - The contract's address
14
-
* origin - The origin address of the message that caused this contract to run
15
-
* coinbase - The current block's coinbase
16
-
* difficulty - The current block's difficulty
17
-
* caller - The address that directly messaged this contract
18
-
* callValue - The value in wei of that the message has
19
-
* callData - The message's data
20
-
* code - The code of the current running contract
21
-
* logs - All the logs that the contract emitted
22
-
* state - Ethereum's state as stored in the state trie
23
-
24
-
Further more we define the following caps on the environmental variables
25
-
26
-
*`codesize` is capped to a 64 bit integer
27
-
*`calldata` size is capped to 64 bits
28
-
*`balances` are represented as a 128 bit little endian unsigned integer
29
-
*`gasPrice` is represented as a 64 bit little endian unsigned integer
30
-
*`gas` is represented as a 64 bit little endian unsigned integer
5
+
# Data types
6
+
7
+
We define the following Ethereum data types:
8
+
-`bytes`: an array of bytes with unrestricted length
9
+
-`address`: a 160 bit number, represented as a 20 bytes long little endian unsigned integer in memory
10
+
-`u128`: a 128 bit number, represented as a 16 bytes long little endian unsigned integer in memory
11
+
-`u256`: a 256 bit number, represented as a 32 bytes long little endian unsigned integer in memory
12
+
13
+
We also define the following WebAssembly data types:
14
+
-`i32`: same as `i32` in WebAssembly
15
+
-`i32ptr`: same as `i32` in WebAssembly, but treated as a pointer to a WebAssembly memory offset
16
+
-`i64`: same as `i64` in WebAssembly
31
17
32
18
# API
33
19
@@ -37,7 +23,7 @@ Subtracts an amount to the gas counter
37
23
38
24
**Parameters**
39
25
40
-
-`amount`**integer** the amount to subtract to the gas counter
26
+
-`amount`**i64** the amount to subtract to the gas counter
41
27
42
28
**Returns**
43
29
@@ -50,7 +36,7 @@ the given offset.
50
36
51
37
**Parameters**
52
38
53
-
-`resultOffset`**i32** the memory offset to load the address into
39
+
-`resultOffset`**i32ptr** the memory offset to load the address into (`address`)
54
40
55
41
**Returns**
56
42
@@ -63,8 +49,8 @@ offset.
63
49
64
50
**Parameters**
65
51
66
-
-`addressOffset`**i32** the memory offset to load the address from
67
-
-`resultOffset`**i32** the memory offset to load the balance into
52
+
-`addressOffset`**i32ptr** the memory offset to load the address from (`address`)
53
+
-`resultOffset`**i32ptr** the memory offset to load the balance into (`u128`)
68
54
69
55
**Returns**
70
56
@@ -76,8 +62,8 @@ Gets the hash of one of the 256 most recent complete blocks.
76
62
77
63
**Parameters**
78
64
79
-
-`number`**integer** which block to load
80
-
-`resultOffset`**i32** the memory offset to load the hash into
65
+
-`number`**i64** which block to load
66
+
-`resultOffset`**i32ptr** the memory offset to load the hash into (`u256`)
81
67
82
68
**Returns**
83
69
@@ -89,12 +75,12 @@ Sends a message with arbitrary date to a given address path
89
75
90
76
**Parameters**
91
77
92
-
-`gas`**integer** the gas limit
93
-
-`addressOffset`**i32** the memory offset to load the address from
94
-
-`valueOffset`**i32** the memory offset to load the value from
95
-
-`dataOffset`**i32** the memory offset to load data from
78
+
-`gas`**i64** the gas limit
79
+
-`addressOffset`**i32ptr** the memory offset to load the address from (`address`)
80
+
-`valueOffset`**i32ptr** the memory offset to load the value from (`u128`)
81
+
-`dataOffset`**i32ptr** the memory offset to load data from (`bytes`)
96
82
-`dataLength`**i32** the length of data
97
-
-`resultOffset`**i32** the memory offset to store the result data at
83
+
-`resultOffset`**i32ptr** the memory offset to store the result data at (`bytes`)
98
84
-`resultLength`**i32** the maximal length of result data
99
85
100
86
**Returns**
@@ -108,7 +94,7 @@ the input data passed with the message call instruction or transaction.
108
94
109
95
**Parameters**
110
96
111
-
-`resultOffset`**i32** the memory offset to load data into
97
+
-`resultOffset`**i32ptr** the memory offset to load data into (`bytes`)
112
98
-`dataOffset`**i32** the offset in the input data
113
99
-`length`**i32** the length of data to copy
114
100
@@ -127,20 +113,20 @@ data passed with the message call instruction or transaction.
127
113
128
114
**Returns**
129
115
130
-
`callDataSize`**integer**
116
+
`callDataSize`**i32**
131
117
132
118
## callCode
133
119
134
120
Message-call into this account with an alternative account's code.
135
121
136
122
**Parameters**
137
123
138
-
-`gas`**integer** the gas limit
139
-
-`addressOffset`**i32** the memory offset to load the address from
140
-
-`valueOffset`**i32** the memory offset to load the value from
141
-
-`dataOffset`**i32** the memory offset to load data from
124
+
-`gas`**i64** the gas limit
125
+
-`addressOffset`**i32ptr** the memory offset to load the address from (`address`)
126
+
-`valueOffset`**i32ptr** the memory offset to load the value from (`u128`)
127
+
-`dataOffset`**i32ptr** the memory offset to load data from (`bytes`)
142
128
-`dataLength`**i32** the length of data
143
-
-`resultOffset`**i32** the memory offset to store the result data at
129
+
-`resultOffset`**i32ptr** the memory offset to store the result data at (`bytes`)
144
130
-`resultLength`**i32** the maximal length of result data
145
131
146
132
**Returns**
@@ -154,36 +140,38 @@ persisting the current values for sender and value.
154
140
155
141
**Parameters**
156
142
157
-
-`gas`**integer** the gas limit
158
-
-`addressOffset`**i32** the memory offset to load the address from
159
-
-`dataOffset`**i32** the memory offset to load data from
143
+
-`gas`**i64** the gas limit
144
+
-`addressOffset`**i32ptr** the memory offset to load the address from (`address`)
145
+
-`dataOffset`**i32ptr** the memory offset to load data from (`bytes`)
160
146
-`dataLength`**i32** the length of data
161
-
-`resultOffset`**i32** the memory offset to store the result data at
147
+
-`resultOffset`**i32ptr** the memory offset to store the result data at (`bytes`)
162
148
-`resultLength`**i32** the maximal length of result data
163
149
164
150
**Returns**
165
151
166
152
`result`**i32** Returns 1 or 0 depending on if the VM trapped on the message or not
167
153
168
154
## storageStore
155
+
169
156
Store 256-bit a value in memory to persistent storage
170
157
171
158
**Parameters**
172
159
173
-
-`pathOffest`**i32** the memory offset to load the path from
174
-
-`valueOffset`**i32** the memory offset to load the value from
160
+
-`pathOffest`**i32ptr** the memory offset to load the path from (`u256`)
161
+
-`valueOffset`**i32ptr** the memory offset to load the value from (`u256`)
175
162
176
163
**Returns**
177
164
178
165
*nothing*
179
166
180
167
## storageLoad
168
+
181
169
Loads a 256-bit a value to memory from persistent storage
182
170
183
171
**Parameters**
184
172
185
-
-`pathOffest`**i32** the memory offset to load the path from
186
-
-`resultOffset`**i32** the memory offset to store the result at
173
+
-`pathOffest`**i32ptr** the memory offset to load the path from (`u256`)
174
+
-`resultOffset`**i32ptr** the memory offset to store the result at (`u256`)
187
175
188
176
**Returns**
189
177
@@ -196,7 +184,7 @@ the address of the account that is directly responsible for this execution.
196
184
197
185
**Parameters**
198
186
199
-
-`resultOffset`**i32** the memory offset to load the address into
187
+
-`resultOffset`**i32ptr** the memory offset to load the address into (`address`)
200
188
201
189
**Returns**
202
190
@@ -209,7 +197,7 @@ this execution and loads it into memory at the given location.
209
197
210
198
**Parameters**
211
199
212
-
-`resultOffset`**i32** the memory offset to load the value into
200
+
-`resultOffset`**i32ptr** the memory offset to load the value into (`u128`)
213
201
214
202
**Returns**
215
203
@@ -221,7 +209,7 @@ Copies the code running in current environment to memory.
221
209
222
210
**Parameters**
223
211
224
-
-`resultOffset`**i32** the memory offset to load the result into
212
+
-`resultOffset`**i32ptr** the memory offset to load the result into (`bytes`)
225
213
-`codeOffset`**i32** the offset within the code
226
214
-`length`**i32** the length of code to copy
227
215
@@ -247,7 +235,7 @@ Gets the block’s beneficiary address and loads into memory.
247
235
248
236
**Parameters**
249
237
250
-
-`resultOffset`**i32** the memory offset to load the coinbase address into
238
+
-`resultOffset`**i32ptr** the memory offset to load the coinbase address into (`address`)
251
239
252
240
**Returns**
253
241
@@ -259,34 +247,35 @@ Creates a new contract with a given value.
259
247
260
248
**Parameters**
261
249
262
-
-`valueOffset`**i32** the memory offset to load the value from
263
-
-`dataOffset`**i32** the memory offset to load the code for the new contract from
250
+
-`valueOffset`**i32ptr** the memory offset to load the value from (`u128`)
251
+
-`dataOffset`**i32ptr** the memory offset to load the code for the new contract from (`bytes`)
264
252
-`length`**i32** the data length
253
+
-`resultOffset`**i32ptr** the memory offset to write the new contract address to (`address`)
265
254
266
255
**Returns**
267
256
268
-
*nothing*
257
+
`result`**i32** Returns 1 or 0 depending on if the VM trapped on the message or not
269
258
270
259
## getBlockDifficulty
271
260
272
261
Get the block’s difficulty.
273
262
274
263
**Parameters**
275
264
276
-
*none*
265
+
-`offset`**i32ptr** the memory offset to load the difficulty into (`u256`)
277
266
278
267
**Returns**
279
268
280
-
`difficulty`**integer**
269
+
*nothing*
281
270
282
271
## externalCodeCopy
283
272
284
273
Copies the code of an account to memory.
285
274
286
275
**Parameters**
287
276
288
-
-`addressOffset`**i32** the memory offset to load the address from
289
-
-`resultOffset`**i32** the memory offset to load the result into
277
+
-`addressOffset`**i32ptr** the memory offset to load the address from (`address`)
278
+
-`resultOffset`**i32ptr** the memory offset to load the result into (`bytes`)
290
279
-`codeOffset`**i32** the offset within the code
291
280
-`length`**i32** the length of code to copy
292
281
@@ -300,7 +289,7 @@ Get size of an account’s code.
300
289
301
290
**Parameters**
302
291
303
-
-`addressOffset`**i32** the memory offset to load the address from
292
+
-`addressOffset`**i32ptr** the memory offset to load the address from (`address`)
304
293
305
294
**Returns**
306
295
@@ -316,7 +305,7 @@ Returns the current gasCounter
316
305
317
306
**Returns**
318
307
319
-
`gasLeft`**integer**
308
+
`gasLeft`**i64**
320
309
321
310
## getBlockGasLimit
322
311
@@ -328,33 +317,33 @@ Get the block’s gas limit.
328
317
329
318
**Returns**
330
319
331
-
`blockGasLimit`**integer**
320
+
`blockGasLimit`**i64**
332
321
333
322
## getTxGasPrice
334
323
335
324
Gets price of gas in current environment.
336
325
337
326
**Parameters**
338
327
339
-
*none*
328
+
-`valueOffset`**i32ptr** the memory offset to write the value to (`u128`)
340
329
341
330
**Returns**
342
331
343
-
`gasPrice`**integer**
332
+
*nothing*
344
333
345
334
## log
346
335
347
336
Creates a new log in the current environment
348
337
349
338
**Parameters**
350
339
351
-
-`dataOffset`**i32** the memory offset to load data from
340
+
-`dataOffset`**i32ptr** the memory offset to load data from (`bytes`)
352
341
-`length`**i32** the data length
353
-
-`topic1`**integer**
354
-
-`topic2`**integer**
355
-
-`topic3`**integer**
356
-
-`topic4`**integer**
357
-
-`topic5`**integer**
342
+
-`numberOfTopics`**i32** the number of topics following (0 to 4)
343
+
-`topic1`**i32ptr** the memory offset to load topic1 from (`u256`)
344
+
-`topic2`**i32ptr** the memory offset to load topic2 from (`u256`)
345
+
-`topic3`**i32ptr** the memory offset to load topic3 from (`u256`)
346
+
-`topic4`**i32ptr** the memory offset to load topic4 from (`u256`)
358
347
359
348
**Returns**
360
349
@@ -370,7 +359,7 @@ Get the block’s number.
370
359
371
360
**Returns**
372
361
373
-
`blockNumber`**integer**
362
+
`blockNumber`**i64**
374
363
375
364
## getTxOrigin
376
365
@@ -380,7 +369,7 @@ account with non-empty associated code.
380
369
381
370
**Parameters**
382
371
383
-
-`resultOffset`**i32** the memory offset to load the origin address from
372
+
-`resultOffset`**i32ptr** the memory offset to load the origin address from (`address`)
384
373
385
374
**Returns**
386
375
@@ -392,7 +381,7 @@ Halt execution returning output data.
392
381
393
382
**Parameters**
394
383
395
-
-`dataOffset`**i32** the memory offset of the output data
384
+
-`dataOffset`**i32ptr** the memory offset of the output data (`bytes`)
396
385
-`length`**i32** the length of the output data
397
386
398
387
**Returns**
@@ -406,7 +395,7 @@ balance to an address path
406
395
407
396
**Parameters**
408
397
409
-
-`addressOffset`**i32** the memory offset to load the address from
398
+
-`addressOffset`**i32ptr** the memory offset to load the address from (`address`)
0 commit comments