From 3ae125698916236625a608d0f68152761f5753a8 Mon Sep 17 00:00:00 2001 From: Jacques Wagener Date: Mon, 6 May 2019 21:25:35 +0200 Subject: [PATCH] Add hello and build.sh --- build.sh | 14 ++++++++++++++ eth_contracts.nimble | 1 + examples/hello.nim | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100755 build.sh create mode 100644 examples/hello.nim diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..0a5140c --- /dev/null +++ b/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash +export WASM_LLVM_BIN="./llvm-wasm/bin/" + +function print_contract () { + wasm_file=$1 + echo "${wasm_file} eWASM bytecode:" + echo "0x"`xxd -p $wasm_file | tr -d '\n'` +} + +nimble examples + +if [ $? -eq 0 ]; then + print_contract examples/hello.wasm +fi diff --git a/eth_contracts.nimble b/eth_contracts.nimble index d868d15..2a38210 100644 --- a/eth_contracts.nimble +++ b/eth_contracts.nimble @@ -15,3 +15,4 @@ proc buildExample(name: string) = task examples, "Build examples": buildExample("wrc20") buildExample("wrc202") + buildExample("hello") diff --git a/examples/hello.nim b/examples/hello.nim new file mode 100644 index 0000000..b432664 --- /dev/null +++ b/examples/hello.nim @@ -0,0 +1,36 @@ +import ../eth_contracts + +proc hello(): int64 = + return 1234567 + +proc main() {.exportwasm.} = + var res: int64 = 1234567 + finish(addr res, sizeof(res).int32) + + +discard """ +[ + { + "name": "hello", + "outputs": [ + { + "type": "int64", + "name": "out" + } + ], + "inputs": [ + { + "type": "int64", + "name": "a" + }, + { + "type": "int64", + "name": "b" + } + ], + "constant": false, + "payable": false, + "type": "function", + } +] +"""