Skip to content

Commit

Permalink
Merge pull request #110 from neonlabsorg/fix/using-hardhat-foundry
Browse files Browse the repository at this point in the history
fix hardhat & add foundry examples
  • Loading branch information
m4sterbunny authored Dec 5, 2023
2 parents 3f9cf82 + e2ac04e commit f061663
Show file tree
Hide file tree
Showing 12 changed files with 290 additions and 112 deletions.
4 changes: 2 additions & 2 deletions docs/about/why_neon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Neon EVM enables Solidity- and Vyper-based dApps to tap into Solana’s network

From a developer’s perspective, this means creating Solana-compatible contracts using tools you’re familiar with from the Ethereum Ecosystem.

Neon EVM makes the key Ethereum dApp tools compatible with Solana, including Vyper, Solidity, [MetaMask](/docs/wallet/metamask_setup), [Hardhat](/docs/developing/deploy_facilities/using_hardhat), [Remix](/docs/developing/deploy_facilities/using_remix), (and [Truffle](/docs/developing/deploy_facilities/using_truffle)). The solution allows any Ethereum application to run on Solana with minimal reconfiguration, this includes Uniswap, SushiSwap, 0x, and MakerDAO.
Neon EVM makes the key Ethereum dApp tools compatible with Solana, including Vyper, Solidity, [MetaMask](/docs/wallet/metamask_setup), [Foundry](/docs/developing/deploy_facilities/using_foundry), [Hardhat](/docs/developing/deploy_facilities/using_hardhat), [Remix](/docs/developing/deploy_facilities/using_remix), (and [Truffle](/docs/developing/deploy_facilities/using_truffle)). The solution allows any Ethereum application to run on Solana with minimal reconfiguration, this includes Uniswap, SushiSwap, 0x, and MakerDAO.


### Who uses Neon EVM?
Expand All @@ -40,7 +40,7 @@ Neon EVM offers a better solution: by bringing Solana's sophisticated and low-co
With Neon EVM, developers retain:

* Familiar languages: Solidity, Vyper
* Well-known Ethereum tools: MetaMask, Hardhat, Remix, etc.
* Well-known Ethereum tools: MetaMask, Foundry, Hardhat, Remix, etc.
* Ethereum RPC API compatibility
* Ethereum Accounts, Signatures, Token standards (ERC-20 and ERC-721)

Expand Down
25 changes: 17 additions & 8 deletions docs/developing/connect_rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ proofedDate: 20231101
iterationBy: na
includedInSite: true
approvedBy: na
comment:
comment: todo Find out from Yury whether we can have a NeonLabs youtube domain to support the video material that has been created to complement this page
---

import chainlist_raw from '@site/static/img/doc-images/developing/chainlist/chainlist-raw-3.png';
import chainlist_gotcha from '@site/static/img/doc-images/developing/chainlist/chainlist4.png';

Check failure on line 10 in docs/developing/connect_rpc.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'chainlist_gotcha'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'chainlist_gotcha'?", "location": {"path": "docs/developing/connect_rpc.md", "range": {"start": {"line": 10, "column": 8}}}, "severity": "ERROR"}

Check failure on line 10 in docs/developing/connect_rpc.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'chainlist'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'chainlist'?", "location": {"path": "docs/developing/connect_rpc.md", "range": {"start": {"line": 10, "column": 70}}}, "severity": "ERROR"}
import chainlist from '@site/static/img/doc-images/developing/chainlist/chainlist-raw-3.png';

## TL;DR

Expand Down Expand Up @@ -41,7 +42,7 @@ One Proxy may be available on different networks (i.e. Devnet and Mainnet). The

To view the available RPC endpoints, expand the card details of the network of your choice.

> <img src={chainlist_raw} width="450" />
> <img src={chainlist} width="450" />
Notice that if several Proxy Operators offer public RPC endpoints, you have a choice over who to use.

Expand All @@ -53,13 +54,21 @@ The preceding steps demonstrate how to connect to a Solana cluster via Chainlist

## Connect dev tools to Neon EVM

To connect to a Proxy using Remix or Hardhat, check out the following resources:

