This smart contract is like the bank, which you can deposit and withdraw the different ERC20-token in. and it provides two functions to call:
-
deposit(address token, uint256 amount)
: deposit the specific token with amount what you want.
-
withdraw(address token, uint256 amount)
: withdraw the specific token with amount what you want.
Please note, When use deposit(token,amount)
method, you need to set the allowance(THIS_CONTRACT_ADRESS,amount)
method blong to what the token you want to store, to allow the contract transfer token from your account.
going to the folder of the program and running the following instructions in the shell:
-
- create the package.json file:
npm init
- create the package.json file:
-
- install hardhat pachage:
npm install hardhat --save-dev
- install hardhat pachage:
-
- install or upgrade the package:
npm install
- install or upgrade the package:
-
- add the following enviroment variable into
.env
file:- API_URL = [YOUR_API_URL]
- API_KEY = [YOUR_API_KEY]
- PRIVATE_KEY = [YOUR_PRIVATE_KEY]
- ETHERSCAN_API_KEY = [YOUR_ETHERSCAN_API_KEY]
- add the following enviroment variable into
-
- make sure the version of node.js up to v16.0.0
-
- compile the contract with hardhat:
npx hardhat compile
- compile the contract with hardhat:
-
- deploy the contract to goerli network with hardhat:
npx hardhat run scripts/deploy.js --network goerli
, and then you get the address of the deployed contract.
- deploy the contract to goerli network with hardhat:
-
- verify the contract on the goerli network with hardhat:
npx hardhat verify --network goerli [DEPLOYED_CONTRACT_ADDRESS]
- verify the contract on the goerli network with hardhat:
-
- how to deploy the contract with hardhat: https://docs.alchemy.com/docs/hello-world-smart-contract
-
- how to verify the contract with hardhat: https://docs.alchemy.com/docs/submitting-your-smart-contract-to-etherscan