A Solidity project for ERC20 proxy contracts using OpenZeppelin upgradeable contracts and Truffle. This project demonstrates how to manage and transfer control of upgradeable proxy contracts.
contracts/: Solidity smart contractsERC20_V1.sol: Upgradeable ERC20 token implementationERC721Implementation.sol: Upgradeable ERC721 token implementationImportHelper.sol: Helper file to import OpenZeppelin proxy contracts
migrations/: Truffle migration scriptsscripts/: Utility scriptscomplete-test-workflow.js: Demonstrates proxy admin management
test/: Test files for contracts
- Install dependencies:
npm install
- Create a
.envfile based on.env.exampleand fill in your configuration:
cp .env.example .env
- Compile contracts:
npm run compile
- Run tests:
npm run test
- Deploy contracts:
npm run deploy
- Upgradeable ERC20 token implementation
- OpenZeppelin contracts for security and standardization
- Truffle for compilation, testing, and deployment
- Proxy admin management and transfer workflow
The complete-test-workflow.js script demonstrates how to change the admin of a transparent upgradeable proxy contract. This is useful for consolidating control of multiple proxies or transferring control between different entities.
- Deploy a ProxyAdmin contract to manage your proxy
- Deploy the ERC20 implementation contract (ERC20_V1)
- Deploy a TransparentUpgradeableProxy pointing to your implementation
- Initialize the implementation with token details
- Verify the proxy's admin is correctly set
- Deploy another ProxyAdmin contract that will become the new admin
- Deploy a second proxy with the second ProxyAdmin
- Create a deployment file with mixed admin references
- Observe warnings about mismatched proxy admins
- Verify each proxy has its correct admin before changes
- Use the first ProxyAdmin's
changeProxyAdminfunction to transfer admin rights - Verify the admin slot now contains the address of the second ProxyAdmin
- Confirm the token's name and symbol are preserved after the admin change
- Test token functionality by minting tokens through the proxy
- Verify the second ProxyAdmin can correctly manage the first proxy
- Admin Consolidation: Simplify management by controlling multiple proxies with one admin
- Safe Transitions: Preserve contract state and functionality while changing control
- Organizational Control: Transfer control of upgradeable contracts between different entities
npx truffle exec scripts/complete-test-workflow.js --network development- Truffle: Smart contract development framework
- OpenZeppelin Contracts Upgradeable: Secure, upgradeable contract implementations
- Solidity v0.8.21: Smart contract language
MIT