The eWASM Contract Interface (ECI) specifies the structure of a contract module.
Every contract must be stored in the WebAssembly Binary Encoding format (in short, WASM bytecode).
The WASM bytecode must be prefixed with an invalid EVM1 opcode (0xEF).
A contract can only import symbols specified in the Ethereum Environment Interface.
A contract must have exactly two exported symbols:
memory: the shared memory space available for the EEI to write into.main: a function with no parameters and no result value.
The method exported as main will be executed by the VM.
On successful execution, the code should return via a normal code path.
If it needs to abort due to a failure, an unreachable instruction should be executed.
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 symbols should be rejected.
The imports are available under the debug namespace:
print(i64): print a numberprintMem(i32 offset, i32 length): print a string as pointed byoffsetprintMemHex(i32 offset, i32 length): print a hex representation of the memory pointed to byoffset