Skip to content

Deployer

TTUDeployer

Deploys all TokenTable Unlocker core and proxy contracts and handles their initial setup and configuration. To save gas and allow upgrades, every deployed contract is a LibClone or BeaconProxy instance. Avoid deploying TokenTable contracts individually unless you know what you're doing.

This page describes version 2.7.7 (version() returns 2.7.7-TTUDeployer plus the EVM suffix). In 2.7.7 there is no separate deployer interface: the events, errors and functions below are declared on the TTUDeployer contract itself. npm package 2.7.0 instead has the ITTUDeployer interface, implemented by TTUDeployerLite, whose deployTTSuite returns (ITokenTableUnlockerV2, ITTFutureTokenV2).

TTUDeployer uses Solady's Ownable (see Ownership). Its owner is TokenTable, which configures the beacon manager and fee collector and decides on emergency withdraw requests. Anyone can call deployTTSuite.

TTUDeployerInitialized

event TTUDeployerInitialized(address unlockerImpl, address futureTokenImpl, address trackerTokenImpl, address beaconManagerImpl, address feeCollector)

Declared but not emitted by TTUDeployer.

TokenTableSuiteDeployed

event TokenTableSuiteDeployed(address by, string projectId, address unlocker, address futureToken, address trackerToken)

FeeCollectorChanged

event FeeCollectorChanged(address feeCollector)

AlreadyDeployed

error AlreadyDeployed()

0xa6ef0ba1

MissingRequest

error MissingRequest()

0xad78f5dc

Unauthorized

error Unauthorized()

0x82b42900

Inherited from Solady's Ownable. Thrown when a function restricted to the owner, or to Unlockers deployed by this deployer, is called by anyone else.

initialize

function initialize(address owner) external

Sets the owner. ITTCreate3Initializable requires it because TokenTable deploys this contract with CREATE3 and initializes it in the same transaction. Can only be called once.

beaconManager

function beaconManager() external view returns (contract ITTUBeaconManager)

The beacon manager that holds the implementations used for new suites. See TTUBeaconManager.

feeCollector

function feeCollector() external view returns (contract ITTFeeCollector)

The fee collector that Unlockers from this deployer use to charge claim fees. See Fee Collector.

registry

function registry(string projectId) external view returns (address unlocker)

The Unlocker deployed for projectId, or the zero address.

setBeaconManager

function setBeaconManager(address _beaconManager) external

Only callable by the owner.

setFeeCollector

function setFeeCollector(address feeCollector_) external

Only callable by the owner. Emits FeeCollectorChanged.

setEmergencyWithdrawRequestStatus

function setEmergencyWithdrawRequestStatus(bool status) external

Called by an Unlocker to start or cancel an emergency withdraw request.

Only callable by a deployed Unlocker.

Founders do not call this directly: they call setEmergencyWithdrawRequestStatus on their Unlocker, which forwards the request. Canceling a request also clears any approval.

handleEmergencyWithdrawRequest

function handleEmergencyWithdrawRequest(address unlocker, bool approve) external

Approves or rejects the pending emergency withdraw request of unlocker. Only callable by the owner. Reverts with MissingRequest if unlocker has no pending request.

consumeEmergencyWithdrawRequest

function consumeEmergencyWithdrawRequest() external returns (bool approved)

Returns the current approval status and resets the approval to false.

Only callable by a deployed Unlocker.

The Unlocker calls this from withdrawDeposit when withdrawals are disabled. It also clears the request.

Return Values

Name Type Description
approved bool Whether the withdraw request was approved.

emergencyWithdrawApprovals

function emergencyWithdrawApprovals(address unlocker) external view returns (bool approved)

Whether the emergency withdraw request of unlocker is currently approved.

deployTTSuite

function deployTTSuite(address projectToken, address existingFutureToken, string projectId, bool isUpgradeable, bool isTransferable, bool isCancelable, bool isHookable, bool isWithdrawable) external returns (contract ITTUnlocker, contract ITTFutureToken)

Deploys and configures a new TokenTable suite, optionally with an existing NFT as FutureToken.

Emits TokenTableSuiteDeployed. Throws: AlreadyDeployed.

Deploys an Unlocker, a FutureToken (unless existingFutureToken is set) and a TrackerToken, links them, and transfers ownership of the Unlocker to the caller. The TrackerToken address is not returned; read it from the TokenTableSuiteDeployed event.

Parameters

Name Type Description
projectToken address The project token address.
existingFutureToken address An existing NFT to use as the FutureToken (experimental), served by the TTUnlockerExternalFT variant. Pass the zero address to deploy a new FutureToken. The deploy scripts do not register an UnlockerExternalFT beacon.
projectId string Must be unique, or the call reverts.
isUpgradeable bool If false, the deployer creates a Clone instead of a BeaconProxy, so the suite cannot be upgraded.
isTransferable bool Whether FutureTokens are transferable. Ignored if an existing FutureToken is supplied.
isCancelable bool Whether the founder can cancel unlocking schedules in the Unlocker.
isHookable bool Whether the Unlocker can call an external hook.
isWithdrawable bool Whether the founder can withdraw deposited funds.

Return Values

Name Type Description
[0] contract ITTUnlocker The deployed Unlocker.
[1] contract ITTFutureToken The FutureToken used by the Unlocker.

TTUBeaconManager

Holds one UpgradeableBeacon per contract type. When TokenTable upgrades a beacon, every suite deployed with isUpgradeable set to true is upgraded. In npm package 2.7.0 the contract is TTUV2BeaconManager, and beacons are keyed by strings instead of an enum.

enum TTUBeaconType {
    Unlocker,
    FutureToken,
    TrackerToken,
    UnlockerExternalFT
}

beacons

function beacons(TTUBeaconType beaconType) external view returns (UpgradeableBeacon)

Returns the beacon for a contract type.

upgradeCustomBeacon

function upgradeCustomBeacon(TTUBeaconType id, address newImpl) external

Upgrades or creates the beacon for a contract type. Only callable by the owner.

TTUMulticallDeployer

Deploys a suite, deposits tokens and creates presets and actuals in one transaction, then transfers ownership of the Unlocker to the caller.

function multicallDeploy(TTUDeployer deployer, bytes encodedDeployerParams, bytes encodedCreatePresetsParams, bytes encodedCreateActualsParams) external
  • encodedDeployerParams is abi.encode(projectToken, existingFutureToken, projectId, isUpgradeable, isTransferable, isCancelable, isHookable, isWithdrawable, depositAmount). The deposit is pulled from the caller with safeTransferFrom, so the caller must first approve TTUMulticallDeployer for depositAmount.
  • encodedCreatePresetsParams and encodedCreateActualsParams are the ABI-encoded arguments of createPresets and createActuals.

TTUDeployerDuplicate

Identical to TTUDeployer except for its version string (2.7.7-TTUDeployerDuplicate). It is deployed as a second deployer instance.