Unlock Protocol contest details
- $47,500 USDC main award pot
- $2,500 USDC gas optimization award pot
- Join C4 Discord to register
- Submit findings using the C4 form
- Read our guidelines for more details
- Starts November 18, 2021 00:00 UTC
- Ends November 24, 2021 23:59 UTC
Unlock is a protocol for memberships that lets creators of all kinds deploy a "membership contract" (we call that a Lock) and that lets them then sell memberships (keys, implemented as NFT).
Unlock.sol : a factory contract that deploys all locks. It is also called back by the lock on key purchases to mint/distribute new UDT tokens. This contract is deployed once on each network currently supported (Mainnet, xDAI, Polygon, BSC). It is upgradable and currently 'owned' by a Gnosis multisig but will eventually be transfered to the DAO.
PublicLock: the actual "membership" contract that implements ERC721 and a few others. It is deployed multiple times by creators.
UnlockDiscountTokenV2: the governance token contract (UDT). The only minter is the Unlock contract.
Note: the code being reviewed has not been deployed yet, even though it is an incremental upgrade on the existing deployed code. Similarly, the documentation reflects the current implementation, not the code being reviewed. You can find below the most significant change:
You can run test in the smart-contracts repo with
yarn run test (make sure you run
yarn install first to install all dependencies).
If you want to run the front-end applications, please check instruction in the main Unlock repo.
The biggest change we introduced to the smart contract and that we hope to deploy in the next few weeks is to enable upgrades on the PublicLock smart contracts. We want these locks to be upgradable when new versions of the protocol are released, but only by their "Lock Managers" (See permission).
The approach we took is to deploy a Proxy Admin as part of the Unlock.sol contract. We updated the
createLock to deploy a lock proxy instead of the lock directly. We also introduced an
upgradeLock function that can then be trigger by one of the lock's lock managers to update the implementation.
To support these uprgades, the Unlock contract will now keep a list of implementation, as well the corresponding version numbers as we only support incremental upgrades.