About Smart Contracts

The Unlock Protocol, at its core, is enabled by 2 primary Ethereum smart contracts, deployed on all networks supported by Unlock: the Unlock and the PublicLock contracts. We have a few more contracts, such as the governance token contract and the actual governance contract, but they are not actually required by the core protocol.
Our contracts have been audited by 3 different teams.


This is our "factory" contract (Unlock.sol) and has several roles.
  • Deploying Locks: Locks are deployed through the Unlock smart contract. This is important because the Locks will actually invoke the Unlock smart contract when keys are sold and the Unlock smart contract will check that the invoking lock has been deployed through it.
  • Keeping Track of the Unlock Discount Tokens. Unlock Discount Tokens are ERC20 tokens that implement the Unlock network referral program to let users of the protocol govern it. The Discount Tokens are granted when keys (NFTs) are purchased.
You should not need to deploy an Unlock contract yourself. Here are the addresses of contracts deployed on respective networks and you can call them directly using the block explorer.

Production networks:

Test networks:

Please, refer to the Unlock contract documentation for more details.

Lock Contract

This is the contract (PublicLock.sol) which users can configure and deploy to restrict access to resources, such as a blog, a subset of software features, or an event.
Each lock is a standalone contract with its own deployment, address, and storage. As per v9, locks can be entirely untethered and still fully functional even without access to the main Unlock contract.
  • Each lock contract is an ERC-721 compliant contract capable of creating and managing NFTs (non-fungible tokens we call "Keys"), as well as restricting access based on the user's possession (or lack of) one of these keys.
  • Keys for one lock are valid only for the lock which created them.
  • A given user may own only 1 key (NFT) at a time.
You can call and inspect the Lock contracts directly using the block explorers as well.

Production Networks

Test Networks

Please, refer to the Lock contract documentation for more details.


We're making use of upgradeable contracts via openzeppelin 's approach which leverages proxy contracts. What does this mean for users? First, when interacting with the Unlock contract (via the dashboard, etherscan, from another smart contract, or from a new UI you build) you will always be interacting with the most recent version of the contract. Under the hood, the contract you interact with is actually a proxy contract, so its address never changes. When we upgrade to a new version of Unlock, the proxy is also updated to delegate all calls to the new version of Unlock.

What about Locks?

Good question. Until version 10, Deployed locks are immutable. That is, while they can be re-configured, disabled, or destroyed by their owner, they will otherwise remain unchanged on their EVM network for as long as it persists. Nobody else can modify a lock you deployed but you, unless you choose to allow this. After an upgrade of Unlock, all new locks deployed moving forward will be of the new version, and may support new features and/or improved usability.
Starting with version 10, we are introducing upgradable locks. These locks are still deployed and owned by their creator (who is the sole lock manager initially), but they can later be upgraded to support new features introduced by the protocol, by their lock managers only. The upgrades are optional and can only be triggered by the lock managers themselves.

Npm Modules

Each version of the contracts is available via the @unlock-protocol/contracts module. Among other things, this module includes the compiled artifacts for both Unlock.sol and PublicLock.sol, as well as the interfaces for our contracts, a changelog and, the commit hash for this version. This allows us (or anyone) to support multiple versions when building on Unlock!

How to use

yarn add @unlock-protocol/contracts
With javascript
// get latest
import unlock from '@unlock-protocol/contracts/abis/Unlock'
// get previous versions
import unlock from '@unlock-protocol/contracts/abis/UnlockV0'
import { UnlockV0 } from '@unlock-protocol/contracts'
With Solidity
import "@unlock-protocol/contracts/dist/Unlock/UnlockV0.sol";


Other standards which Unlock adheres to are:
  • erc-1167 - Minimal Proxy Contract
  • erc-165 - Standard Interface Detection
  • erc-712 - Ethereum typed structured data hashing and signing (in progress)
  • erc-20 - Token Standard (in progress)