-
Notifications
You must be signed in to change notification settings - Fork 89
feat: add tutorial for - writing your first smart contract #545 #547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: add tutorial for - writing your first smart contract #545 #547
Conversation
Daanvdplas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! Thank you very much for your contribution!
One comment I have: once a link is added in text I would like it to make things more clear. now the links often reference official rust docs but I'm not always of the opinion that is beginner friendly. As an alternative, some links can be added at the end of a section for optional further reading, this to keep the flow of the actual section light and easy.
I left some other small comments for you take a look at but other than that it looks good to go!
|
|
||
| There are two ways to follow along with this tutorial! | ||
|
|
||
| ### GitHub Codespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a little difficult for beginners?
| - Install [Brew](https://brew.sh/) | ||
| - Install [Rust](https://rust-lang.org/tools/install/), [Cargo](https://doc.rust-lang.org/cargo/) | ||
| and [Pop CLI](https://github.com/r0gue-io/pop-cli) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All those steps are included here: https://learn.onpop.io/contracts/welcome/install-pop-cli
We should make it easier to install pop-cli
| Read up on the [Pop CLI](https://learn.onpop.io/) | ||
| ::: | ||
|
|
||
| ### Verify Installation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just verify pop
| - Pass in `contract` to the command `pop new` | ||
| - We name the contract`helloink` | ||
| - Lastly, we use the [Standard Template](https://github.com/use-ink/ink-examples/tree/main/flipper), | ||
| passing in `-t standard` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed if we use the interactive mode
| passing in `-t standard` |
| ```bash | ||
| pop new contract helloink -t standard | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the full command if they don't want interactive mode, maybe we should make that clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw there is also a question whether they want a frontend or not now, we should specify that they can click no
| _Let's review each major component of the `lib.rs` file:_ | ||
|
|
||
| ### Conditional Compilation Statement | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ```rust | |
| #![cfg_attr(not(feature = "std"), no_std, no_main)] |
| **lib.rs** (excerpt) | ||
|
|
||
| ```rust | ||
| #![cfg_attr(not(feature = "std"), no_std, no_main)] | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| **lib.rs** (excerpt) | |
| ```rust | |
| #![cfg_attr(not(feature = "std"), no_std, no_main)] | |
| ``` |
| Applies the `#[ink(constructor)]` macro to the `new()` function declaration. | ||
|
|
||
| - Marks the function as the **ink!** constructor | ||
| - Makes function available to the API for instantiating the contract |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps explain what instantiating is?
| ## Deploy to Local Ink Node | ||
|
|
||
| Now, let's use [Pop to deploy our contract](https://learn.onpop.io/contracts/guides/deploy) to | ||
| a [local ink node](https://github.com/use-ink/ink-node). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much info:
| a [local ink node](https://github.com/use-ink/ink-node). | |
| a local ink node. |
| - `--path` points to the contract directory | ||
| - `--constructor` method name (defaults to `new`) | ||
| - `--args` constructor arguments | ||
| - `--suri` secret key URI (default to `//Alice`) | ||
| - `--url` ink node url (default `ws://localhost:9944`) | ||
|
|
||
| ```bash | ||
| pop up --path . \ | ||
| --constructor new \ | ||
| --args true \ | ||
| --suri //Alice \ | ||
| --url ws://localhost:9944 | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just run pop up -w which uses a wallet integration, or pop up --suri //Alice
Point I'm trying to make, let them discover pop interactive mode :)
Related Issue:
fixes #545
Title:
Writing Your First Smart Contract
Description:
Walk through hand-on instructions to create a
fully functional ink! smart contract.
Attached companion GitHub template repo helloink.
Explain key concepts:
Learning Objectives:
Local Testing Steps
pnpm start