Comments (4)
Quick introduction about myself: I previously worked at Berty, a distributed secure messenger, where I played a lot with IPFS
and its underlying network library libp2p
. I've been working with Golang for around 5 years, especially on mobile. Apart maybe from the original Bitcoin paper, I currently have little to zero knowledge of the blockchain ecosystem.
Week 1: ressources, setup and challenge
Gather Resources:
- GNO Official Repo: gno
- Curated List of GNO Resources: awesome-gno
- Awesome GNO Tutorials: tutorials
- GNO By Example: website
- Getting Started Boards: README
- Getting Started Repository: getting-started
- Cool and Usefull Videos About GNO:
First Week Challenge:
-
Set up a local dev environment without blockchain (gno cli)
- Setup Editor:
- I'm using Emacs, and since there is no GNO mode yet, I created gno-mode, based on
go-mode
. Inspired by the VSCode extension, I will move this to a dedicated repo later.
- I'm using Emacs, and since there is no GNO mode yet, I created gno-mode, based on
- Install GNO from GitHub:
- I usually manage all my projects the old Golang way (with
[org]/[name]
), so I'm cloninggno
into~/code/gnoland/gno
and executing a simplemake
to install thegno
andgnokey
binaries.
- I usually manage all my projects the old Golang way (with
- Getting Started:
- Following the getting started page, I generated my first private key and saved the address and mnemonic into my password manager for quick access.
- Checking my key with
gnokey list
: success. - The next step is to add some tokens to my address using the faucet on https://test3.gno.land/faucet. Well, not a success; as I'm writing these lines, this faucet seems to be down. I had to use https://staging.gno.land/faucet, which is reset every hour.
- Note: Even on staging, I still have some random issues (like unauthorized error); I had to send my request multiple times to make it work.
- Using
gnokey query auth/accounts/<myaddr>
, I can now see my token balance (targeting https://staging.gno.land). - The next step is to create a Board using the
gnokey maketx call
on the https://staging.gno.land/r/demo/boards realm using theCreateBoard
method (located in public.gno). Unfortunately, it wasn't successful, and it ended with anunauthorized
error. - I haven't tried every call of every realm, but
CreateThread
was the only call that worked for me, using the default board (bid:1).- Maybe instructions are outdated on the
getting started
page? I have already corrected some links, so I won't be surprised if some calls haven't been updated for a while. - I had to remove
true
from-broadcast true
to make the examples work. - The
-send
argument should already be filled, at least for the getting started instructions. - The automatically generated
help
andsource
pages are totally awesome and super useful.
- Maybe instructions are outdated on the
- Improvement Ideas:
- Besides correcting outdated information, a cool idea would be something similar to
org-babel
but with Markdown, extracting all snippets as single or multiple independent bash block(s) and executing against a local chain for continuous testing. - As a new user, it can be really frustrating to encounter some issues on a getting started page, especially with little knowledge of the project, as it's hard to determine if the problem comes from you or the given instructions.
- Besides correcting outdated information, a cool idea would be something similar to
- Setup Editor:
-
Set up a local dev environment with blockchain (gnoland + gnoweb + gnokey)
- The process is not really different from the previous exercise; the only difference is that instead of communicating with an already running remote instance, we use a local instance.
- For this, I had to install some other tools located inside
gno/gno.land
, using themake build
command to build all the remaining required tools (gnoland
,gnoweb
). - Then, simply running those two tools in two separate shell instances enabled me to access the testnet on https://localhost:8888 (with the web UI).
- I was unable to make the faucet work locally, but I was able to edit the genesis file located at
gno.land/genesis/genesis_balances
to add my key address and set my starting balance to an arbitrary amount.- I had to remove the gnoland
data
folder and restart the node to make the change take effect.
- I had to remove the gnoland
- Ultimately, I ended up with the same result as the previous exercise.
-
Writing contracts
-
Exploring Existing Contracts
- Before writing my own smart contracts, I delved into the existing set of smart contracts from example directory in the main repo to see how things work, playing around with the
gno
binary, which is very similar to thego
binary. I was able to run the whole set of GNO file tests.- It appears that running every
_test
file ended up with apanic: package ./gnovm/stdlibs/bufio already exists in cache
.
- It appears that running every
- I also encountered some issues running tests outside the
gno
main repo; for example, this test located in the getting started repository wasn't working from scratch for me. The test was unable to find thestd
library, and it took me some time to realize that I was missing theroot-dir
argument. Looking at the code to find out how guessing the root dir works took me here, where basically the root dir is guessed by reading an uppergo.mod
file usinggo mod list
to findgno
location; doing ago mod download
should have fixed my issue. I ended up making a small pull request addingGNOROOT
as an environment variable so it can be set globally. - Besides that, gnovm seems to work fine with most existing Golang syntax, and looks really handy to write.
- Before writing my own smart contracts, I delved into the existing set of smart contracts from example directory in the main repo to see how things work, playing around with the
-
Hello World
- For my first contact, I wrote down a simple contract with a basic counter state that can be incremented with an
Incr
method and rendered with theRender
method. I believe this is perhaps the most straightforward example you can create using the state feature of GNO:
var counter int func Incr() { counter += 1 } func Render(string) string { b := new(strings.Builder) b.WriteString("# gfanton's Realm\n\n") b.WriteString(ufmt.Sprintf("### this is my super gfanton counter: %d\n", counter)) return b.String() }
- I then published it on my local node using
gnokey maketx addpkg -pkgpath "gno.land/r/gui/gfrealm"
: success. I can now access it at: http://localhost:8888/r/gui/gfrealm and increase my counter calling theIncr
withgnokey maketx call -func "Incr"
- Later on, you quickly realize that if you want to make some updates to your contract, it's impossible for now. If you really want to make some changes, you will need to publish it with a new pkgpath:
gno.land/r/gui/gfrealm2
. While it can make sense that you can't update your contract on a chain, it left me confused about how to manage things. I ended up versioning my pkg by publishing successively ongno.land/r/gui/gfrealmX
(where X is my version), whether or not that makes sense.
- For my first contact, I wrote down a simple contract with a basic counter state that can be incremented with an
-
Subscription
-
My next challenge was to continue working on a
Subscriptions
contract from this PR: gnolang/gno#1025 -
The first thing that caught me off guard when writing a larger contract is that without a linter, debugging becomes quite challenging. You have to do a lot of back and forth to guess the type or name of the method you want to call from the standard library. Essentially, you write down your contract and then repeatedly run
go test .
to fix the errors one by one. This was so frustrating to me that I decided to take thegno test
run process part and put it inside thegno lint
command (which appears to be a work in progress) so I could integrate it into my editor to have real-time errors. This also enabled me to dig a bit deeper into the GNO code to see how things work. For the curious, here is the small change I made to make this works. It's a bit ugly and far from perfect, as it seems to only work on testing packages for now, but it's far enough for me to work under satisfactory conditions.- While digging into the code, I was a little confused by the large number of
panic
calls, especially in the lower-level parts of the codebase (for example, inpreprocess.go
). From my own personal experience, I feel this is unusual in Go, but it's not necessarily wrong; it just took me a while to handle it "properly" on the linter side, as I'm not used to handling errors this way.
- While digging into the code, I was a little confused by the large number of
-
TO CONTINUE ...
-
-
from hackerspace.
Welcome, Cosmonaut! 🚀 Feel right at home in this new environment, where your past experiences pave the way for exciting possibilities. 🌌 Enjoy the voyage!
from hackerspace.
https://gist.github.com/gfanton/6e233656dfeabd7a46f21f7507b6b311 -> Awesome-gno, please!
from hackerspace.
@gfanton, would you like to include a conclusion to wrap up and archive this onboarding journey? We can refer to awesome-gno for guidance if needed.
from hackerspace.
Related Issues (20)
- Chain activity visualizer HOT 3
- Gno code coverage and plan improve it. HOT 4
- Reentrancy
- Gno Account Abstraction HOT 3
- Zone01 - Student Program Journey HOT 27
- Utilize `gno get` Command and Create Gno Package Center
- Onbloc x Gno Core Workshop
- WorxDAO Design HOT 1
- Zentasktic Builder Journey HOT 1
- Digital Audio Workstation
- Proposal for support Fully Onchain Games (FOCG) HOT 1
- Scalability of avl.Tree and Gas Limit R&D Findings & Recommendations from the dSocial Grant
- PoC Innovation - Student Program Journey HOT 11
- Testnet 4 Validator Initiative Discussion HOT 2
- Adapting Go security tools to the Gno ecosystem HOT 1
- Gno incubator with security audit grant
- Proposal: Developing Gno Name Service (GNS) HOT 1
- `pkg.gno.dev` - a gno package registry HOT 4
- `gnocrux` - a threshold TM2 signer
- META - Gno Live Coding Sessions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hackerspace.