Skip to content

Commit f34fdea

Browse files
authored
Merge pull request #29 from ethereum/ewasm-contract
Add eWASM Contract Interface specification
2 parents f818e4a + 27eaf1b commit f34fdea

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

README.md

Lines changed: 2 additions & 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)
@@ -49,6 +49,7 @@ eWASM:
4949
* [FAQ](./faq.md)
5050
* [Rationale](./rationale.md)
5151
* [Ethereum environment interface](./eth_interface.md)
52+
* [eWASM Contract Interface](./contract_interface.md)
5253
* [Original Proposal](https://github.com/ethereum/EIPs/issues/48) (EIP#48)
5354
* [WebAssembly design documents](https://github.com/WebAssembly/design)
5455

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 exported symbols:
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+
symbols 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)