Search Apps Documentation Source Content File Folder Download Copy

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 localhost:26657 here, that flag can be replaced with --remote localhost:26657 for local testnets.

build gnoland.

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

add test account.

1./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.

1./build/gnoland

(This can be reset with make reset).

start gnoland web server (optional).

1go run ./gnoland/website

Signing and broadcasting transactions.

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

1./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
2./build/gnokey query "auth/accounts/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5"
3./build/gnokey sign test1 --txpath addpkg.avl.unsigned.txt --chainid "portal-loop" --number 0 --sequence 0 > addpkg.avl.signed.txt
4./build/gnokey broadcast addpkg.avl.signed.txt --remote localhost:26657

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

1./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
2./build/gnokey sign test1 --txpath addpkg.boards.unsigned.txt --chainid "portal-loop" --number 0 --sequence 1 > addpkg.boards.signed.txt
3./build/gnokey broadcast addpkg.boards.signed.txt --remote localhost:26657

create a board with a smart contract call.

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

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

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

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

1./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
2./build/gnokey sign test1 --txpath createpost.unsigned.txt --chainid "portal-loop" --number 0 --sequence 3 > createpost.signed.txt
3./build/gnokey broadcast createpost.signed.txt --remote localhost:26657

create a comment to a post.

1./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
2./build/gnokey sign test1 --txpath createcomment.unsigned.txt --chainid "portal-loop" --number 0 --sequence 4 > createcomment.signed.txt
3./build/gnokey broadcast createcomment.signed.txt --remote localhost:26657
1./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:

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

- @administrator, 2024-12-21 12:51am (UTC) [reply] [repost] [x]

Hello ! - @moul, 2024-12-21 12:51am (UTC) [reply] [x]

hello1 - @test1, 2024-12-21 12:51am (UTC) [reply] [x]

hello2 - @test1, 2024-12-21 12:51am (UTC) [reply] [x]

hello2 - @test1, 2024-12-21 12:51am (UTC) [reply] [x]

coucou - @test1, 2024-12-21 12:51am (UTC) [reply] [x]

test provider - @test1, 2024-12-21 12:51am (UTC) [reply] [x]