Solidity API
IUnlockV11
initialize
function initialize(address _unlockOwner) external
initializeProxyAdmin
function initializeProxyAdmin() external
deploy a ProxyAdmin contract used to upgrade locks
proxyAdminAddress
function proxyAdminAddress() external view returns (address)
Retrieve the contract address of the proxy admin that manages the locks
Return Values
Name | Type | Description |
---|---|---|
[0] | address | the address of the ProxyAdmin instance |
createLock
function createLock(uint256 _expirationDuration, address _tokenAddress, uint256 _keyPrice, uint256 _maxNumberOfKeys, string _lockName, bytes12) external returns (address)
Create lock (legacy) This deploys a lock for a creator. It also keeps track of the deployed lock.
internally call createUpgradeableLock
Parameters
Name | Type | Description |
---|---|---|
_expirationDuration | uint256 | the duration of the lock (pass 0 for unlimited duration) |
_tokenAddress | address | set to the ERC20 token address, or 0 for ETH. |
_keyPrice | uint256 | the price of each key |
_maxNumberOfKeys | uint256 | the maximum nimbers of keys to be edited |
_lockName | string | the name of the lock param _salt [deprec] -- kept only for backwards copatibility This may be implemented as a sequence ID or with RNG. It's used with create2 to know the lock's address before the transaction is mined. |
bytes12 |
createUpgradeableLock
function createUpgradeableLock(bytes data) external returns (address)
Create lock (default) This deploys a lock for a creator. It also keeps track of the deployed lock.
this call is passed as encoded function - for instance: bytes memory data = abi.encodeWithSignature( 'initialize(address,uint256,address,uint256,uint256,string)', msg.sender, _expirationDuration, _tokenAddress, _keyPrice, _maxNumberOfKeys, _lockName );
Parameters
Name | Type | Description |
---|---|---|
data | bytes | bytes containing the call to initialize the lock template |
Return Values
Name | Type | Description |
---|---|---|
[0] | address | address of the create lock |
createUpgradeableLockAtVersion
function createUpgradeableLockAtVersion(bytes data, uint16 _lockVersion) external returns (address)
Create an upgradeable lock using a specific PublicLock version
Parameters
Name | Type | Description |
---|---|---|
data | bytes | bytes containing the call to initialize the lock template (refer to createUpgradeableLock for more details) |
_lockVersion | uint16 | the version of the lock to use |
upgradeLock
function upgradeLock(address payable lockAddress, uint16 version) external returns (address)
Upgrade a lock to a specific version
only available for publicLockVersion > 10 (proxyAdmin /required)
Parameters
Name | Type | Description |
---|---|---|
lockAddress | address payable | the existing lock address |
version | uint16 | the version number you are targeting Likely implemented with OpenZeppelin TransparentProxy contract |
recordKeyPurchase
function recordKeyPurchase(uint256 _value, address _referrer) external
This function keeps track of the added GDP, as well as grants of discount tokens to the referrer, if applicable. The number of discount tokens granted is based on the value of the referal, the current growth rate and the lock's discount token distribution rate This function is invoked by a previously deployed lock only.
recordConsumedDiscount
function recordConsumedDiscount(uint256 _discount, uint256 _tokens) external view
[DEPRECATED] Call to this function has been removed from PublicLock > v9.
[DEPRECATED] Kept for backwards compatibility This function will keep track of consumed discounts by a given user. It will also grant discount tokens to the creator who is granting the discount based on the amount of discount and compensation rate. This function is invoked by a previously deployed lock only.
computeAvailableDiscountFor
function computeAvailableDiscountFor(address _purchaser, uint256 _keyPrice) external pure returns (uint256 discount, uint256 tokens)
[DEPRECATED] Call to this function has been removed from PublicLock > v9.
[DEPRECATED] Kept for backwards compatibility This function returns the discount available for a user, when purchasing a a key from a lock. This does not modify the state. It returns both the discount and the number of tokens consumed to grant that discount.
globalBaseTokenURI
function globalBaseTokenURI() external view returns (string)
getGlobalBaseTokenURI
function getGlobalBaseTokenURI() external view returns (string)
Redundant with globalBaseTokenURI() for backwards compatibility with v3 & v4 locks.
globalTokenSymbol
function globalTokenSymbol() external view returns (string)
chainId
function chainId() external view returns (uint256)
getGlobalTokenSymbol
function getGlobalTokenSymbol() external view returns (string)
Redundant with globalTokenSymbol() for backwards compatibility with v3 & v4 locks.
configUnlock
function configUnlock(address _udt, address _weth, uint256 _estimatedGasForPurchase, string _symbol, string _URI, uint256 _chainId) external
Allows the owner to update configuration variables
addLockTemplate
function addLockTemplate(address impl, uint16 version) external
Add a PublicLock template to be used for future calls to createLock
.
This is used to upgrade conytract per version number
publicLockImpls
function publicLockImpls(uint16 _version) external view returns (address)
Match lock templates addresses with version numbers
Parameters
Name | Type | Description |
---|---|---|
_version | uint16 | the number of the version of the template |
Return Values
Name | Type | Description |
---|---|---|
[0] | address | address of the lock templates |
publicLockVersions
function publicLockVersions(address _impl) external view returns (uint16)
Match version numbers with lock templates addresses
Parameters
Name | Type | Description |
---|---|---|
_impl | address | the address of the deployed template contract (PublicLock) |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint16 | number of the version corresponding to this address |
publicLockLatestVersion
function publicLockLatestVersion() external view returns (uint16)
Retrieve the latest existing lock template version
Return Values
Name | Type | Description |
---|---|---|
[0] | uint16 | the version number of the latest template (used to deploy contracts) |
setLockTemplate
function setLockTemplate(address payable _publicLockAddress) external
Upgrade the PublicLock template used for future calls to createLock
.
This will initialize the template and revokeOwnership.
resetTrackedValue
function resetTrackedValue(uint256 _grossNetworkProduct, uint256 _totalDiscountGranted) external
grossNetworkProduct
function grossNetworkProduct() external view returns (uint256)
totalDiscountGranted
function totalDiscountGranted() external view returns (uint256)
locks
function locks(address) external view returns (bool deployed, uint256 totalSales, uint256 yieldedDiscountTokens)
publicLockAddress
function publicLockAddress() external view returns (address)
uniswapOracles
function uniswapOracles(address) external view returns (address)
weth
function weth() external view returns (address)
udt
function udt() external view returns (address)
estimatedGasForPurchase
function estimatedGasForPurchase() external view returns (uint256)
networkBaseFee
function networkBaseFee() external view returns (uint256)
Helper to get the network mining basefee as introduced in EIP-1559
this helper can be wrapped in try/catch statement to avoid revert in networks where EIP-1559 is not implemented
unlockVersion
function unlockVersion() external pure returns (uint16)
setOracle
function setOracle(address _tokenAddress, address _oracleAddress) external
allows the owner to set the oracle address to use for value conversions setting the _oracleAddress to address(0) removes support for the token
This will also call update to ensure at least one datapoint has been recorded.
__initializeOwnable
function __initializeOwnable(address sender) external
Initialize the Ownable contract, granting contract ownership to the specified sender
isOwner
function isOwner() external view returns (bool)
Returns true if the caller is the current owner.
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | bool True of the caller is the owner |
owner
function owner() external view returns (address)
Returns the address of the current owner.
renounceOwnership
function renounceOwnership() external
_Leaves the contract without owner. It will not be possible to call
onlyOwner
functions anymore. Can only be called by the current owner.
NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner._
transferOwnership
function transferOwnership(address newOwner) external
Transfers ownership of the contract to a new account (newOwner
).
Can only be called by the current owner.