This directory contains all the files necessary to deploy simplest ERC20-like contract using Neon onto the Solana blockchain. This example base on project https://github.com/neonlabsorg/examples/tree/main/simple-erc20-hardhat
Run command
git clone https://github.com/neonlabsorg/examples.git
NOTE All the next operations must be performed from the examples/simple-erc20-hardhat directory
- Install requirements
npm install
NOTE In case of error try to execute:
npm cache clear --force
and then back to previous command
NOTE Private keys in hardhat.config.js file are compromised so it is highly recommended to setup your own test accounts to run this example. This project uses two test accounts. We will call it account #1 and account #2 To create new accounts:
-
Setup your Metamask wallet to work with Neon devnet:
- Connect your metamask wallet to Neon Devnet using these settings:
- Network Name: Neon Devnet
- New RPC URL: https://devnet.neonevm.org
- Chain ID: 245022926
- Currency Symbol (optional): NEON
- Connect your metamask wallet to Neon Devnet using these settings:
-
Create 2 new accounts in Metamask
-
Airdrop at most 100 NEONs to just created account #1 from here
-
Copy your Metamask account's private keys (Account Details >> Export Private Key) and insert them into hardhat.config.js at lines 9 (account #1) and line 10 (account #2) NOTE! Add 0x prefix at the beginning
Execute command
./node_modules/.bin/hardhat test
This command will do next:
- Compile all smart-contracts related to this project
- Deploy these smart-contracts to the Neon devnet
- Run tests from ./test/test_erc20.js
After successfully running this step you should get console output similar to:
Compiled 2 Solidity files successfully
Testing TestERC20 contract
✔ should successfully mint 10000 ERC20 in the first account (15967ms)
✔ should transfer token correctly (31327ms)
2 passing (53s)
- Compiling contract
./node_modules/.bin/hardhat compile
- Deploying contract
./node_modules/.bin/hardhat run ./scripts/deploy.js
After successfully running this step you should get console output similar to:
Deploying contracts with the account: 0xf71c4DACa893E5333982e2956C5ED9B648818376
Contract address is: 0x49DCDEc367bba4271876259AE473890aa5AABc2e
Minting 100000000000 tokens...
This project contains only one deployment script which performs two actions:
- Deploying test ERC20 smart-contract
- Minting 100 TERC20 token to account #1 specified in hardhat.config.js file on line 9
In migration command output, in the line Contract address is: 0x49DCDEc367bba4271876259AE473890aa5AABc2e
is our
new ERC20 token contract address. You can easily import it into your Metamask wallet. After it you can transfer new
token from previously created account #1
- Config hardhat.config.js
etherscan: {
apiKey: {
neonevm: "test"
},
customChains: [
{
network: "neonevm",
chainId: 245022926,
urls: {
apiURL: "https://devnet-api.neonscan.org/hardhat/verify",
browserURL: "https://devnet.neonscan.org"
}
}
]
}
- Verify
./node_modules/.bin/hardhat verify 0x49DCDEc367bba4271876259AE473890aa5AABc2e
After successfully running this step you should get console output similar to:
Successfully submitted source code for contract
contracts/ERC20.sol:ERC20 at 0x49DCDEc367bba4271876259AE473890aa5AABc2e
for verification on the block explorer. Waiting for verification result...
Successfully verified contract ERC20 on Etherscan.
https://devnet.neonscan.org/address/0x49DCDEc367bba4271876259AE473890aa5AABc2e#code