Getting Started
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).
Build gnokey
, create your account, and interact with Gno.
NOTE: Where you see --remote localhost:26657
here, that flag can be replaced
with --remote localhost:26657
for local testnets.
Build gnokey
.
1git clone git@github.com:gnolang/gno.git
2cd ./gno
3make
Generate a seed/mnemonic code.
1./build/gnokey generate
NOTE: You can generate 24 words with any good bip39 generator.
Create a new account using your mnemonic.
1./build/gnokey add KEYNAME --recover
NOTE: KEYNAME
is your key identifier, and should be changed.
Verify that you can see your account locally.
1./build/gnokey list
Interact with the blockchain:
Get your current balance, account number, and sequence number.
1./build/gnokey query auth/accounts/ACCOUNT_ADDR --remote localhost:26657
NOTE: you can retrieve your ACCOUNT_ADDR
with ./build/gnokey list
.
Acquire testnet tokens using the official faucet.
Go to https://gno.land/faucet
Create a board with a smart contract call.
NOTE: BOARDNAME
will be the slug of the board, and should be changed.
1./build/gnokey maketx call KEYNAME --pkgpath "gno.land/r/demo/boards" --func "CreateBoard" --args "BOARDNAME" --gas-fee "1000000ugnot" --gas-wanted "2000000" --broadcast=true --chainid portal-loop --remote localhost:26657
Interactive documentation: https://gno.land/r/demo/boards$help&func=CreateBoard
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(\"BOARDNAME\")" --remote localhost:26657
Create a post of a board with a smart contract call.
NOTE: If a board was created successfully, your SEQUENCE_NUMBER would have increased.
1./build/gnokey maketx call KEYNAME --pkgpath "gno.land/r/demo/boards" --func "CreateThread" --args BOARD_ID --args "Hello gno.land" --args\#file "./examples/gno.land/r/demo/boards/example_post.md" --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast=true --chainid portal-loop --remote localhost:26657
Interactive documentation: https://gno.land/r/demo/boards$help&func=CreateThread
Create a comment to a post.
1./build/gnokey maketx call KEYNAME --pkgpath "gno.land/r/demo/boards" --func "CreateReply" --args "BOARD_ID" --args "1" --args "1" --args "Nice to meet you too." --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast=true --chainid portal-loop --remote localhost:26657
Interactive documentation: https://gno.land/r/demo/boards$help&func=CreateReply
1./build/gnokey query "vm/qrender" --data "gno.land/r/demo/boards:BOARDNAME/1" --remote localhost:26657
Render page with optional path expression.
The contents of https://gno.land/r/demo/boards:
and https://gno.land/r/demo/boards:gnolang
are rendered by calling
the Render(path string)
function like so:
1./build/gnokey query "vm/qrender" --data "gno.land/r/demo/boards:gnolang"
Starting a local gnoland
node:
Add test account.
1./build/gnokey add test1 --recover
Use this mneonic:
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
node.
1./build/gnoland
NOTE: This can be reset with make reset
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 100000000ugnot --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast=true --chainid portal-loop --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 100000000ugnot --gas-fee 1000000ugnot --gas-wanted 300000000 --broadcast=true --chainid portal-loop --remote localhost:26657
- @moul, 2024-12-21 12:51am (UTC) [reply] [repost] [x]