There are three contract:
-
- Safecontract: it is like a bank, which you can deposit and withdraw the different ERC20-token in. it provides the following function:
- deploy:
Safecontract.deplot([OWNER_ADDRESS])
get_version()
: get the version of the contractdeposit(address token, uint256 amount)
: deposit the token to the contract. there is the 0.1% feewithdraw(address token, uint256 amount)
: withdraw the token from the contracttakeFee(address token)
: take fee from the contract. only the owner can execute this functionfee(address token)
: get the fee which stores in the contractbalanceof(address account, address token)
: get the balancesafecontract_owner()
: get the owner of the safe contract
- deploy:
- Safecontract: it is like a bank, which you can deposit and withdraw the different ERC20-token in. it provides the following function:
-
- Proxy: a proxy contract which let the owner update the implmentation contract. it provides the following function:
- deploy:
proxy.deplot([IMPLEMENTATION_ADDRESS], [OWNER_ADDRESS])
update_implementation(address newImp)
: used to updata the implementationupdate_owner(address newOwner)
:used to updata the owner of proxyowner()
:used to get the owner of this proxy
- deploy:
- Proxy: a proxy contract which let the owner update the implmentation contract. it provides the following function:
-
- SafeFactory: it is a factory of Safecontract, which let the user get the proxy or safec ontract from it. it provides the following function:
deploy:SafeFactory.deplot([IMPLEMENTATION_CONTRACT])
updateImplementation(address newImp)
: update the Safecontract in the factorydeploySafeProxy()
:deploy the proxy contract which delegates Safecontract and the owners of the both Smartcontact and proxy are function callerdeploySafe()
:deploy the Safecontract contract whose owner is function callerproxy_search(address owner)
: get the caller's proxy contract which was generated by factoy.safecontract_search(address owner)
: get the caller's Smartcontract whish is generated by factoy.
- SafeFactory: it is a factory of Safecontract, which let the user get the proxy or safec ontract from it. it provides the following function:
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:
-
- 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]
- PUBLIC_KEY = [YOUR_PUBLIC_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 the goerli network, and then get the address of the deployed contract:
- deploy the safecontract:
npx hardhat run deploy/deploy_safecontract.js --network goerli
- deploy the proxy:
npx hardhat run deploy/deploy_proxy.js --network goerli
- deploy the safefactory:
npx hardhat run deploy/safefactory.js --network goerli
- deploy the safecontract:
- deploy the contract to the goerli network, and then get the address of the deployed contract:
-
- 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