Skip to content

henry861010/311551136-bdaf-lab3

Repository files navigation

311551136-bdaf-lab2

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:

    1. deposit(address token, uint256 amount): deposit the specific token with amount what you want.
    1. 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.

1. set the enviroment

going to the folder of the program and running the following instructions in the shell:

    1. create the package.json file: npm init
    1. install hardhat pachage: npm install hardhat --save-dev
    1. install or upgrade the package: npm install
    1. add the following enviroment variable into .env file:
      1. API_URL = [YOUR_API_URL]
      2. API_KEY = [YOUR_API_KEY]
      3. PRIVATE_KEY = [YOUR_PRIVATE_KEY]
      4. ETHERSCAN_API_KEY = [YOUR_ETHERSCAN_API_KEY]
    1. make sure the version of node.js up to v16.0.0

2. run program

    1. compile the contract with hardhat: npx hardhat compile
    1. 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.
    1. verify the contract on the goerli network with hardhat: npx hardhat verify --network goerli [DEPLOYED_CONTRACT_ADDRESS]

3. reference

About

NYCU blockchain and FinTec about the erc20 token

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published