-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
670b7b8
commit fa34542
Showing
33 changed files
with
331 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,7 @@ | |
svg.lucide { | ||
color: #3752AC; | ||
} | ||
|
||
.my-6 > svg.lucide { | ||
color: #fff; | ||
} |
34 changes: 32 additions & 2 deletions
34
content/course/customizing-evm/02-intro-to-evm/06-setup-core-wallet.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
--- | ||
title: Setup Core Wallet (Draft) | ||
title: Setup Core Wallet | ||
description: Learn how to setup Core Wallet. | ||
updated: 2024-05-31 | ||
authors: [ashucoder9] | ||
icon: Terminal | ||
--- | ||
--- | ||
|
||
## Install the Browser Extension | ||
|
||
The Core browser extension is compatible with Google Chrome and Brave Browser. Using one of these, head to the Chrome Web Store and add the Core extension: [Core Crypto Wallet & NFT Extension](https://chromewebstore.google.com/detail/core-crypto-wallet-nft-ex/agoakfejjabomempkjlepdflaleeobhb) | ||
|
||
<YouTube id="X3sVqXHdhnw" /> | ||
|
||
## Create a New Wallet | ||
|
||
Open the core extension and follow the instructions to create a new wallet. You can also follow the below video guide. | ||
|
||
<YouTube id="eczkjrGG_As" /> | ||
|
||
## Pin the Extension | ||
|
||
Don't forget to pin the extension, making it is easy to access. | ||
|
||
![](/course/customizing-evm/30.png) | ||
|
||
## Managing MetaMask and Core Extensions | ||
|
||
If you've added both Metamask and Core Wallet to your browser, you could face some problems. But to fix them, you don't need to remove Metamask. Just follow the below steps to disable the Metamask extension: | ||
|
||
1. Open the extensions page in your browser. You can also type `chrome://extensions/` in your address bar and press enter. | ||
2. Scroll through your list of installed extensions, or use the search bar at the top of the page, to find the Metamask extension. | ||
3. Once you find Metamask, you will see a toggle switch next to it. Click on this switch to disable the extension. | ||
|
||
When the switch is in the off position, Metamask is disabled, and you should be all set. | ||
|
||
![](/course/customizing-evm/31.png) |
37 changes: 36 additions & 1 deletion
37
content/course/customizing-evm/02-intro-to-evm/07-interact-wtih-precompile.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,43 @@ | ||
--- | ||
title: Interact with a Precompile (draft) | ||
title: Interact with a Precompile | ||
description: Learn about why you should utilize Precompiles in your smart contracts. | ||
updated: 2024-05-31 | ||
authors: [ashucoder9] | ||
icon: Terminal | ||
--- | ||
|
||
So let's get to it and interact with a precompile on the Fuji, Avalanche's testnet. | ||
|
||
## Switch Core to Testnet Mode | ||
|
||
Open the Core browser extension by clicking the Owl logo next to the address bar, then click the burger menu of your Core browser extension. Now, go to Advanced and activate Testnet Mode. | ||
|
||
## Compile Solidity Interface in Remix | ||
|
||
Open Remix and create a new Solidity file using the code below, and compile it (Cmd + s): [Remix Online Solidity IDE](https://remix.ethereum.org/#lang=en&optimize=false&runs=200&evmVersion=null&version=soljson-v0.8.26+commit.8a97fa7a.js) | ||
|
||
```solidity | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0; | ||
interface Isha256_precompile { | ||
function run (string memory value) external view returns (bytes32 hash); | ||
} | ||
``` | ||
|
||
## Call Precompile from Remix | ||
|
||
Switch to the **Deploy & Run Transactions** view in the left sidebar. Select the **Injected Provider** as the environment, let Core connect to Remix and paste this precompile address below in the **At Address** field: | ||
|
||
**Precompile Address:** `0x0000000000000000000000000000000000000002` | ||
|
||
![](/course/customizing-evm/32.png) | ||
|
||
Next, click the blue **At Address** button next to the input field where you entered the address. A new compiled contract appears below. Click the **small arrow** next to the name **SHA256** and call the function with any string. | ||
|
||
![](/course/customizing-evm/33.png) | ||
|
||
You can see the return value of the hash function below the input field. | ||
|
||
![](/course/customizing-evm/34.png) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
content/course/customizing-evm/08-chain-configuration/03-setup-chainid.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
...t/course/customizing-evm/08-chain-configuration/08-avalanche-network-runner.mdx
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
content/course/customizing-evm/08-chain-configuration/08-setup-thunderclient.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: Setup ThunderClient | ||
description: Learn about ThunderClient and how to use it to interact with the Avalanche network. | ||
updated: 2024-05-31 | ||
authors: [ashucoder9] | ||
icon: Terminal | ||
--- | ||
|
||
## What is ThunderClient | ||
|
||
Thunder Client is a lightweight, fast HTTP client extension for Visual Studio Code, designed as an alternative to applications like Postman for sending HTTP requests. | ||
|
||
## Installation | ||
|
||
Head over to the Visual Studio Marketplace and install the extension. Alternatively you can search for it in the **Extensions** tab of VS Code: [ThunderClient](https://marketplace.visualstudio.com/items?itemName=rangav.vscode-thunder-client) | ||
|
||
## Importing the Avalanche Academy Collection | ||
|
||
We provide a collection of requests, so you do not have to enter all of these yourself. Head to the **Collections** tab and click the symbol with three lines next to the search bar. There, click **Import from URL**. | ||
|
||
Paste the following URL in the input that appears: https://raw.githubusercontent.com/ava-labs/precompile-evm/avalanche-academy-start/.vscode/avalanche-academy-thunder-collection.json | ||
|
||
![](/course/customizing-evm/35.png) | ||
|
||
## Verify | ||
|
||
You should now see a collection called **Avalanche Academy - Customize the EVM** in your collections tab. When you click on it, you should see multiple requests in some folders. | ||
|
||
![](/course/customizing-evm/36.png) |
72 changes: 72 additions & 0 deletions
72
...izing-evm/08-chain-configuration/09-build-and-run-custom-genesis-blockchain.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
title: Build and Run Custom Genesis Blockchain | ||
description: Learn how to build and run your blockchain with custom genesis file. | ||
updated: 2024-05-31 | ||
authors: [ashucoder9] | ||
icon: Terminal | ||
--- | ||
|
||
## Build the Precompile-EVM | ||
|
||
In the root of your Precompile-EVM, run the following script: `./scripts/build.sh` | ||
|
||
## Launch Avalanche-Network-Runner | ||
|
||
To create a blockchain from our genesis block, we need to start a local Avalanche network using the Avalanche Network Runner. Make sure you do not have another instance of Avalanche Network Runner running in another terminal. | ||
|
||
Let's start the gRPC server, which will manage the Avalanche nodes for us, so we do not have to build the network manually. | ||
|
||
```bash | ||
avalanche-network-runner server \ | ||
--log-level debug \ | ||
--port=":8080" \ | ||
--grpc-gateway-port=":8081" | ||
``` | ||
|
||
In this terminal, you should now the the gRPC server logs. Since this will not launch the network yet, but just start the managing server, this should go fast. | ||
|
||
![](/course/customizing-evm/37.png) | ||
|
||
## Start an Avalanche Network with a New Blockchain | ||
|
||
Next, run a local Avalanche Network with five nodes and create a Blockchain of your EVM using the Genesis block you have created. | ||
|
||
From here, we can interact with the gRPC server we just launched. We do this using the HTTP client or by issuing command in the terminal. | ||
|
||
### Using HTTP Client | ||
|
||
To start the network, navigate to **ThunderClient** and select the **Start Network** endpoint. As we can see, most of the data is already prefilled: | ||
|
||
![](/course/customizing-evm/38.png) | ||
|
||
The only thing we have to specify is the path to our genesis JSON. Navigate to the file in `tests/precompile/genesis` and copy the absolute file path: | ||
|
||
![](/course/customizing-evm/39.png) | ||
|
||
Paste this path into the genesis value of the JSON. The path should look something like this `/Users/.../go/src/github.com/ava-labs/precompile-evm/tests/precompile/genesis/sha256.json`. | ||
|
||
Finally, click the **Send** button and observe what happens in the terminal of the server. This process should take about a minute. | ||
|
||
### By Issuing a Command in Terminal | ||
|
||
Alternatively, open up a new terminal and issue the following command: | ||
|
||
```bash | ||
avalanche-network-runner control start \ | ||
--log-level debug \ | ||
--endpoint="0.0.0.0:8080" \ | ||
--number-of-nodes=5 \ | ||
--blockchain-specs '[{"vm_name": "subnetevm", "genesis": "./tests/precompile/genesis/evm-configuration-genesis.json"}]' | ||
``` | ||
|
||
The command uses the environment variables for AvalancheGo we set earlier and a relative path to the the genesis JSON we have been modifying thoughout this section. It is important to understand that we can build the Virtual Machine once and create multiple blockchains from it using multiple genesis configurations. | ||
|
||
You should first see an output like this: | ||
|
||
```bash | ||
[07-05|17:54:15.547] DEBUG client/client.go:71 dialing server at {"endpoint": "0.0.0.0:8080"} | ||
[07-05|17:54:15.548] INFO client/client.go:140 start | ||
[07-05|17:54:51.047] INFO ux/output.go:13 start response: cluster_info:{node_names:"node1" node_names:"node2" node_names:"node3" node_names:"node4" node_names:"node5" node_infos:{key:"node1" value:{name:"node1" exec_path:"/Users/Martin.Eckardt/go/src/github.com/ava-labs/avalanchego/build/avalanchego" uri:"http://127.0.0.1:9650" id:"NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg" log_dir:"/var/folders/6m/57y_04h52mv7_93ycwdp30gw0000gn/T/network-runner-root-data/network_20230705_175415/node1/logs" db_dir:"/var/folders/6m/57y_04h52mv7_93ycwdp30gw0000gn/T/network-runner-root-data/network_20230705_175415/node1/db" plugin_dir:"/Users/Martin.Eckardt/go/src/github.com/ava-labs/avalanchego/build/plugins" whitelisted_subnets:"p433wpuXyJiDhyazPYyZMJeaoPSW76CBZ2x7wrVPLgvokotXz"}} node_infos:{key:"node2" value:{name:"node2" exec_path:"/Users/Martin.Eckardt/go/src/github.com/ava-labs/avalanchego/build/avalanchego" uri:"http://127.0.0.1:9652" id:"NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ" log_dir:"/var/folders/6m/57y_04h52mv7_93ycwdp30gw0000gn/T/network-runner-root-data/network_20230705_175415/node2/logs" db_dir:"/var/folders/6m/57y_04h52mv7_93ycwdp30gw0000gn/T/network-runner-root-data/network_20230705_175415/node2/db" plugin_dir:"/Users/Martin.Eckardt/go/src/github.com/ava-labs/avalanchego/build/plugins" whitelisted_subnets:"p433wpuXyJiDhyazPYyZMJeaoPSW76CBZ2x7wrVPLgvokotXz"}} node_infos:{key:"node3" value:{name:"node3" exec_path:"/Users/Martin.Eckardt/go/src/github.com/ava-labs/avalanchego/build/avalanchego" uri:"http://127.0.0.1:9654" id:"NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN" log_dir:"/var/folders/6m/57y_04h52mv7_93ycwdp30gw0000gn/T/network-runner-root-data/network_20230705_175415/node3/logs" db_dir:"/var/folders/6m/57y_04h52mv7_93ycwdp30gw0000gn/T/network-runner-root-data/network_20230705_175415/node3/db" plugin_dir:"/Users/Martin.Eckardt/go/src/github.com/ava-labs/avalanchego/build/plugins" whitelisted_subnets:"p433wpuXyJiDhyazPYyZMJeaoPSW76CBZ2x7wrVPLgvokotXz"}} node_infos:{key:"node4" value:{name:"node4" exec_path:"/Users/Martin.Eckardt/go/src/github.com/ava-labs/avalanchego/build/avalanchego" uri:"http://127.0.0.1:9656" id:"NodeID-GWPcbFJZFfZreETSoWjPimr846mXEKCtu" log_dir:"/var/folders/6m/57y_04h52mv7_93ycwdp30gw0000gn/T/network-runner-root-data/network_20230705_175415/node4/logs" db_dir:"/var/folders/6m/57y_04h52mv7_93ycwdp30gw0000gn/T/network-runner-root-data/network_20230705_175415/node4/db" plugin_dir:"/Users/Martin.Eckardt/go/src/github.com/ava-labs/avalanchego/build/plugins" whitelisted_subnets:"p433wpuXyJiDhyazPYyZMJeaoPSW76CBZ2x7wrVPLgvokotXz"}} node_infos:{key:"node5" value:{name:"node5" exec_path:"/Users/Martin.Eckardt/go/src/github.com/ava-labs/avalanchego/build/avalanchego" uri:"http://127.0.0.1:9658" id:"NodeID-P7oB2McjBGgW2NXXWVYjV8JEDFoW9xDE5" log_dir:"/var/folders/6m/57y_04h52mv7_93ycwdp30gw0000gn/T/network-runner-root-data/network_20230705_175415/node5/logs" db_dir:"/var/folders/6m/57y_04h52mv7_93ycwdp30gw0000gn/T/network-runner-root-data/network_20230705_175415/node5/db" plugin_dir:"/Users/Martin.Eckardt/go/src/github.com/ava-labs/avalanchego/build/plugins" whitelisted_subnets:"p433wpuXyJiDhyazPYyZMJeaoPSW76CBZ2x7wrVPLgvokotXz"}} pid:58541 root_data_dir:"/var/folders/6m/57y_04h52mv7_93ycwdp30gw0000gn/T/network-runner-root-data/network_20230705_175415" healthy:true custom_chains_healthy:true custom_chains:{key:"2YUr8sULVTm25EDFNDUwxnwk73enuqhkci4yXzoAgJYEjQ2HuC" value:{chain_name:"subnetevm" vm_id:"srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy" subnet_id:"p433wpuXyJiDhyazPYyZMJeaoPSW76CBZ2x7wrVPLgvokotXz" chain_id:"2YUr8sULVTm25EDFNDUwxnwk73enuqhkci4yXzoAgJYEjQ2HuC"}} subnets:{key:"p433wpuXyJiDhyazPYyZMJeaoPSW76CBZ2x7wrVPLgvokotXz" value:{is_elastic:true subnet_participants:{node_names:"node5" node_names:"node4" node_names:"node3" node_names:"node2" node_names:"node1"}}}} chain_ids:"2YUr8sULVTm25EDFNDUwxnwk73enuqhkci4yXzoAgJYEjQ2HuC" | ||
``` | ||
|
||
After around 1 minute the blockchain should have been created and some more output should appear in the terminal. |
7 changes: 0 additions & 7 deletions
7
content/course/customizing-evm/08-chain-configuration/09-setup-thunderclient.mdx
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...izing-evm/08-chain-configuration/10-build-and-run-custom-genesis-blockchain.mdx
This file was deleted.
Oops, something went wrong.
82 changes: 82 additions & 0 deletions
82
content/course/customizing-evm/08-chain-configuration/10-connect-core.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
title: Connect Core | ||
description: Learn how to Connect Core to your new blockchain. | ||
updated: 2024-05-31 | ||
authors: [ashucoder9] | ||
icon: Terminal | ||
--- | ||
|
||
## Connecting to a Local Blockchain | ||
|
||
In order to interact with our new Blockchain, we need to connect a wallet. Wallets communicate with the blockchain through one of the nodes. To connect a wallet to the blockchain, we need to provide the following information: | ||
|
||
- Network RPC URL | ||
- Network Name | ||
- Chain ID | ||
- Token Symbol | ||
|
||
## RPC URLs | ||
|
||
Each node provides an RPC endpoint for its Blockchains. When you create a transaction, click on send and sign it, which causes it to be sent to the specified RPC URL of your blockchain by your wallet. | ||
|
||
An RPC URL could look something like this: http://127.0.0.1:9654/ext/bc/2YUr8sULVTm25EDFNDUwxnwk73enuqhkci4yXzoAgJYEjQ2HuC/rpc | ||
|
||
Let's dissect this URL: `http://<node_ip>:<node_port>/ext/bc/<blockchain_id>/rpc` | ||
|
||
**→ node_ip:** The IP of the node. Since we are testing locally, all of our nodes share the same IP 127.0.0.1 which equals to localhost, meaning it is always the current machine. | ||
|
||
**→ node_port:** Each Machine requires a unique port, so send and receive network data. The default port is 9650. Since we are are running 5 nodes locally, they are run on different ports. Uneven port numbers are skipped. | ||
|
||
**→ blockchain_id:** Each Blockchain has a unique id. Because a node validates multiple chains, we have to specify in the url which blockchain we want to submit the transaction to. | ||
|
||
## RPC URLs for Codespaces | ||
|
||
Since we are running our Avalanche network on Github Cloud while using Codespaces, localhost refers to the machine in the cloud. Therefore, we need to take few extra steps. | ||
|
||
### 1. Publish Ports | ||
|
||
First, let's instruct the codespace to make the port available to everyone on the internet. Find the port 9650, right-click the entry, and set the **Port Visibility** to **Public**. | ||
|
||
![](/course/customizing-evm/40.png) | ||
|
||
### 2. Get URL | ||
|
||
Next, right-click the same row and click **Copy Local Address**. | ||
|
||
![](/course/customizing-evm/41.png) | ||
|
||
This will give us something like: `https://obscure-succotash-pjr7qxv9q6gh696v-9650.app.github.dev/` | ||
|
||
This is equivalent to `localhost:9650` if we were running the network on our local machine. Now, we have to add the rest of the URL (`/ext/bc/<BLOCKCHAIN_ID>/rpc`), | ||
so we will end up with something like this: `https://obscure-succotash-pjr7qxv9q6gh696v-9650.app.github.dev/ext/bc/2YUr8sULVTm25EDFNDUwxnwk73enuqhkci4yXzoAgJYEjQ2HuC/rpc` | ||
|
||
Follow these steps to create the RPC URLs for one of the Avalanche nodes running in your own codespace. | ||
|
||
## Add Network to Core | ||
|
||
Now, open the Core browser extension and navigate from there to the screen to add a new network. | ||
|
||
<Gallery url1="/course/customizing-evm/42.png" url2="/course/customizing-evm/43.png" /> | ||
|
||
Now, enter the RPC URL for your network and append **/rpc** to it: `http://127.0.0.1:<node_port>/ext/bc/<your_blockchain_id>/rpc` | ||
|
||
Also, add the following information: | ||
|
||
- **Network Name**: Pick an arbitrary name, such as MyChain | ||
- **ChainID**: Use the number you assigned at the top of your Genesis JSON file | ||
- **Token Symbol**: Any symbol name for your native gas token, such as TOK | ||
|
||
<Gallery url1="/course/customizing-evm/44.png" url2="/course/customizing-evm/45.png" /> | ||
|
||
Hit **Save** and make sure to **switch** to the newly created Network. | ||
|
||
## Send Tokens | ||
|
||
Go ahead and send some tokens to your other account by clicking the **circle with the plus** and then **Send**. From there, click on icon in the address field and switch to the tab **My Account** to select another of you accounts. | ||
|
||
<Gallery url1="/course/customizing-evm/46.png" url2="/course/customizing-evm/47.png" /> | ||
|
||
While sending the tokens, reflect on how this is influenced by: | ||
|
||
- the initial token allocation you have set | ||
- the gas fees you have set |
7 changes: 0 additions & 7 deletions
7
content/course/customizing-evm/08-chain-configuration/11-connect-core.mdx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.