- [Using Remix](developing/deploy_facilities/using_remix.md)
- [Using Hardhat](developing/deploy_facilities/using_hardhat.md)
To connect to a Proxy check out the following resources:

Check warning on line 57 in docs/developing/connect_rpc.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google-adapted.Substitutions] Use 'select' instead of 'check'. Raw Output: {"message": "[Google-adapted.Substitutions] Use 'select' instead of 'check'.", "location": {"path": "docs/developing/connect_rpc.md", "range": {"start": {"line": 57, "column": 23}}}, "severity": "WARNING"}
* [Using Foundry](developing/deploy_facilities/using_foundry.md)
* [Using Hardhat](developing/deploy_facilities/using_hardhat.mdx)
* [Using Remix](developing/deploy_facilities/using_remix.md)
* [Using Truffle](developing/deploy_facilities/using_truffle.md)

Please note that, for Hardhat, you need to set up the configuration file by setting the URL and the `network_id`/`chainId` to the RPC URL (and ID) selected from Chainlist. This is described in detail in the relevant tutorial sections.

## Gotchas

Should the main "Connect Wallet" button not function, use the dropdown and use the "Connect Wallet" for a specified RPC server address.

> <img src={chainlist_gotcha} width="450" />
## What next?

If you wish to transact via your RPC, then check out the [supported RPC API methods](/docs/evm_compatibility/json_rpc_api_methods).
If you wish to transact via your RPC, then checkout the [supported RPC API methods](/docs/evm_compatibility/json_rpc_api_methods).

3 changes: 1 addition & 2 deletions docs/developing/deploy_facilities/configure_foundry.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ proofedDate: 20231116
iterationBy: na
includedInSite: true
approvedBy: na
comment: Killing the ## What next? See the [tutorial on how to use Foundry](/docs/developing/deploy_facilities/using_foundry) to deploy to Neon EVM. as this is killing the build todo -- return this later
comment:
---

Foundry is a blazing fast, portable,modular toolkit for Ethereum application development written in Rust.
Expand Down Expand Up @@ -34,4 +34,3 @@ The parameters for `forge create` command include:
* `--legacy`: This parameter is being passed to use legacy transactions _(Neon EVM currently [doesn't support EIP-1559 transactions](/docs/evm_compatibility/overview#shared-standards-and-features))_



2 changes: 1 addition & 1 deletion docs/developing/deploy_facilities/configure_hardhat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The Hardhat framework isn't described here; find that in the [Hardhat documentat

<ConfigHardHat/>

We provide a full example of the `hardhat.config.js` configuration file for connecting Hardhat to a Devnet Proxy using the one-way library on Node.js:
The following config file provides a full example of the `hardhat.config.js` for connecting Hardhat to a Devnet Proxy using the one-way library on Node.js:

Check warning on line 28 in docs/developing/deploy_facilities/configure_hardhat.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google-adapted.Substitutions] Use 'configuration' instead of 'config'. Raw Output: {"message": "[Google-adapted.Substitutions] Use 'configuration' instead of 'config'.", "location": {"path": "docs/developing/deploy_facilities/configure_hardhat.mdx", "range": {"start": {"line": 28, "column": 15}}}, "severity": "WARNING"}

Check warning on line 28 in docs/developing/deploy_facilities/configure_hardhat.mdx

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google-adapted.Substitutions] Use 'configuration' instead of 'config'. Raw Output: {"message": "[Google-adapted.Substitutions] Use 'configuration' instead of 'config'.", "location": {"path": "docs/developing/deploy_facilities/configure_hardhat.mdx", "range": {"start": {"line": 28, "column": 67}}}, "severity": "WARNING"}

### hardhat.config.js

Expand Down
155 changes: 155 additions & 0 deletions docs/developing/deploy_facilities/using_foundry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
title: Deploy with Foundry
proofedDate: 20231116
iterationBy: na
includedInSite: true
approvedBy: na
comment:
---

import mm_p_key from '@site/static/img/doc-images/developing/deploy_facilities/foundry-metamask.png';

Check failure on line 10 in docs/developing/deploy_facilities/using_foundry.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'mm_p_key'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'mm_p_key'?", "location": {"path": "docs/developing/deploy_facilities/using_foundry.md", "range": {"start": {"line": 10, "column": 8}}}, "severity": "ERROR"}

