see top left hand corner list icon
This project was designed for a set of simple contracts (with tests) that uses delegateCall
to defer logic to another contract. In particular, the call should move underlying funds owned by the contract thus delegating out control.
There are a few steps needed to run this project:
- We can run this program using your terminal. Open a new window and run
git clone ...
- It will require NodeJS, Mocha and Hardhat modules listed in the
package.json
file. Create a new folder in your directory, and runnpm install
- Once your npm modules are installed you can begin running Hardhat. It is a tool (often used as an alternative to Truffle) that will allow us to establish a blockchain on our local machine, allow us to compile contracts, and run tests. To compile, run
npx hardhat compile
. To test, runnpx hardhat test
(this will automatically compile the latest changes as well before it runs). - Once running compilation and test, your local machine should return unit tests output designed for the project.
- Enjoy!
This project was based on the following directions:
Design and write a set of simple contracts (with tests) that uses `delegatecall` to defer logic to another contract.
The call should move underlying funds owned by the contract delegating out control.
One should view the ContractProxy as a wallet that holds several ERC20 tokens that need to be moved.
ContractProxy.sol
- should delegatecall to ContractLogic
- owns and control many ERC20 tokens
ContractLogic.sol
- should contain the logic to move a token to another address by implementing
- transfer(token, recipient, amount)
Usage of libraries and frameworks is encouraged.
Read more about sequence-diagrams here: http://bramp.github.io/js-sequence-diagrams/ See logic below:
Note right of Token: Mint new Token
Token-->ContractProxy: supply of new token
Note over ContractProxy: Wallet now holds ERC20 tokens
Note over ContractProxy: Start new transaction
ContractProxy->ContractLogic: make delegateCall
Note right of ContractLogic: Send token to receipient
ContractLogic->ContractProxy: transaction executed
Note over ContractProxy: Ready for new tokens, balance & transactions