gnØland

Hello World

This is a demo of Gno smart contract programming. This document was constructed by Gno onto a smart contract hosted on the data Realm name "gno.land/r/demo/boards" (github).

Starting the gnoland node node/validator.

NOTE: Where you see --remote test3.gno.land:36657 here, that flag can be replaced with --remote localhost:26657 for local testnets.

build gnoland.

git clone git@github.com:gnolang/gno.git cd ./gno make

add test account.

./build/gnokey add test1 --recover

Use this mnemonic:

source bonus chronic canvas draft south burst lottery vacant surface solve popular case indicate oppose farm nothing bullet exhibit title speed wink action roast

start gnoland validator node.

./build/gnoland

(This can be reset with make reset).

start gnoland web server (optional).

go run ./gnoland/website

Signing and broadcasting transactions.

publish the "gno.land/p/demo/avl" package.

./build/gnokey maketx addpkg test1 --pkgpath "gno.land/p/demo/avl" --pkgdir "examples/gno.land/p/demo/avl" --deposit 100ugnot --gas-fee 1ugnot --gas-wanted 2000000 > addpkg.avl.unsigned.txt ./build/gnokey query "auth/accounts/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5" ./build/gnokey sign test1 --txpath addpkg.avl.unsigned.txt --chainid "test3" --number 0 --sequence 0 > addpkg.avl.signed.txt ./build/gnokey broadcast addpkg.avl.signed.txt --remote test3.gno.land:36657

publish the "gno.land/r/demo/boards" realm package.

./build/gnokey maketx addpkg test1 --pkgpath "gno.land/r/demo/boards" --pkgdir "examples/gno.land/r/demo/boards" --deposit 100ugnot --gas-fee 1ugnot --gas-wanted 300000000 > addpkg.boards.unsigned.txt ./build/gnokey sign test1 --txpath addpkg.boards.unsigned.txt --chainid "test3" --number 0 --sequence 1 > addpkg.boards.signed.txt ./build/gnokey broadcast addpkg.boards.signed.txt --remote test3.gno.land:36657

create a board with a smart contract call.

./build/gnokey maketx call test1 --pkgpath "gno.land/r/demo/boards" --func CreateBoard --args "testboard" --gas-fee 1ugnot --gas-wanted 2000000 > createboard.unsigned.txt ./build/gnokey sign test1 --txpath createboard.unsigned.txt --chainid "test3" --number 0 --sequence 2 > createboard.signed.txt ./build/gnokey broadcast createboard.signed.txt --remote test3.gno.land:36657

Next, query for the permanent board ID by querying (you need this to create a new post):

./build/gnokey query "vm/qeval" --data "gno.land/r/demo/boards GetBoardIDFromName(\"testboard\")"

create a post of a board with a smart contract call.

./build/gnokey maketx call test1 --pkgpath "gno.land/r/demo/boards" --func CreatePost --args 1 --args "Hello World" --args#file "./examples/gno.land/r/demo/boards/README.md" --gas-fee 1ugnot --gas-wanted 2000000 > createpost.unsigned.txt ./build/gnokey sign test1 --txpath createpost.unsigned.txt --chainid "test3" --number 0 --sequence 3 > createpost.signed.txt ./build/gnokey broadcast createpost.signed.txt --remote test3.gno.land:36657

create a comment to a post.

./build/gnokey maketx call test1 --pkgpath "gno.land/r/demo/boards" --func CreateReply --args 1 --args 1 --args "A comment" --gas-fee 1ugnot --gas-wanted 2000000 > createcomment.unsigned.txt ./build/gnokey sign test1 --txpath createcomment.unsigned.txt --chainid "test3" --number 0 --sequence 4 > createcomment.signed.txt ./build/gnokey broadcast createcomment.signed.txt --remote test3.gno.land:36657
./build/gnokey query "vm/qrender" --data "gno.land/r/demo/boards testboard/1"

render page with optional path expression.

The contents of https://gno.land/r/demo/boards: and https://gno.land/r/demo/boards:testboard are rendered by calling the Render(path string) function like so:

./build/gnokey query "vm/qrender" --data "gno.land/r/demo/boards testboard"

- @administrator, 2023-08-18 11:44am (UTC) [reply] [x]