Check failure on line 10 in docs/developing/deploy_facilities/using_foundry.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Terms] Use 'MetaMask' instead of 'metamask'. Raw Output: {"message": "[Vale.Terms] Use 'MetaMask' instead of 'metamask'.", "location": {"path": "docs/developing/deploy_facilities/using_foundry.md", "range": {"start": {"line": 10, "column": 88}}}, "severity": "ERROR"}

This tutorial walks through deploying a contract describing an ERC-20 token to Neon Devnet.

Check failure on line 12 in docs/developing/deploy_facilities/using_foundry.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'Devnet'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'Devnet'?", "location": {"path": "docs/developing/deploy_facilities/using_foundry.md", "range": {"start": {"line": 12, "column": 85}}}, "severity": "ERROR"}

<!-- I don't see this step: You test this contract by transferring tokens to randomly generated wallet. todo verify if this can be added, or if I missed it -->

## Introduction

This tutorial is based on an [example in GitHub](https://github.com/neonlabsorg/neon-tutorials/tree/main/foundry).

Check warning on line 18 in docs/developing/deploy_facilities/using_foundry.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google-adapted.Passive] In general, use active voice instead of passive voice ('is based'). Raw Output: {"message": "[Google-adapted.Passive] In general, use active voice instead of passive voice ('is based').", "location": {"path": "docs/developing/deploy_facilities/using_foundry.md", "range": {"start": {"line": 18, "column": 15}}}, "severity": "INFO"}

:::info

