ETH Price: $2,062.83 (-0.94%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Deny209299312024-10-09 18:48:35166 days ago1728499715IN
0x9A865A71...89e94E803
0 ETH0.0005822924.90580701
Rely209299302024-10-09 18:48:23166 days ago1728499703IN
0x9A865A71...89e94E803
0 ETH0.0012103925.60059978

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AllocatorRoles

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 200 runs

Other Settings:
london EvmVersion
File 1 of 1 : AllocatorRoles.sol
// SPDX-FileCopyrightText: © 2017 DappHub, LLC
// SPDX-FileCopyrightText: © 2023 Dai Foundation <www.daifoundation.org>
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

pragma solidity ^0.8.16;

contract AllocatorRoles {
    // --- storage variables ---

    mapping(address => uint256) public wards;
    mapping(bytes32 => address) public ilkAdmins;
    mapping(bytes32 => mapping(address => bytes32)) public userRoles;
    mapping(bytes32 => mapping(address => mapping(bytes4 => bytes32))) public actionsRoles;

    // --- events ---

    event Rely(address indexed usr);
    event Deny(address indexed usr);
    event SetIlkAdmin(bytes32 indexed ilk, address user);
    event SetUserRole(bytes32 indexed ilk, address indexed who, uint8 indexed role, bool enabled);
    event SetRoleAction(bytes32 indexed ilk, uint8 indexed role, address indexed target, bytes4 sig, bool enabled);

    // --- modifiers ---

    modifier auth() {
        require(wards[msg.sender] == 1, "AllocatorRoles/not-authorized");
        _;
    }

    modifier ilkAuth(bytes32 ilk) {
        require(ilkAdmins[ilk] == msg.sender, "AllocatorRoles/ilk-not-authorized");
        _;
    }

    // --- constructor ---

    constructor() {
        wards[msg.sender] = 1;
        emit Rely(msg.sender);
    }

    // --- getters ---

    function hasUserRole(bytes32 ilk, address who, uint8 role) external view returns (bool has) {
        has = userRoles[ilk][who] & bytes32(uint256(1) << role) != bytes32(0);
    }

    function hasActionRole(bytes32 ilk, address target, bytes4 sig, uint8 role) external view returns (bool has) {
        has = actionsRoles[ilk][target][sig] & bytes32(uint256(1) << role) != bytes32(0);
    }

    // --- general administration ---

    function rely(address usr) external auth {
        wards[usr] = 1;
        emit Rely(usr);
    }

    function deny(address usr) external auth {
        wards[usr] = 0;
        emit Deny(usr);
    }

    function setIlkAdmin(bytes32 ilk, address usr) external auth {
        ilkAdmins[ilk] = usr;
        emit SetIlkAdmin(ilk, usr);
    }

    // --- ilk administration ---

    function setUserRole(bytes32 ilk, address who, uint8 role, bool enabled) public ilkAuth(ilk) {
        bytes32 mask = bytes32(uint256(1) << role);
        if (enabled) {
            userRoles[ilk][who] |= mask;
        } else {
            userRoles[ilk][who] &= ~mask;
        }
        emit SetUserRole(ilk, who, role, enabled);
    }

    function setRoleAction(bytes32 ilk, uint8 role, address target, bytes4 sig, bool enabled) external ilkAuth(ilk) {
        bytes32 mask = bytes32(uint256(1) << role);
        if (enabled) {
            actionsRoles[ilk][target][sig] |= mask;
        } else {
            actionsRoles[ilk][target][sig] &= ~mask;
        }
        emit SetRoleAction(ilk, role, target, sig, enabled);
    }

    // --- caller ---

    function canCall(bytes32 ilk, address caller, address target, bytes4 sig) external view returns (bool ok) {
        ok = userRoles[ilk][caller] & actionsRoles[ilk][target][sig] != bytes32(0);
    }
}

Settings
{
  "remappings": [
    "ds-test/=lib/dss-test/lib/forge-std/lib/ds-test/src/",
    "dss-interfaces/=lib/dss-test/lib/dss-interfaces/src/",
    "dss-test/=lib/dss-test/src/",
    "forge-std/=lib/dss-test/lib/forge-std/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"usr","type":"address"}],"name":"Deny","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"usr","type":"address"}],"name":"Rely","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"ilk","type":"bytes32"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"SetIlkAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"ilk","type":"bytes32"},{"indexed":true,"internalType":"uint8","name":"role","type":"uint8"},{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bytes4","name":"sig","type":"bytes4"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"SetRoleAction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"ilk","type":"bytes32"},{"indexed":true,"internalType":"address","name":"who","type":"address"},{"indexed":true,"internalType":"uint8","name":"role","type":"uint8"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"SetUserRole","type":"event"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes4","name":"","type":"bytes4"}],"name":"actionsRoles","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"ilk","type":"bytes32"},{"internalType":"address","name":"caller","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"sig","type":"bytes4"}],"name":"canCall","outputs":[{"internalType":"bool","name":"ok","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usr","type":"address"}],"name":"deny","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"ilk","type":"bytes32"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"sig","type":"bytes4"},{"internalType":"uint8","name":"role","type":"uint8"}],"name":"hasActionRole","outputs":[{"internalType":"bool","name":"has","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"ilk","type":"bytes32"},{"internalType":"address","name":"who","type":"address"},{"internalType":"uint8","name":"role","type":"uint8"}],"name":"hasUserRole","outputs":[{"internalType":"bool","name":"has","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"ilkAdmins","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"usr","type":"address"}],"name":"rely","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"ilk","type":"bytes32"},{"internalType":"address","name":"usr","type":"address"}],"name":"setIlkAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"ilk","type":"bytes32"},{"internalType":"uint8","name":"role","type":"uint8"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"sig","type":"bytes4"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setRoleAction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"ilk","type":"bytes32"},{"internalType":"address","name":"who","type":"address"},{"internalType":"uint8","name":"role","type":"uint8"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setUserRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"name":"userRoles","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"wards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b503360008181526020819052604080822060019055517fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a609190a2610990806100596000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c8063a04deb7411610071578063a04deb74146101d7578063bf353dbb14610218578063c6768fb714610246578063cb0c4adc14610277578063daa70103146102a2578063fd58fc34146102b557600080fd5b80631c76b182146100b957806365fae35e146100ce57806366d3e365146100e15780636b53cb40146100f4578063784c0a91146101615780639c52a7f1146101c4575b600080fd5b6100cc6100c73660046106dd565b6102f8565b005b6100cc6100dc36600461073b565b610420565b6100cc6100ef36600461075d565b610494565b61014c6101023660046107aa565b60009384526003602090815260408086206001600160a01b0390951686529381528385206001600160e01b0319909316855291909152912054600160ff9092169190911b16151590565b60405190151581526020015b60405180910390f35b61014c61016f3660046107ec565b60008481526003602090815260408083206001600160a01b03958616845282528083206001600160e01b0319909416835292815282822054958252600281528282209490931681529290915290205416151590565b6100cc6101d236600461073b565b610582565b6102006101e536600461082e565b6001602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610158565b61023861022636600461073b565b60006020819052908152604090205481565b604051908152602001610158565b610238610254366004610847565b600360209081526000938452604080852082529284528284209052825290205481565b610238610285366004610883565b600260209081526000928352604080842090915290825290205481565b6100cc6102b0366004610883565b6105f5565b61014c6102c33660046108af565b60009283526002602090815260408085206001600160a01b039094168552929052912054600160ff9092169190911b16151590565b60008581526001602052604090205485906001600160a01b031633146103395760405162461bcd60e51b8152600401610330906108e2565b60405180910390fd5b600160ff86161b82156103855760008781526003602090815260408083206001600160a01b038916845282528083206001600160e01b03198816845290915290208054821790556103c1565b60008781526003602090815260408083206001600160a01b038916845282528083206001600160e01b0319881684529091529020805482191690555b604080516001600160e01b03198616815284151560208201526001600160a01b0387169160ff8916918a917fe459bcd103dbe8b0e6a5d530849ce830cfccf2828693cd58ae90801afd24fab5910160405180910390a450505050505050565b3360009081526020819052604090205460011461044f5760405162461bcd60e51b815260040161033090610923565b6001600160a01b03811660008181526020819052604080822060019055517fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a609190a250565b60008481526001602052604090205484906001600160a01b031633146104cc5760405162461bcd60e51b8152600401610330906108e2565b600160ff84161b82156105065760008681526002602090815260408083206001600160a01b03891684529091529020805482179055610530565b60008681526002602090815260408083206001600160a01b03891684529091529020805482191690555b8360ff16856001600160a01b0316877f830afcb2e8fda1fe33202a89fe3abf4fc4205f546f29092f144c19e34aab3cea86604051610572911515815260200190565b60405180910390a4505050505050565b336000908152602081905260409020546001146105b15760405162461bcd60e51b815260040161033090610923565b6001600160a01b038116600081815260208190526040808220829055517f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b9190a250565b336000908152602081905260409020546001146106245760405162461bcd60e51b815260040161033090610923565b60008281526001602090815260409182902080546001600160a01b0319166001600160a01b038516908117909155915191825283917f1666ce5bfc515e272162696dc7b908334194bcf1f921f457b5406d2e00ed9e6e910160405180910390a25050565b803560ff8116811461069957600080fd5b919050565b80356001600160a01b038116811461069957600080fd5b80356001600160e01b03198116811461069957600080fd5b8035801515811461069957600080fd5b600080600080600060a086880312156106f557600080fd5b8535945061070560208701610688565b93506107136040870161069e565b9250610721606087016106b5565b915061072f608087016106cd565b90509295509295909350565b60006020828403121561074d57600080fd5b6107568261069e565b9392505050565b6000806000806080858703121561077357600080fd5b843593506107836020860161069e565b925061079160408601610688565b915061079f606086016106cd565b905092959194509250565b600080600080608085870312156107c057600080fd5b843593506107d06020860161069e565b92506107de604086016106b5565b915061079f60608601610688565b6000806000806080858703121561080257600080fd5b843593506108126020860161069e565b92506108206040860161069e565b915061079f606086016106b5565b60006020828403121561084057600080fd5b5035919050565b60008060006060848603121561085c57600080fd5b8335925061086c6020850161069e565b915061087a604085016106b5565b90509250925092565b6000806040838503121561089657600080fd5b823591506108a66020840161069e565b90509250929050565b6000806000606084860312156108c457600080fd5b833592506108d46020850161069e565b915061087a60408501610688565b60208082526021908201527f416c6c6f6361746f72526f6c65732f696c6b2d6e6f742d617574686f72697a656040820152601960fa1b606082015260800190565b6020808252601d908201527f416c6c6f6361746f72526f6c65732f6e6f742d617574686f72697a656400000060408201526060019056fea2646970667358221220e63292639d8b0d89e70de3d2eae385e2b74b8aebaa6ff372230e8e0f38b1b9f664736f6c63430008150033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063a04deb7411610071578063a04deb74146101d7578063bf353dbb14610218578063c6768fb714610246578063cb0c4adc14610277578063daa70103146102a2578063fd58fc34146102b557600080fd5b80631c76b182146100b957806365fae35e146100ce57806366d3e365146100e15780636b53cb40146100f4578063784c0a91146101615780639c52a7f1146101c4575b600080fd5b6100cc6100c73660046106dd565b6102f8565b005b6100cc6100dc36600461073b565b610420565b6100cc6100ef36600461075d565b610494565b61014c6101023660046107aa565b60009384526003602090815260408086206001600160a01b0390951686529381528385206001600160e01b0319909316855291909152912054600160ff9092169190911b16151590565b60405190151581526020015b60405180910390f35b61014c61016f3660046107ec565b60008481526003602090815260408083206001600160a01b03958616845282528083206001600160e01b0319909416835292815282822054958252600281528282209490931681529290915290205416151590565b6100cc6101d236600461073b565b610582565b6102006101e536600461082e565b6001602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610158565b61023861022636600461073b565b60006020819052908152604090205481565b604051908152602001610158565b610238610254366004610847565b600360209081526000938452604080852082529284528284209052825290205481565b610238610285366004610883565b600260209081526000928352604080842090915290825290205481565b6100cc6102b0366004610883565b6105f5565b61014c6102c33660046108af565b60009283526002602090815260408085206001600160a01b039094168552929052912054600160ff9092169190911b16151590565b60008581526001602052604090205485906001600160a01b031633146103395760405162461bcd60e51b8152600401610330906108e2565b60405180910390fd5b600160ff86161b82156103855760008781526003602090815260408083206001600160a01b038916845282528083206001600160e01b03198816845290915290208054821790556103c1565b60008781526003602090815260408083206001600160a01b038916845282528083206001600160e01b0319881684529091529020805482191690555b604080516001600160e01b03198616815284151560208201526001600160a01b0387169160ff8916918a917fe459bcd103dbe8b0e6a5d530849ce830cfccf2828693cd58ae90801afd24fab5910160405180910390a450505050505050565b3360009081526020819052604090205460011461044f5760405162461bcd60e51b815260040161033090610923565b6001600160a01b03811660008181526020819052604080822060019055517fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a609190a250565b60008481526001602052604090205484906001600160a01b031633146104cc5760405162461bcd60e51b8152600401610330906108e2565b600160ff84161b82156105065760008681526002602090815260408083206001600160a01b03891684529091529020805482179055610530565b60008681526002602090815260408083206001600160a01b03891684529091529020805482191690555b8360ff16856001600160a01b0316877f830afcb2e8fda1fe33202a89fe3abf4fc4205f546f29092f144c19e34aab3cea86604051610572911515815260200190565b60405180910390a4505050505050565b336000908152602081905260409020546001146105b15760405162461bcd60e51b815260040161033090610923565b6001600160a01b038116600081815260208190526040808220829055517f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b9190a250565b336000908152602081905260409020546001146106245760405162461bcd60e51b815260040161033090610923565b60008281526001602090815260409182902080546001600160a01b0319166001600160a01b038516908117909155915191825283917f1666ce5bfc515e272162696dc7b908334194bcf1f921f457b5406d2e00ed9e6e910160405180910390a25050565b803560ff8116811461069957600080fd5b919050565b80356001600160a01b038116811461069957600080fd5b80356001600160e01b03198116811461069957600080fd5b8035801515811461069957600080fd5b600080600080600060a086880312156106f557600080fd5b8535945061070560208701610688565b93506107136040870161069e565b9250610721606087016106b5565b915061072f608087016106cd565b90509295509295909350565b60006020828403121561074d57600080fd5b6107568261069e565b9392505050565b6000806000806080858703121561077357600080fd5b843593506107836020860161069e565b925061079160408601610688565b915061079f606086016106cd565b905092959194509250565b600080600080608085870312156107c057600080fd5b843593506107d06020860161069e565b92506107de604086016106b5565b915061079f60608601610688565b6000806000806080858703121561080257600080fd5b843593506108126020860161069e565b92506108206040860161069e565b915061079f606086016106b5565b60006020828403121561084057600080fd5b5035919050565b60008060006060848603121561085c57600080fd5b8335925061086c6020850161069e565b915061087a604085016106b5565b90509250925092565b6000806040838503121561089657600080fd5b823591506108a66020840161069e565b90509250929050565b6000806000606084860312156108c457600080fd5b833592506108d46020850161069e565b915061087a60408501610688565b60208082526021908201527f416c6c6f6361746f72526f6c65732f696c6b2d6e6f742d617574686f72697a656040820152601960fa1b606082015260800190565b6020808252601d908201527f416c6c6f6361746f72526f6c65732f6e6f742d617574686f72697a656400000060408201526060019056fea2646970667358221220e63292639d8b0d89e70de3d2eae385e2b74b8aebaa6ff372230e8e0f38b1b9f664736f6c63430008150033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.