ConduitController enables deploying and managing new conduits, or contracts that allow registered callers (or open "channels") to transfer approved ERC20/721/1155 tokens on their behalf.
Initialize contract by deploying a conduit and setting the creation code and runtime code hashes as immutable arguments.
createConduit
function createConduit(bytes32 conduitKey, address initialOwner) external returns (address conduit)
Deploy a new conduit using a supplied conduit key and assigning an initial owner for the deployed conduit. Note that the first twenty bytes of the supplied conduit key must match the caller and that a new conduit cannot be created if one has already been deployed using the same conduit key.
Name
Type
Description
conduitKey
bytes32
The conduit key used to deploy the conduit. Note that the first twenty bytes of the conduit key must match the caller of this contract.
initialOwner
address
The initial owner to set for the new conduit.
Name
Type
Description
conduit
address
The address of the newly deployed conduit.
updateChannel
function updateChannel(address conduit, address channel, bool isOpen) external
Open or close a channel on a given conduit, thereby allowing the specified account to execute transfers against that conduit. Extreme care must be taken when updating channels, as malicious or vulnerable channels can transfer any ERC20, ERC721 and ERC1155 tokens where the token holder has granted the conduit approval. Only the owner of the conduit in question may call this function.
Name
Type
Description
conduit
address
The conduit for which to open or close the channel.
channel
address
The channel to open or close on the conduit.
isOpen
bool
A boolean indicating whether to open or close the channel.
transferOwnership
function transferOwnership(address conduit, address newPotentialOwner) external
Initiate conduit ownership transfer by assigning a new potential owner for the given conduit. Once set, the new potential owner may call acceptOwnership to claim ownership of the conduit. Only the owner of the conduit in question may call this function.
Name
Type
Description
conduit
address
The conduit for which to initiate ownership transfer.
newPotentialOwner
address
The new potential owner of the conduit.
cancelOwnershipTransfer
function cancelOwnershipTransfer(address conduit) external
Clear the currently set potential owner, if any, from a conduit. Only the owner of the conduit in question may call this function.
Name
Type
Description
conduit
address
The conduit for which to cancel ownership transfer.
acceptOwnership
function acceptOwnership(address conduit) external
Accept ownership of a supplied conduit. Only accounts that the current owner has set as the new potential owner may call this function.
Name
Type
Description
conduit
address
The conduit for which to accept ownership.
ownerOf
function ownerOf(address conduit) external view returns (address owner)
Retrieve the current owner of a deployed conduit.
Name
Type
Description
conduit
address
The conduit for which to retrieve the associated owner.
Name
Type
Description
owner
address
The owner of the supplied conduit.
getKey
function getKey(address conduit) external view returns (bytes32 conduitKey)
Retrieve the conduit key for a deployed conduit via reverse lookup.
Name
Type
Description
conduit
address
The conduit for which to retrieve the associated conduit key.
Name
Type
Description
conduitKey
bytes32
The conduit key used to deploy the supplied conduit.
getConduit
function getConduit(bytes32 conduitKey) external view returns (address conduit, bool exists)
Derive the conduit associated with a given conduit key and determine whether that conduit exists (i.e. whether it has been deployed).
Name
Type
Description
conduitKey
bytes32
The conduit key used to derive the conduit.
Name
Type
Description
conduit
address
The derived address of the conduit.
exists
bool
A boolean indicating whether the derived conduit has been deployed or not.
getPotentialOwner
function getPotentialOwner(address conduit) external view returns (address potentialOwner)
Retrieve the potential owner, if any, for a given conduit. The current owner may set a new potential owner via transferOwnership and that owner may then accept ownership of the conduit in question via acceptOwnership.
Name
Type
Description
conduit
address
The conduit for which to retrieve the potential owner.
Name
Type
Description
potentialOwner
address
The potential owner, if any, for the conduit.
getChannelStatus
function getChannelStatus(address conduit, address channel) external view returns (bool isOpen)
Retrieve the status (either open or closed) of a given channel on a conduit.
Name
Type
Description
conduit
address
The conduit for which to retrieve the channel status.
channel
address
The channel for which to retrieve the status.
Name
Type
Description
isOpen
bool
The status of the channel on the given conduit.
getTotalChannels
function getTotalChannels(address conduit) external view returns (uint256 totalChannels)
Retrieve the total number of open channels for a given conduit.
Name
Type
Description
conduit
address
The conduit for which to retrieve the total channel count.
Name
Type
Description
totalChannels
uint256
The total number of open channels for the conduit.
getChannel
function getChannel(address conduit, uint256 channelIndex) external view returns (address channel)
Retrieve an open channel at a specific index for a given conduit. Note that the index of a channel can change as a result of other channels being closed on the conduit.
Name
Type
Description
conduit
address
The conduit for which to retrieve the open channel.
channelIndex
uint256
The index of the channel in question.
Name
Type
Description
channel
address
The open channel, if any, at the specified channel index.
getChannels
function getChannels(address conduit) external view returns (address[] channels)
Retrieve all open channels for a given conduit. Note that calling this function for a conduit with many channels will revert with an out-of-gas error.
Name
Type
Description
conduit
address
The conduit for which to retrieve open channels.
Name
Type
Description
channels
address[]
An array of open channels on the given conduit.
getConduitCodeHashes
function getConduitCodeHashes() external view returns (bytes32 creationCodeHash, bytes32 runtimeCodeHash)
Retrieve the conduit creation code and runtime code hashes.
_assertCallerIsConduitOwner
function _assertCallerIsConduitOwner(address conduit) private view
Private view function to revert if the caller is not the owner of a given conduit.
Name
Type
Description
conduit
address
The conduit for which to assert ownership.
_assertConduitExists
function _assertConduitExists(address conduit) private view
Private view function to revert if a given conduit does not exist.