mirror of https://github.com/status-im/nimplay.git
Add hello and build.sh
This commit is contained in:
parent
9f3f2dc525
commit
3ae1256989
|
@ -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
|
|
@ -15,3 +15,4 @@ proc buildExample(name: string) =
|
|||
task examples, "Build examples":
|
||||
buildExample("wrc20")
|
||||
buildExample("wrc202")
|
||||
buildExample("hello")
|
||||
|
|
|
@ -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",
|
||||
}
|
||||
]
|
||||
"""
|
Loading…
Reference in New Issue