Example of wrapping SPL token by ERC2-20 interface in Neon
Requirements
-
python3 and pip3 installed
-
install python requirements:
pip3 install -r requirements.txt
Steps
- Find your solana wallet address by typing in command line:
solana address
-
Airdrop some SOLs to your wallet address from here NOTE Make sure you airdropping to devnet
-
Check that balance is non-zero (1 SOL will be enough):
solana --url devnet balance
-
Connect your metamask wallet to Neon Devnet using this settings:
- New RPC URL: https://proxy.devnet.neonlabs.org/solana
- Chain ID: 245022926
- Currency Symbol (optional): NEON
-
Airdrop some NEONs to your wallet by this link - will drop maximum 10 tokens at a time.
-
cd to this file's parent directory in command line
-
Generate keypair for new SPL token:
solana-keygen new -o test-token-mint.json --force
You will be asked for passphrase (can skip this step by pressing Enter)
- Create new SPL token by running command:
spl-token --url devnet create-token -- test-token-mint.json
Copy Base59 encoded string returned by this command in line like:
Creating token 3CZZw1DhdzhmWkCBddvDFcPHJsRzG4SktcYg6MtNKY5Z
-
Convert this Base58 address representation into HEX using this service and copy resulting value
-
Replace tokenMint value on line 34 by value got on previous step NOTE Add 0x prefix to it
-
Load ERC20Example.sol file into Remix then compile and deploy it using Injected Web3 Environment on page "Deploy & run transactions" NOTE you should be connected to the same Metamask account that was supplied with airdrop on step 5 and to the same network that was setup on step 4.
-
Copy ERC20 contract address
-
Import newly created token into Metamask. Balance should be 0
-
Run mint_erc20_wrapped_token.py script with 2 arguments:
- first - contract address got on the step 11
- second - your Metamask wallet address
For example:
> python3 mint_erc20_wrapped_token.py 0xb19665132A95e06887e085564e43635eCC24e139 0xf71c4DACa893E5333982e2956C5ED9B648818376
After successfull execution balance should change to 1000