IDelegateRegistry

Git Source

A standalone immutable registry storing delegated permissions from one address to another

Functions

multicall

----------- WRITE -----------

Call multiple functions in the current contract and return the data from all of them if they all succeed

function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);

Parameters

NameTypeDescription
databytes[]The encoded function data for each of the calls to make to this contract

Returns

NameTypeDescription
resultsbytes[]The results from each of the calls passed in via data

delegateAll

Allow the delegate to act on behalf of msg.sender for all contracts

function delegateAll(address to, bytes32 rights, bool enable) external payable returns (bytes32 delegationHash);

Parameters

NameTypeDescription
toaddressThe address to act as delegate
rightsbytes32Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights
enableboolWhether to enable or disable this delegation, true delegates and false revokes

Returns

NameTypeDescription
delegationHashbytes32The unique identifier of the delegation

delegateContract

Allow the delegate to act on behalf of msg.sender for a specific contract

function delegateContract(address to, address contract_, bytes32 rights, bool enable)
    external
    payable
    returns (bytes32 delegationHash);

Parameters

NameTypeDescription
toaddressThe address to act as delegate
contract_addressThe contract whose rights are being delegated
rightsbytes32Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights
enableboolWhether to enable or disable this delegation, true delegates and false revokes

Returns

NameTypeDescription
delegationHashbytes32The unique identifier of the delegation

delegateERC721

Allow the delegate to act on behalf of msg.sender for a specific ERC721 token

function delegateERC721(address to, address contract_, uint256 tokenId, bytes32 rights, bool enable)
    external
    payable
    returns (bytes32 delegationHash);

Parameters

NameTypeDescription
toaddressThe address to act as delegate
contract_addressThe contract whose rights are being delegated
tokenIduint256The token id to delegate
rightsbytes32Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights
enableboolWhether to enable or disable this delegation, true delegates and false revokes

Returns

NameTypeDescription
delegationHashbytes32The unique identifier of the delegation

delegateERC20

Allow the delegate to act on behalf of msg.sender for a specific amount of ERC20 tokens

The actual amount is not encoded in the hash, just the existence of a amount (since it is an upper bound)

function delegateERC20(address to, address contract_, bytes32 rights, uint256 amount)
    external
    payable
    returns (bytes32 delegationHash);

Parameters

NameTypeDescription
toaddressThe address to act as delegate
contract_addressThe address for the fungible token contract
rightsbytes32Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights
amountuint256The amount to delegate, > 0 delegates and 0 revokes

Returns

NameTypeDescription
delegationHashbytes32The unique identifier of the delegation

delegateERC1155

Allow the delegate to act on behalf of msg.sender for a specific amount of ERC1155 tokens

The actual amount is not encoded in the hash, just the existence of a amount (since it is an upper bound)

function delegateERC1155(address to, address contract_, uint256 tokenId, bytes32 rights, uint256 amount)
    external
    payable
    returns (bytes32 delegationHash);

Parameters

NameTypeDescription
toaddressThe address to act as delegate
contract_addressThe address of the contract that holds the token
tokenIduint256The token id to delegate
rightsbytes32Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights
amountuint256The amount of that token id to delegate, > 0 delegates and 0 revokes

Returns

NameTypeDescription
delegationHashbytes32The unique identifier of the delegation

checkDelegateForAll

----------- CHECKS -----------

Check if to is a delegate of from for the entire wallet

function checkDelegateForAll(address to, address from, bytes32 rights) external view returns (bool);

Parameters

NameTypeDescription
toaddressThe potential delegate address
fromaddressThe potential address who delegated rights
rightsbytes32Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only

Returns

NameTypeDescription
<none>boolvalid Whether delegate is granted to act on the from's behalf

checkDelegateForContract

Check if to is a delegate of from for the specified contract_ or the entire wallet

function checkDelegateForContract(address to, address from, address contract_, bytes32 rights)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
toaddressThe delegated address to check
fromaddressThe cold wallet who issued the delegation
contract_addressThe specific contract address being checked
rightsbytes32Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only

Returns

NameTypeDescription
<none>boolvalid Whether delegate is granted to act on from's behalf for entire wallet or that specific contract

checkDelegateForERC721

Check if to is a delegate of from for the specific contract and tokenId, the entire contract_, or the entire wallet

function checkDelegateForERC721(address to, address from, address contract_, uint256 tokenId, bytes32 rights)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
toaddressThe delegated address to check
fromaddressThe wallet that issued the delegation
contract_addressThe specific contract address being checked
tokenIduint256The token id for the token to delegating
rightsbytes32Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only

Returns

NameTypeDescription
<none>boolvalid Whether delegate is granted to act on from's behalf for entire wallet, that contract, or that specific tokenId

