This repo contains demo node modules (javascript files) for interacting with the Ethereum blockchain using the Ethers.js library.
- node.js console applications
- .env and the dotenv npm package
- basic shell commands
- asynchronous javascript (if editing existing scripts)
- Infura account
- Visit infura.io to set up a new account
- Create a new project in your Infura account
- The new project will have a ProjectID and secret that will be used in running the scripts
- Node & NPM
- VS Code (or similar)
- Terminal window (VS Code inbuilt, powershell, gitbash)
- Compiler requirements
- See https://docs.soliditylang.org/en/v0.7.4/installing-solidity.html for further details.
- Most of these requirements may already be installed already (eg git).
- Copy & rename
.env_example
to.env
- Update
projectId
andprojectSecret
with credentials from your infura account - Navigate to the folder location in a terminal window (
cd C:\path\to\project\folder
) - Install
npm i -g truffle
to install the Ethereum contract compiler library globally - Run
npm install
to install npm packages
- Run
node t1_generateAccounts
- Add test network (rinkeby) value to account1:
- Go to https://faucet.rinkeby.io/
- Follow the instructions on the website to add value
- Update
.env
file with the account information that has been output to the console window
- Run
truffle compile
- If this fails, check compiler is installed and requirements are met
- Run
node tc1_createFungibleContract
- Update
.env
file with the contract address information (ftAddress)
node t1_generateAccounts
: Generate new Ethereum Accountsnode t2_getBalance
: Get the balance of an Ethereum Accountnode t3_transferEth
: Transfer Eth balance between two Ethereum Accountsnode t4_createFT
: Create a new contract using ERC20 spec (Fungible Token)node t5_transferTokens
: Transfer tokens between accountsnode t6_createNFT
: Create a new contract using ERC720 spec (Non Fungible Token)node t7_transferNFT
: Transfer an NFT between Ethereum Accounts