diff --git a/contract_interface.md b/contract_interface.md index 06e3e672..d1a320a5 100644 --- a/contract_interface.md +++ b/contract_interface.md @@ -10,6 +10,21 @@ Every contract must be stored in the [WebAssembly Binary Encoding](https://githu A contract can only import symbols specified in the [Ethereum Environment Interface](./eth_interface.md). +As mentioned below, there is a `debug` namespace as well, but that is disallowed in production systems. + +#### Debug-mode + +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: +- `print32(value: i32)` - print value +- `print64(value: i64)` - print value +- `printMem(offset: i32, len: i32)` - print memory segment as printable characters +- `printMemHex(offset: i32, len: i32)` - print memory segment as hex +- `printStorage(pathOffset: i32)` - print storage value as printable characters +- `printStorageHex(pathOffset: i32)` - print storage value as hex + ### Exports A contract must have exactly two exported symbols: @@ -23,13 +38,3 @@ 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 - -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 number -- `printMem(i32 offset, i32 length)`: print a string as pointed by `offset` -- `printMemHex(i32 offset, i32 length)`: print a hex representation of the memory pointed to by `offset`