Skip to content
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

Astar Hacker Guide #256

Merged
merged 9 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/build/builder-guides/astar_features/use_hardhat.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ Happy Hacking!
## Reference

- Official Document for Hardhat: [https://hardhat.org/hardhat-runner/docs/getting-started#overview](https://hardhat.org/hardhat-runner/docs/getting-started#overview)
- Astar Document for Hardhat: [https://docs.astar.network/docs/EVM/developer-tooling/#hardhat](https://docs.astar.network/docs/EVM/developer-tooling/#hardhat)
- Astar Document for [Hardhat](/docs/build/EVM/developer-tooling/#hardhat)
4 changes: 4 additions & 0 deletions docs/build/builder-guides/hacking/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Astar Hacker Guide",
"position": 12
}
40 changes: 40 additions & 0 deletions docs/build/builder-guides/hacking/general.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
sidebar_position: 1
---

# General
![banner](../../assets/gradient5.jpg)

Please read the linked chapter and try to answer questions. If you cant find the answer, go to the [Astar Discord server](https://discord.com/invite/mWGt9bH59s) and ask the question in the general channel under the Developer Support category.

## Introduction
### Polkadot Relay [Chapter](/docs/build/introduction/polkadot_relay)
* What would be the most valuable features that a Relay Chain provides to all connected parachains?
* Is Kusama a parachain?
* Is Astar a parachain on the Polkadot Relay Chain?
* Does Astar use Substrate pallets as building blocks?
* What is the pallet/module name which enables execution of Wasm smart contracts in a Substrate node?


### Interact with the Node [Chapter](/docs/build/introduction/node_interact)
Connect to Astar Network using Polkadot-JS UI,
* How many blocks are produced by Astar Network so far?
* What it the value set for the constant called `blocksPerEra` in the `dappsStaking` pallet?

### Accounts [Chapter](/docs/build/introduction/create_account)
* Did you safely store key seed? How many seed words are used to create your key?
* Go to Subscan [Account Format Transfer](https://astar.subscan.io/tools/format_transform) tool and input your account to check what is the prefix number used on Astar and Shiden.
* Can you share your public key?
* Please note that you can use this account on Polkadot, Kusama and all parachains, but the address format will be different depending on the network prefix used. Connect to Polkadot and then to Astar Network on Polkadot-JS UI to observe the addresses change for same account.

### Astar Network Family [Chapter](/docs/build/introduction/astar_family)
* Is Shiden a parachain on Kusama Relay Chain?
* Is Shiden a parachain on Astar Relay Chain?
* Is Kusama a parachain on Polkadot?
* Using the native account you created in Accounts chapters, go to [Astar portal](https://portal.astar.network/), connect to Shibuya testnet and claim faucet tokens. You will later need these tokens to pay the gas fee and deploy contracts on Shibuya.
* Where can you sell SBY tokens? What is the value od SBY (Shibuya network token)?
* Can you test cross chain messaging with Zombienet?

## Setup Your Environment
### RPC Endpoints [Chapter](/docs/build/environment/endpoints.md)
* Check RPC address which you will use to connect front-end to your smart contract on Shibuya network.
33 changes: 33 additions & 0 deletions docs/build/builder-guides/hacking/hack_evm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
sidebar_position: 3
---
import CustomNet from './img/custom_net.png'
import Zombie from './img/zombie.png'

# Hack EVM Smart Contracts
![banner](../../assets/gradient2.jpg)

Read the linked chapters or use tutorials to be able to answer following questions:

## Setup MetaMask and Remix
* Did you install and connect your MetaMask to Shibuya? Which `Chain Id` did you use to setup Shibuya Network in MetaMask?
* Connect to browser IDE Remix using this [tutorial](/docs/build/builder-guides/astar_features/use_remix)
* Does your environment look like this:
<img src={CustomNet} style={{width: 400}} />

* Can you say what does `Custom (81) network` mean?
* Deploy and test smart contract from Remix tutorial.
* What is the contract's address?
* Can you find ABI for the contract?

## Start using Solidity
<img src={Zombie} style={{width: 100}} />

Since it's inception, Solidity has become mainstream language for smart contract development. There are many good tutorials to start learning Solidity and one of the popular places is [Crypto Zombies](https://cryptozombies.io/).

## Setup Hardhat and Truffle
The Truffle and Hardhat are preferred tools to develop, deploy and test smart contract. For this guide we will pick Hardhat.
Setup your Hardhat environment using [How to use Hardhat to deploy on Shibuya](/docs/build/builder-guides/astar_features/use_hardhat).


What is [next](/docs/build/builder-guides/hacking/next)?
40 changes: 40 additions & 0 deletions docs/build/builder-guides/hacking/hack_wasm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
sidebar_position: 2
---

# Hack Wasm Smart Contracts
![banner](../../assets/gradient4.jpg)

Read the linked chapters or use tutorials to be able to answer following questions:

## Setup ink! Environment [Chapter](/docs/build/environment/ink_environment.md)

* Which cargo version are you using?
* Run `rustup show` command.
* Run `cargo contract -V`. Is your cargo contract version higher than 1.5.0?
* Which rust toolchain do you need to use to be able to compile ink! smart contrats? (nightly or stable)? How do you manage this choice?

## Test Tokens [Chapter](/docs/build/environment/faucet.md)
* Did you claim Shibuya tokens? How many SBY tokens did the faucet provide to you?
* Can you unit test ink! smart contract without running test node like Swanky-node?

## Run [Swanky](https://github.com/AstarNetwork/swanky-node) Node
* Start your Swanky node and connect [polkadot-JS UI](https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/explorer) to it. Please note that for Swanky node there will be no node production if there is no interaction with it.

:::note

Please note that the current version of polkadot-JS is broken for contracts because of [lack of support for Weights V2](https://github.com/polkadot-js/apps/issues/8364). Until that gets resolved please use our [custom built polkadot-JS UI](https://polkadotjs-apps.web.app/#/explorer) or [Contracts-UI](https://contracts-ui.substrate.io/).

:::

## From Zero to ink Hero [Tutorials](/docs/build/wasm/from-zero-to-ink-hero/flipper-contract/flipper)
Depending on your confidence, use any of these tutorial. If you are just starting, the Flipper contract is the way to go.
* Your task is to deploy the contract from the tutorial to Shibuya Network.
* After you build contract notice where the `.contract` and `metadata.json` are created.
* Deploy Contract using [Contracts-UI](https://contracts-ui.substrate.io/).
* What is the contract address?
* Do you have any method that requires payment to be executed?
* Use Polkadot-JS UI to reload same contract you just deployed using Contracts-UI.


What is [next](/docs/build/builder-guides/hacking/next)?
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions docs/build/builder-guides/hacking/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Astar Hacker Guide
![banner](../../assets/gradient8.jpg)
Welcome to Web3!
## What is this Guide all about?
This guide will navigate you through the Astar Documentation to jump start your development journey. We are aware of the complexity of the subject and want to encourage and support you on your Web3 journey.
This Astar Hacker Guide can be used for:
* General Dev onboarding on Astar.
* Preparing participants for Astar centric hackathons.
* Onboarding new team members for teams building on Astar.
* Onboarding new Astar team members.


## Your Developer Background
To follow this Hacker Guide you should have basic programming understanding. The programming languages used throughout this guide are Rust, Solidity and Javascript. Your previous knowledge of them is not mandatory but it will be useful if you add some basics under your hacker's belt.

## How to use it
This guide is divided into 2 tracks with the mandatory General chapter.

0. ***General*** - must know basics. Nodes, interactions, accounts, Environment
1. ***Wasm smart contracts*** - build, deploy, test, interact
2. ***EVM smart contracts*** - build, deploy, test and interact

Each section has assignments and questions which will help you to understand what is expected from you.
51 changes: 51 additions & 0 deletions docs/build/builder-guides/hacking/next.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
sidebar_position: 4
---


# Next step
Here comes the fun! Time to build your own dApp.
Here you will find a list of ideas to implement in any of the smart contract environments.


## Enter Community

- Join Astar Discord and Post GM.
- Follow Twitter.
- Create an account on Stack Exchange.
- Create an account, Post Hi on Forum (A thread just for this purpose).
- Subscribe to Astar Newsletter.

## Ideas to build
These ideas can be implemented as WASM or EVM smart contract. Main intention is for the ink! developers.

### Pool Together
Explore this [project](https://app.pooltogether.com/) and build your own version in ink!

### Voting
Use ink4 from Swanky-node to develop a smart contract which allows people to vote The rules are:

* Contract owner initializes a set of candidates (2-10).
* Lets anyone vote for the candidates.
* Each voter is limited to only one ote (per address).
* Displays the vote totals received by each candidate.

### Tamagotchi
1. Requirements TBA, WIP

### Charity Raffle

Use ink4 from Swanky-node to develop a smart contract which allows people to enter a charity raffle. The rules are:

* A user can send in anywhere between 0.01 and 0.1 tokens.
* A user can only play once.
* A user is added to the pool with one submission, regardless of money that was sent in.
* There can be a maximum of 2 winners.
* The raffle must go on for 15 minutes before a draw can be initiated, but the 15 minute countdown only starts once there are at least 5 players in the pool.
* Anyone can call the draw function at any time, but it will only draw a winner when the 15 minute timer has expired.
* The draw function can be called twice for a maximum of two winners.
* The winners get nothing (it’s a raffle for a real world item, like a t-shirt, so ignore on-chain effects of a win) but they need to be clearly exposed by the contract, i.e. the list of winners has to be a public value dapps and users can read from the contract.
* The collected money from the pot is automatically sent to a pre-defined address when the second winner is drawn.

Happy coding!

2 changes: 1 addition & 1 deletion docs/build/environment/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Setup the Development Environment
![banner](../assets/gradient6.jpg)
![banner](../assets/gradient5.jpg)

Prior to commencing development, you do not need to know how to set up these environments. However, you may want to review the following sections to become more familiar with what they do, and their specific requirements.

Expand Down