Check warning on line 20 in docs/developing/deploy_facilities/using_foundry.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google-adapted.Substitutions] Use 'information' instead of 'info'. Raw Output: {"message": "[Google-adapted.Substitutions] Use 'information' instead of 'info'.", "location": {"path": "docs/developing/deploy_facilities/using_foundry.md", "range": {"start": {"line": 20, "column": 4}}}, "severity": "WARNING"}
This page is a quickstart based on a specific example program. For more details on installing Foundry, refer to the *[Foundry documentation](https://book.getfoundry.sh/getting-started/installation)*.
:::

## Prerequisites

- An EVM-compatible wallet, such as MetaMask [connected to Devnet](/docs/developing/connect_rpc#connect-via-chainlist)

Check failure on line 26 in docs/developing/deploy_facilities/using_foundry.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'Devnet'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'Devnet'?", "location": {"path": "docs/developing/deploy_facilities/using_foundry.md", "range": {"start": {"line": 26, "column": 60}}}, "severity": "ERROR"}
- A balance in [Devnet NEON](https://neonfaucet.org/)

Check failure on line 27 in docs/developing/deploy_facilities/using_foundry.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'Devnet'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'Devnet'?", "location": {"path": "docs/developing/deploy_facilities/using_foundry.md", "range": {"start": {"line": 27, "column": 17}}}, "severity": "ERROR"}

### Step 1: Installation

1.1 Clone the example Foundry project from the remote repository and navigate to it:

```sh
git clone https://github.com/neonlabsorg/neon-tutorials
cd neon-tutorials/foundry
```

1.2 Install Foundryup with:

Check failure on line 38 in docs/developing/deploy_facilities/using_foundry.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'Foundryup'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'Foundryup'?", "location": {"path": "docs/developing/deploy_facilities/using_foundry.md", "range": {"start": {"line": 38, "column": 13}}}, "severity": "ERROR"}
```sh
curl -L https://foundry.paradigm.xyz | bash
foundryup
```

:::info
`foundryup` installs the latest _(nightly)_ precompiled binaries: forge, cast, anvil, and chisel.

Check failure on line 45 in docs/developing/deploy_facilities/using_foundry.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Vale.Spelling] Did you really mean 'precompiled'? Raw Output: {"message": "[Vale.Spelling] Did you really mean 'precompiled'?", "location": {"path": "docs/developing/deploy_facilities/using_foundry.md", "range": {"start": {"line": 45, "column": 45}}}, "severity": "ERROR"}
:::


1.3 Install the required libraries:
```sh
forge install foundry-rs/forge-std --no-commit
forge install openzeppelin/openzeppelin-contracts --no-commit
```


### Step 2: Set up an environment file

:::info
This step requires an EVM-compatible wallet such as MetaMask, connected to Neon Devnet, with a balance in Devnet NEON available from [NeonFaucet](https://neonfaucet.org/).

The following tutorials assist you to meet these prerequisites:
- Learn how to [install a MetaMask wallet and connect it to Devnet](/docs/wallet/metamask_setup)
> Or [connect an existing wallet to Devnet](/docs/developing/connect_rpc#connect-via-chainlist)
:::

<!-- I suspect there is no need to create new wallet as per first draft of page >> existing wallet probably fine -- test on run through -->

2.1 Obtain the private key for your wallet account.

> To obtain the private key from MetaMask, from the hamburger menu, click **Account Details** > **Show Private Key**, enter your password, and click **Confirm** for access to the private key for that account.
> <img src={mm_p_key} width="250" />
2.2 Create a .env file and add these lines:

```
RPC_URL_DEVNET=https://devnet.neonevm.org
CHAIN_ID_DEVNET=245022926
RPC_URL_MAINNET=https://neon-proxy-mainnet.solana.p2p.org
CHAIN_ID_MAINNET=245022934
PRIVATE_KEY=<YOUR_PRIVATE_KEY>
VERIFIER_URL_BLOCKSCOUT=https://neon-devnet.blockscout.com/api
```
:::important
Replace <YOUR_PRIVATE_KEY> with your data.
:::

2.3 Run:
```
source .env
```


### Step 3: Compile contracts

The contracts are located in the project's `src/` directory. Before these contracts can be run, they must first be compiled.

3.1 To compile the project's contracts, run the following command:
```sh
forge build
```

After running this step, you should see output similar to the following:
```
[⠢] Compiling...
[⠒] Compiling 24 files with 0.8.21
[⠃] Solc 0.8.21 finished in 2.48s
Compiler run successful!
```

3.2 (Optional) test the smart contracts with:
```sh
forge test
```

### Step 4: Deploy Contracts

4. To deploy the project's contracts, run:
```sh
forge create --rpc-url $RPC_URL_DEVNET --private-key $PRIVATE_KEY src/TestERC20/TestERC20.sol:TestERC20 --constructor-args "Test ERC20 Token" "TERC20" --legacy
```

On running this step you should get console output similar to:
```
[⠰] Compiling...
No files changed, compilation skipped
Deployer: 0x4455E84Eaa56a01676365D4f86348B311969a4f4
Deployed to: 0x5537599aa2F97Dd60a66342522a465A7f2e40Ff9
Transaction hash: 0x6de9dab8a526cbac33008056d185b93dff725605efb791bf116b6bece4f0c486
```

### Step 5: Contract verification

5.1 Verify the deployment of our smart contract on the explorer [Neon Blockscout](https://neon-devnet.blockscout.com) using following command:
```sh
forge verify-contract --chain-id $CHAIN_ID_DEVNET <contract_address> src/TestERC20/TestERC20.sol:TestERC20 --verifier-url $VERIFIER_URL_BLOCKSCOUT --verifier blockscout
```

:::important
Replace `<contract_address>` with your smart contract address.
:::

After successfully running this step you should get console output similar to:
```
Start verifying contract `0x5537599aa2F97Dd60a66342522a465A7f2e40Ff9` deployed on 245022926
Submitting verification for [src/TestERC20/TestERC20.sol:TestERC20] "0x5537599aa2F97Dd60a66342522a465A7f2e40Ff9".
Submitted contract for verification:
Response: `OK`
GUID: `5537599aa2f97dd60a66342522a465a7f2e40ff9654118b3`
URL:
https://neon-devnet.blockscout.com/api?/address/0x5537599aa2f97dd60a66342522a465a7f2e40ff9
```

5.2 Copy/paste this link in your browser, remembering to replace `contract_address` with your freshly deployed contract address:

```https://neon-devnet.blockscout.com/address/<contract_address>```
94 changes: 0 additions & 94 deletions docs/developing/deploy_facilities/using_hardhat.md

This file was deleted.

Loading

0 comments on commit f061663

Please sign in to comment.