Skip to content

Commit

Permalink
general and wasm
Browse files Browse the repository at this point in the history
minor

evm plus next
  • Loading branch information
Maar-io committed Feb 13, 2023
1 parent 607328f commit 14fad12
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 1 deletion.
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
}
38 changes: 38 additions & 0 deletions docs/build/builder-guides/hacking/general.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
sidebar_position: 1
---

# General
Please read the linked chapter and try to answer questions. If you do not know the answer, go to Discord Developer Support and ask in general channel.

## 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 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 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 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.
31 changes: 31 additions & 0 deletions docs/build/builder-guides/hacking/hack_evm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
sidebar_position: 3
---
import CustomNet from './img/custom_net.png'
import Zombie from './img/zombie.png'

# Hack EVM Smart Contracts
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)?
34 changes: 34 additions & 0 deletions docs/build/builder-guides/hacking/hack_wasm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
sidebar_position: 2
---

# Hack Wasm Smart Contracts

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?

## 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.


## 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.
Binary file added docs/build/builder-guides/hacking/img/zombie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions docs/build/builder-guides/hacking/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Astar Hacker Guide

## What is this Guide all about?
Welcome to Web3! 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.
49 changes: 49 additions & 0 deletions docs/build/builder-guides/hacking/next.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
sidebar_position: 4
---


# Next step
Here comes the fun!!! Time to build your own dApp.
Here you will fins 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
### 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!

0 comments on commit 14fad12

Please sign in to comment.