Skip to content

Commit 2453de7

Browse files
committed
Add eWASM Contract Interface
1 parent f818e4a commit 2453de7

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A few key points:
2121
eWASM is a restricted subset of WASM to be used for contracts in Ethereum.
2222

2323
eWASM:
24-
* specifies the semantics for an *eWASM contract*
24+
* specifies the [semantics for an *eWASM contract*](./contract_interface.md)
2525
* specifies an [Ethereum environment interface](./eth_interface.md) to facilitate interaction with the Ethereum environment from an *eWASM contract*
2626
* specifies [metering](./metering.md) for instructions
2727
* and aims to restrict [non-deterministic behavior](https://github.com/WebAssembly/design/blob/master/Nondeterminism.md)

contract_interface.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# eWASM Contract Interface (ECI) Specification; Version 0
2+
3+
The eWASM Contract Interface (ECI) specifies the structure of a contract module.
4+
5+
### Wire format
6+
7+
Every contract must be stored in the [WebAssembly Binary Encoding](https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md) format (in short, WASM bytecode).
8+
9+
### Imports
10+
11+
A contract can only import symbols specified in the [Ethereum Environment Interface](./eth_interface.md).
12+
13+
### Exports
14+
15+
A contract must have exactly two exports:
16+
- `memory`: the shared memory space available for the EEI to write into.
17+
- `main`: a function with no parameters and no result value
18+
19+
### Entry point
20+
21+
The method exported as `main` will be executed by the VM.
22+
23+
### Debug-mode
24+
25+
Debug-mode is a special VM option, where an additional set of debugging interfaces are available to contracts. On a live VM, any bytecode trying to import these
26+
should be rejected.
27+
28+
The imports are available under the `debug` namespace:
29+
- `print(i32 offset, i32 length)`: print a string as pointed by `offset`
30+
- `printHex(i32 offset, i32 length)`: print a hex representation of the memory pointed to by `offset`

0 commit comments

Comments
 (0)