checkDelegateForERC20

Returns the amount of ERC20 tokens the delegate is granted rights to act on the behalf of

function checkDelegateForERC20(address to, address from, address contract_, bytes32 rights)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
toaddressThe delegated address to check
fromaddressThe cold wallet who issued the delegation
contract_addressThe address of the token contract
rightsbytes32Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only

Returns

NameTypeDescription
<none>uint256balance The delegated balance, which will be 0 if the delegation does not exist

checkDelegateForERC1155

Returns the amount of a ERC1155 tokens the delegate is granted rights to act on the behalf of

function checkDelegateForERC1155(address to, address from, address contract_, uint256 tokenId, bytes32 rights)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
toaddressThe delegated address to check
fromaddressThe cold wallet who issued the delegation
contract_addressThe address of the token contract
tokenIduint256The token id to check the delegated amount of
rightsbytes32Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only

Returns

NameTypeDescription
<none>uint256balance The delegated balance, which will be 0 if the delegation does not exist

getIncomingDelegations

----------- ENUMERATIONS -----------

Returns all enabled delegations a given delegate has received

function getIncomingDelegations(address to) external view returns (Delegation[] memory delegations);

Parameters

NameTypeDescription
toaddressThe address to retrieve delegations for

Returns

NameTypeDescription
delegationsDelegation[]Array of Delegation structs

getOutgoingDelegations

Returns all enabled delegations an address has given out

function getOutgoingDelegations(address from) external view returns (Delegation[] memory delegations);

Parameters

NameTypeDescription
fromaddressThe address to retrieve delegations for

Returns

NameTypeDescription
delegationsDelegation[]Array of Delegation structs

getIncomingDelegationHashes

Returns all hashes associated with enabled delegations an address has received

function getIncomingDelegationHashes(address to) external view returns (bytes32[] memory delegationHashes);

Parameters

NameTypeDescription
toaddressThe address to retrieve incoming delegation hashes for

Returns

NameTypeDescription
delegationHashesbytes32[]Array of delegation hashes

getOutgoingDelegationHashes

Returns all hashes associated with enabled delegations an address has given out

function getOutgoingDelegationHashes(address from) external view returns (bytes32[] memory delegationHashes);

Parameters

NameTypeDescription
fromaddressThe address to retrieve outgoing delegation hashes for

Returns

NameTypeDescription
delegationHashesbytes32[]Array of delegation hashes

getDelegationsFromHashes

Returns the delegations for a given array of delegation hashes

function getDelegationsFromHashes(bytes32[] calldata delegationHashes)
    external
    view
    returns (Delegation[] memory delegations);

Parameters

NameTypeDescription
delegationHashesbytes32[]is an array of hashes that correspond to delegations

Returns

NameTypeDescription
delegationsDelegation[]Array of Delegation structs, return empty structs for nonexistent or revoked delegations

readSlot

----------- STORAGE ACCESS -----------

Allows external contracts to read arbitrary storage slots

function readSlot(bytes32 location) external view returns (bytes32);

readSlots

Allows external contracts to read an arbitrary array of storage slots

function readSlots(bytes32[] calldata locations) external view returns (bytes32[] memory);

Events

DelegateAll

Emitted when an address delegates or revokes rights for their entire wallet

event DelegateAll(address indexed from, address indexed to, bytes32 rights, bool enable);

DelegateContract

Emitted when an address delegates or revokes rights for a contract address

event DelegateContract(
    address indexed from, address indexed to, address indexed contract_, bytes32 rights, bool enable
);

DelegateERC721

Emitted when an address delegates or revokes rights for an ERC721 tokenId

event DelegateERC721(
    address indexed from, address indexed to, address indexed contract_, uint256 tokenId, bytes32 rights, bool enable
);

DelegateERC20

Emitted when an address delegates or revokes rights for an amount of ERC20 tokens

event DelegateERC20(
    address indexed from, address indexed to, address indexed contract_, bytes32 rights, uint256 amount
);

DelegateERC1155

Emitted when an address delegates or revokes rights for an amount of an ERC1155 tokenId

event DelegateERC1155(
    address indexed from, address indexed to, address indexed contract_, uint256 tokenId, bytes32 rights, uint256 amount
);

Errors

MulticallFailed

Thrown if multicall calldata is malformed

error MulticallFailed();

Structs

Delegation

Struct for returning delegations

struct Delegation {
    DelegationType type_;
    address to;
    address from;
    bytes32 rights;
    address contract_;
    uint256 tokenId;
    uint256 amount;
}

Enums

DelegationType

Delegation type, NONE is used when a delegation does not exist or is revoked

enum DelegationType {
    NONE,
    ALL,
    CONTRACT,
    ERC721,
    ERC20,
    ERC1155
}