Address Contract Partially Verified
Address
0xDE1e8A7E184Babd9F0E3af18f40634e9Ed6F0905
Balance
0 ETH
Nonce
1
Code Size
3707 bytes
Creator
0xce0042B8...cf9f at tx 0x718311bb...faf25f
Indexed Transactions
0
Contract Bytecode
3707 bytes
0x608060405234801561001057600080fd5b50600436106100725760003560e01c80634cd443b9116100505780634cd443b9146100c9578063ce2f6ef5146100dc578063e0653453146100ef57600080fd5b80631e61206a1461007757806332aeba931461008c57806343953e911461009f575b600080fd5b61008a610085366004610913565b61013e565b005b61008a61009a366004610a0c565b61044a565b6100b26100ad366004610a6d565b610554565b6040516100c0929190610b01565b60405180910390f35b61008a6100d7366004610b23565b61063a565b61008a6100ea366004610b60565b610708565b61012e6100fd366004610bb7565b6002602090815260009283526040909220815180830184018051928152908401929093019190912091525460ff1681565b60405190151581526020016100c0565b33600090815260208190526040808220905161015b908690610c29565b90815260200160405180910390206040516020016101799190610c86565b6040516020818303038152906040528051906020012090506000836040516020016101a49190610ca0565b60405160208183030381529060405280519060200120905080821480156101f85750336000908152600160205260409081902090518491906101e7908890610c29565b908152602001604051809103902054145b1561023c5730846040517f1dd0547d000000000000000000000000000000000000000000000000000000008152600401610233929190610cb3565b60405180910390fd5b336000818152602081905260409081902090517fbbfaebc0e35c81daa40cc3d21316def67a6456e2b1c91d5f8ad1de9b721de37b91889161027e908390610c29565b90815260405190819003602001812061029b929189908990610d01565b60405180910390a2336000908152602081905260409081902090516102c1908790610c29565b908152602001604051809103902060006102db91906107f0565b6000805b855181101561041057818682815181106102fb576102fb610d4c565b6020026020010151600001511161036e573086828151811061031f5761031f610d4c565b6020908102919091010151516040517ff3458b170000000000000000000000000000000000000000000000000000000081526001600160a01b0390921660048301526024820152604401610233565b3360009081526020819052604090819020905161038c908990610c29565b90815260200160405180910390208682815181106103ac576103ac610d4c565b602090810291909101810151825460018181018555600094855293839020825160029092020190815591015191015585518690829081106103ef576103ef610d4c565b6020026020010151600001519150808061040890610d62565b9150506102df565b5033600090815260016020526040908190209051859190610432908990610c29565b90815260405190819003602001902055505050505050565b3360009081526001602052604090819020905182919061046b908590610c29565b908152602001604051809103902054036104ba576040517f5fd7432600000000000000000000000000000000000000000000000000000000815230600482015260248101829052604401610233565b336000908152600160205260409081902090518291906104db908590610c29565b908152604080519182900360209081018320939093553360008181529384905292207fa32227b2030924096f77f3098d1a4bd08f954c5c03672df745323d1c782b959b9185919061052d908390610c29565b90815260405190819003602001812061054892918690610d89565b60405180910390a25050565b6001600160a01b0381166000908152602081905260408082209051606092919061057f908690610c29565b9081526020016040518091039020805480602002602001604051908101604052809291908181526020016000905b828210156105f3578382906000526020600020906002020160405180604001604052908160008201548152602001600182015481525050815260200190600101906105ad565b5050506001600160a01b0385166000908152600160205260409081902090519294509161062291508690610c29565b90815260200160405180910390205490509250929050565b336000818152602081905260409081902090517fbd98d3f04eeb1303945395a3f2e81f61bd3850805868eb03afa6f491295ed8d491849161067c908390610c29565b9081526040519081900360200181206106959291610dbf565b60405180910390a2336000908152602081905260409081902090516106bb908390610c29565b908152602001604051809103902060006106d591906107f0565b336000908152600160205260409081902090516106f3908390610c29565b90815260200160405180910390206000905550565b33600090815260026020526040908190209051821515919061072b908590610c29565b9081526040519081900360200190205460ff1615150361077d573082826040517f61224be100000000000000000000000000000000000000000000000000000000815260040161023393929190610ded565b3360009081526002602052604090819020905182919061079e908590610c29565b908152604051908190036020018120805492151560ff199093169290921790915533907f7e87855f33013e8d674833df5eab0f65055b248901ff9059f5482da853f76347906105489085908590610e21565b50805460008255600202906000526020600020908101906108119190610814565b50565b5b8082111561082f5760008082556001820155600201610815565b5090565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff8111828210171561086c5761086c610833565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561089b5761089b610833565b604052919050565b600082601f8301126108b457600080fd5b813567ffffffffffffffff8111156108ce576108ce610833565b6108e1601f8201601f1916602001610872565b8181528460208386010111156108f657600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561092857600080fd5b833567ffffffffffffffff8082111561094057600080fd5b61094c878388016108a3565b945060209150818601358181111561096357600080fd5b8601601f8101881361097457600080fd5b80358281111561098657610986610833565b610994848260051b01610872565b818152848101935060069190911b8201840190898211156109b457600080fd5b918401915b818310156109f7576040838b0312156109d25760008081fd5b6109da610849565b8335815285840135868201528452928401926040909201916109b9565b96999698505050506040949094013593505050565b60008060408385031215610a1f57600080fd5b823567ffffffffffffffff811115610a3657600080fd5b610a42858286016108a3565b95602094909401359450505050565b80356001600160a01b0381168114610a6857600080fd5b919050565b60008060408385031215610a8057600080fd5b823567ffffffffffffffff811115610a9757600080fd5b610aa3858286016108a3565b925050610ab260208401610a51565b90509250929050565b600081518084526020808501945080840160005b83811015610af6578151805188528301518388015260409096019590820190600101610acf565b509495945050505050565b604081526000610b146040830185610abb565b90508260208301529392505050565b600060208284031215610b3557600080fd5b813567ffffffffffffffff811115610b4c57600080fd5b610b58848285016108a3565b949350505050565b60008060408385031215610b7357600080fd5b823567ffffffffffffffff811115610b8a57600080fd5b610b96858286016108a3565b92505060208301358015158114610bac57600080fd5b809150509250929050565b60008060408385031215610bca57600080fd5b610bd383610a51565b9150602083013567ffffffffffffffff811115610bef57600080fd5b610bfb858286016108a3565b9150509250929050565b60005b83811015610c20578181015183820152602001610c08565b50506000910152565b60008251610c3b818460208701610c05565b9190910192915050565b6000815480845260208085019450836000528060002060005b83811015610af657815487526001808301548489015260409097019660029092019101610c5e565b602081526000610c996020830184610c45565b9392505050565b602081526000610c996020830184610abb565b6001600160a01b0383168152604060208201526000610b586040830184610abb565b60008151808452610ced816020860160208601610c05565b601f01601f19169290920160200192915050565b608081526000610d146080830187610cd5565b8281036020840152610d268187610c45565b90508281036040840152610d3a8186610abb565b91505082606083015295945050505050565b634e487b7160e01b600052603260045260246000fd5b600060018201610d8257634e487b7160e01b600052601160045260246000fd5b5060010190565b606081526000610d9c6060830186610cd5565b8281036020840152610dae8186610c45565b915050826040830152949350505050565b604081526000610dd26040830185610cd5565b8281036020840152610de48185610c45565b95945050505050565b6001600160a01b0384168152606060208201526000610e0f6060830185610cd5565b90508215156040830152949350505050565b604081526000610e346040830185610cd5565b90508215156020830152939250505056fea264697066735822122098025ec4ca8ea1a643c5751b047f9d7b1df4bcad4037893f48afa47d79d39a2b64736f6c63430008110033
Verified Source Code Partial Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (1000 runs)
DelegateRegistry.sol 169 lines
/**
*Submitted for verification at gnosisscan.io on 2023-02-14
*/
// SPDX-License-Identifier: LGPL-3.0-only
/*
____ _ _
| _ \ ___| | ___ __ _ __ _| |_ ___
| | | |/ _ \ |/ _ \/ _` |/ _` | __/ _ \
| |_| | __/ | __/ (_| | (_| | || __/
|____/ \___|_|\___|\__, |\__,_|\__\___|
____ _ |___/
| _ \ ___ __ _(_)___| |_ _ __ _ _
| |_) / _ \/ _` | / __| __| '__| | | |
| _ < __/ (_| | \__ \ |_| | | |_| |
|_| \_\___|\__, |_|___/\__|_| \__, |
|___/ |___/
Made with ❤️ by Gnosis Guild
*/
pragma solidity ^0.8.17;
struct Delegation {
bytes32 delegate;
uint256 ratio;
}
contract DelegateRegistry {
// Mapping from account address => context => array of user-defined delegations.
mapping(address => mapping(string => Delegation[])) private delegations;
// Mapping from account address => context => user-defined delegation expiration dates.
mapping(address => mapping(string => uint256)) private expirationTimestamps;
// Mapping from delegate address => context => opt-out status
mapping(address => mapping(string => bool)) public optouts;
event ExpirationUpdated(
address indexed account,
string context,
Delegation[] delegation,
uint256 expirationTimestamp
);
event DelegationUpdated(
address indexed account,
string context,
Delegation[] previousDelegation,
Delegation[] delegation,
uint256 expirationTimestamp
);
event DelegationCleared(
address indexed account,
string context,
Delegation[] delegatesCleared
);
event OptOutStatusSet(
address indexed delegate,
string context,
bool optout
);
/// @dev Delegation is already set to this value.
error DuplicateDelegation(address emitter, Delegation[] delegation);
/// @dev Duplicate expiration timestamp.
error DuplicateTimestamp(address emitter, uint256 expirationTimestamp);
/// @dev Given delegate is 0 or a duplicate.
error InvalidDelegateID(address emiter, bytes32 delegate);
/// @dev Duplicate opt-out status
error DuplicateOptoutStatus(address emitter, string context, bool optout);
/// @dev Sets a delegate for the msg.sender and a specific context.
/// @param context ID of the context in which delegation should be set.
/// @param delegation Array of delegations. Must be sorted in numerical order, from smallest to largets.
/// @param expirationTimestamp Unix timestamp for at which this delegation should expire.
/// @notice setDelegation() will overrite the user's previous delegation for the given context.
function setDelegation(
string memory context,
Delegation[] memory delegation,
uint256 expirationTimestamp
) public {
bytes32 currentDelegationHash = keccak256(
abi.encode(delegations[msg.sender][context])
);
bytes32 delegationHash = keccak256(abi.encode(delegation));
if (
currentDelegationHash == delegationHash &&
expirationTimestamps[msg.sender][context] == expirationTimestamp
) revert DuplicateDelegation(address(this), delegation);
emit DelegationUpdated(
msg.sender,
context,
delegations[msg.sender][context],
delegation,
expirationTimestamp
);
delete delegations[msg.sender][context];
// Update delegation mapping
bytes32 previous;
for (uint i = 0; i < delegation.length; i++) {
if (delegation[i].delegate <= previous)
revert InvalidDelegateID(address(this), delegation[i].delegate);
delegations[msg.sender][context].push(delegation[i]);
previous = delegation[i].delegate;
}
// set delegation expiration
expirationTimestamps[msg.sender][context] = expirationTimestamp;
}
/// @dev Clears msg.sender's delegation in a given context.
/// @param context ID of the context in which delegation should be cleared.
function clearDelegation(string memory context) public {
emit DelegationCleared(
msg.sender,
context,
delegations[msg.sender][context]
);
delete delegations[msg.sender][context];
delete expirationTimestamps[msg.sender][context];
}
/// @dev Sets msg.senders expiration timestamp for a given context.
/// @param context ID of the context in which the timestamp should be set.
/// @param expirationTimestamp Unix timestamp at which the delegations in this context should expire.
function setExpiration(
string memory context,
uint256 expirationTimestamp
) public {
if (expirationTimestamps[msg.sender][context] == expirationTimestamp)
revert DuplicateTimestamp(address(this), expirationTimestamp);
expirationTimestamps[msg.sender][context] = expirationTimestamp;
emit ExpirationUpdated(
msg.sender,
context,
delegations[msg.sender][context],
expirationTimestamp
);
}
/// @dev Sets an "opt-out" status, allowing users to signal a desire to opt-out of receiving delegations.
/// @param context Context in which the user wishes to set their opt-out status.
/// @param _optout opt-out status.
function optout(string memory context, bool _optout) public {
if (optouts[msg.sender][context] == _optout)
revert DuplicateOptoutStatus(address(this), context, _optout);
optouts[msg.sender][context] = _optout;
emit OptOutStatusSet(msg.sender, context, _optout);
}
/// @dev Returns the delegation details for a given account in a given context.
/// @param context ID of the context to query.
/// @param account Address of the account to query.
/// @return delegation Array of delegations.
/// @return expirationTimestamp Unix timestamp at which this delegation will expire.
function getDelegation(
string memory context,
address account
)
public
view
returns (Delegation[] memory delegation, uint256 expirationTimestamp)
{
delegation = delegations[account][context];
expirationTimestamp = expirationTimestamps[account][context];
}
}
Read Contract
getDelegation 0x43953e91 → tuple[], uint256
optouts 0xe0653453 → bool
Write Contract 4 functions
These functions modify contract state and require a wallet transaction to execute.
clearDelegation 0x4cd443b9
string context
optout 0xce2f6ef5
string context
bool _optout
setDelegation 0x211b3a46
string context
tuple[] delegation
uint256 expirationTimestamp
setExpiration 0x32aeba93
string context
uint256 expirationTimestamp
Recent Transactions
No transactions found for this address