IDelegateRegistry
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
Name | Type | Description |
---|---|---|
data | bytes[] | The encoded function data for each of the calls to make to this contract |
Returns
Name | Type | Description |
---|---|---|
results | bytes[] | 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
Name | Type | Description |
---|---|---|
to | address | The address to act as delegate |
rights | bytes32 | Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights |
enable | bool | Whether to enable or disable this delegation, true delegates and false revokes |
Returns
Name | Type | Description |
---|---|---|
delegationHash | bytes32 | The 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
Name | Type | Description |
---|---|---|
to | address | The address to act as delegate |
contract_ | address | The contract whose rights are being delegated |
rights | bytes32 | Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights |
enable | bool | Whether to enable or disable this delegation, true delegates and false revokes |
Returns
Name | Type | Description |
---|---|---|
delegationHash | bytes32 | The 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
Name | Type | Description |
---|---|---|
to | address | The address to act as delegate |
contract_ | address | The contract whose rights are being delegated |
tokenId | uint256 | The token id to delegate |
rights | bytes32 | Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights |
enable | bool | Whether to enable or disable this delegation, true delegates and false revokes |
Returns
Name | Type | Description |
---|---|---|
delegationHash | bytes32 | The 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
Name | Type | Description |
---|---|---|
to | address | The address to act as delegate |
contract_ | address | The address for the fungible token contract |
rights | bytes32 | Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights |
amount | uint256 | The amount to delegate, > 0 delegates and 0 revokes |
Returns
Name | Type | Description |
---|---|---|
delegationHash | bytes32 | The 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
Name | Type | Description |
---|---|---|
to | address | The address to act as delegate |
contract_ | address | The address of the contract that holds the token |
tokenId | uint256 | The token id to delegate |
rights | bytes32 | Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights |
amount | uint256 | The amount of that token id to delegate, > 0 delegates and 0 revokes |
Returns
Name | Type | Description |
---|---|---|
delegationHash | bytes32 | The 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
Name | Type | Description |
---|---|---|
to | address | The potential delegate address |
from | address | The potential address who delegated rights |
rights | bytes32 | Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | valid 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
Name | Type | Description |
---|---|---|
to | address | The delegated address to check |
from | address | The cold wallet who issued the delegation |
contract_ | address | The specific contract address being checked |
rights | bytes32 | Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | valid 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
Name | Type | Description |
---|---|---|
to | address | The delegated address to check |
from | address | The wallet that issued the delegation |
contract_ | address | The specific contract address being checked |
tokenId | uint256 | The token id for the token to delegating |
rights | bytes32 | Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | valid 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
Name | Type | Description |
---|---|---|
to | address | The delegated address to check |
from | address | The cold wallet who issued the delegation |
contract_ | address | The address of the token contract |
rights | bytes32 | Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | balance 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
Name | Type | Description |
---|---|---|
to | address | The delegated address to check |
from | address | The cold wallet who issued the delegation |
contract_ | address | The address of the token contract |
tokenId | uint256 | The token id to check the delegated amount of |
rights | bytes32 | Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | balance 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
Name | Type | Description |
---|---|---|
to | address | The address to retrieve delegations for |
Returns
Name | Type | Description |
---|---|---|
delegations | Delegation[] | 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
Name | Type | Description |
---|---|---|
from | address | The address to retrieve delegations for |
Returns
Name | Type | Description |
---|---|---|
delegations | Delegation[] | 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
Name | Type | Description |
---|---|---|
to | address | The address to retrieve incoming delegation hashes for |
Returns
Name | Type | Description |
---|---|---|
delegationHashes | bytes32[] | 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
Name | Type | Description |
---|---|---|
from | address | The address to retrieve outgoing delegation hashes for |
Returns
Name | Type | Description |
---|---|---|
delegationHashes | bytes32[] | 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
Name | Type | Description |
---|---|---|
delegationHashes | bytes32[] | is an array of hashes that correspond to delegations |
Returns
Name | Type | Description |
---|---|---|
delegations | Delegation[] | 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
}