ETH Price: $3,099.14 (-0.98%)
Gas: 2 Gwei

Contract

0xd38f22243BA0346d59d425E829760F3CE2F5e01b
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
Grant User Role58592622018-06-26 20:00:112154 days ago1530043211IN
0xd38f2224...CE2F5e01b
0 ETH0.000202284
Grant User Role46931522017-12-07 21:59:432355 days ago1512683983IN
0xd38f2224...CE2F5e01b
0 ETH0.0050572100
Add Contract Rol...46930902017-12-07 21:44:472355 days ago1512683087IN
0xd38f2224...CE2F5e01b
0 ETH0.004882100
0x6060604046929252017-12-07 21:05:442355 days ago1512680744IN
 Contract Creation
0 ETH0.1778394100

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xfAF52e46...5a805875E
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
Roles

Compiler Version
v0.4.18+commit.9cf6e910

Optimization Enabled:
No with 200 runs

Other Settings:
default evmVersion
/**
 *Submitted for verification at Etherscan.io on 2018-07-08
*/

// Copyright (c) 2017 Sweetbridge Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

pragma solidity ^0.4.17;

contract OwnedEvents {
    event LogSetOwner (address newOwner);
}


contract Owned is OwnedEvents {
    address public owner;

    function Owned() public {
        owner = msg.sender;
    }

    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }

    function setOwner(address owner_) public onlyOwner {
        owner = owner_;
        LogSetOwner(owner);
    }

}

interface SecuredWithRolesI {
    function hasRole(string roleName) public view returns (bool);
    function senderHasRole(string roleName) public view returns (bool);
    function contractHash() public view returns (bytes32);
}


contract SecuredWithRoles is Owned {
    RolesI public roles;
    bytes32 public contractHash;
    bool public stopped = false;

    function SecuredWithRoles(string contractName_, address roles_) public {
        contractHash = keccak256(contractName_);
        roles = RolesI(roles_);
    }

    modifier stoppable() {
        require(!stopped);
        _;
    }

    modifier onlyRole(string role) {
        require(senderHasRole(role));
        _;
    }

    modifier roleOrOwner(string role) {
        require(msg.sender == owner || senderHasRole(role));
        _;
    }

    // returns true if the role has been defined for the contract
    function hasRole(string roleName) public view returns (bool) {
        return roles.knownRoleNames(contractHash, keccak256(roleName));
    }

    function senderHasRole(string roleName) public view returns (bool) {
        return hasRole(roleName) && roles.roleList(contractHash, keccak256(roleName), msg.sender);
    }

    function stop() public roleOrOwner("stopper") {
        stopped = true;
    }

    function restart() public roleOrOwner("restarter") {
        stopped = false;
    }

    function setRolesContract(address roles_) public onlyOwner {
        // it must not be possible to change the roles contract on the roles contract itself
        require(this != address(roles));
        roles = RolesI(roles_);
    }

}


interface RolesI {
    function knownRoleNames(bytes32 contractHash, bytes32 nameHash) public view returns (bool);
    function roleList(bytes32 contractHash, bytes32 nameHash, address member) public view returns (bool);

    function addContractRole(bytes32 ctrct, string roleName) public;
    function removeContractRole(bytes32 ctrct, string roleName) public;
    function grantUserRole(bytes32 ctrct, string roleName, address user) public;
    function revokeUserRole(bytes32 ctrct, string roleName, address user) public;
}


contract RolesEvents {
    event LogRoleAdded(bytes32 contractHash, string roleName);
    event LogRoleRemoved(bytes32 contractHash, string roleName);
    event LogRoleGranted(bytes32 contractHash, string roleName, address user);
    event LogRoleRevoked(bytes32 contractHash, string roleName, address user);
}


contract Roles is RolesEvents, SecuredWithRoles {
    // mapping is contract -> role -> sender_address -> boolean
    mapping(bytes32 => mapping (bytes32 => mapping (address => bool))) public roleList;
    // the intention is
    mapping (bytes32 => mapping (bytes32 => bool)) public knownRoleNames;

    function Roles() SecuredWithRoles("RolesRepository", this) public {}

    function addContractRole(bytes32 ctrct, string roleName) public roleOrOwner("admin") {
        require(!knownRoleNames[ctrct][keccak256(roleName)]);
        knownRoleNames[ctrct][keccak256(roleName)] = true;
        LogRoleAdded(ctrct, roleName);
    }

    function removeContractRole(bytes32 ctrct, string roleName) public roleOrOwner("admin") {
        require(knownRoleNames[ctrct][keccak256(roleName)]);
        delete knownRoleNames[ctrct][keccak256(roleName)];
        LogRoleRemoved(ctrct, roleName);
    }

    function grantUserRole(bytes32 ctrct, string roleName, address user) public roleOrOwner("admin") {
        require(knownRoleNames[ctrct][keccak256(roleName)]);
        roleList[ctrct][keccak256(roleName)][user] = true;
        LogRoleGranted(ctrct, roleName, user);
    }

    function revokeUserRole(bytes32 ctrct, string roleName, address user) public roleOrOwner("admin") {
        delete roleList[ctrct][keccak256(roleName)][user];
        LogRoleRevoked(ctrct, roleName, user);
    }

}

Contract Security Audit

Contract ABI

[{"constant":false,"inputs":[],"name":"stop","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"roleName","type":"string"}],"name":"senderHasRole","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"restart","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"ctrct","type":"bytes32"},{"name":"roleName","type":"string"},{"name":"user","type":"address"}],"name":"grantUserRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"},{"name":"","type":"bytes32"}],"name":"knownRoleNames","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"roles","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"ctrct","type":"bytes32"},{"name":"roleName","type":"string"}],"name":"addContractRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"stopped","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"},{"name":"","type":"bytes32"},{"name":"","type":"address"}],"name":"roleList","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"contractHash","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"roles_","type":"address"}],"name":"setRolesContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"ctrct","type":"bytes32"},{"name":"roleName","type":"string"},{"name":"user","type":"address"}],"name":"revokeUserRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"roleName","type":"string"}],"name":"hasRole","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"ctrct","type":"bytes32"},{"name":"roleName","type":"string"}],"name":"removeContractRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newOwner","type":"address"}],"name":"LogSetOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"contractHash","type":"bytes32"},{"indexed":false,"name":"roleName","type":"string"}],"name":"LogRoleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"contractHash","type":"bytes32"},{"indexed":false,"name":"roleName","type":"string"}],"name":"LogRoleRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"contractHash","type":"bytes32"},{"indexed":false,"name":"roleName","type":"string"},{"indexed":false,"name":"user","type":"address"}],"name":"LogRoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"contractHash","type":"bytes32"},{"indexed":false,"name":"roleName","type":"string"},{"indexed":false,"name":"user","type":"address"}],"name":"LogRoleRevoked","type":"event"}]

Deployed Bytecode

0x6060604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806307da68f5146100eb57806313af4035146101005780631ca03b8e146101395780631ef3755d146101ae5780632f677038146101c35780633037cea31461024c578063392f5f6414610298578063644443ed146102ed57806375f12b21146103575780638b51ca42146103845780638da5cb5b146103ef578063904c609414610444578063afa202ac14610475578063c2a48c70146104ae578063e3c33a9b14610537578063edd70a75146105ac575b600080fd5b34156100f657600080fd5b6100fe610616565b005b341561010b57600080fd5b610137600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506106d5565b005b341561014457600080fd5b610194600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506107f7565b604051808215151515815260200191505060405180910390f35b34156101b957600080fd5b6101c1610975565b005b34156101ce57600080fd5b61024a60048080356000191690602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a34565b005b341561025757600080fd5b61027e60048080356000191690602001909190803560001916906020019091905050610d56565b604051808215151515815260200191505060405180910390f35b34156102a357600080fd5b6102ab610d85565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156102f857600080fd5b61035560048080356000191690602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610dab565b005b341561036257600080fd5b61036a61105c565b604051808215151515815260200191505060405180910390f35b341561038f57600080fd5b6103d56004808035600019169060200190919080356000191690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061106f565b604051808215151515815260200191505060405180910390f35b34156103fa57600080fd5b6104026110ab565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561044f57600080fd5b6104576110d0565b60405180826000191660001916815260200191505060405180910390f35b341561048057600080fd5b6104ac600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506110d6565b005b34156104b957600080fd5b61053560048080356000191690602001909190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506111d2565b005b341561054257600080fd5b610592600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190505061143c565b604051808215151515815260200191505060405180910390f35b34156105b757600080fd5b61061460048080356000191690602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611575565b005b6040805190810160405280600781526020017f73746f70706572000000000000000000000000000000000000000000000000008152506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806106ac57506106ab816107f7565b5b15156106b757600080fd5b6001600360006101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561073057600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fce241d7ca1f669fee44b6fc00b8eba2df3bb514eed0f6f668f8f89096e81ed946000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b60006108028261143c565b801561096e5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638b51ca42600254846040518082805190602001908083835b602083101515610880578051825260208201915060208101905060208303925061085b565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020336000604051602001526040518463ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180846000191660001916815260200183600019166000191681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019350505050602060405180830381600087803b151561095257600080fd5b6102c65a03f1151561096357600080fd5b505050604051805190505b9050919050565b6040805190810160405280600981526020017f72657374617274657200000000000000000000000000000000000000000000008152506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610a0b5750610a0a816107f7565b5b1515610a1657600080fd5b6000600360006101000a81548160ff02191690831515021790555050565b6040805190810160405280600581526020017f61646d696e0000000000000000000000000000000000000000000000000000008152506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610aca5750610ac9816107f7565b5b1515610ad557600080fd5b6005600085600019166000191681526020019081526020016000206000846040518082805190602001908083835b602083101515610b285780518252602082019150602081019050602083039250610b03565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191660001916815260200190815260200160002060009054906101000a900460ff161515610b8457600080fd5b60016004600086600019166000191681526020019081526020016000206000856040518082805190602001908083835b602083101515610bd95780518252602082019150602081019050602083039250610bb4565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191660001916815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f407d91ed2028325ba84bcf37bade3cde79c3dec599612fa155b042eba4786ddc848484604051808460001916600019168152602001806020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825284818151815260200191508051906020019080838360005b83811015610d14578082015181840152602081019050610cf9565b50505050905090810190601f168015610d415780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a150505050565b60056020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6040805190810160405280600581526020017f61646d696e0000000000000000000000000000000000000000000000000000008152506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610e415750610e40816107f7565b5b1515610e4c57600080fd5b6005600084600019166000191681526020019081526020016000206000836040518082805190602001908083835b602083101515610e9f5780518252602082019150602081019050602083039250610e7a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191660001916815260200190815260200160002060009054906101000a900460ff16151515610efc57600080fd5b60016005600085600019166000191681526020019081526020016000206000846040518082805190602001908083835b602083101515610f515780518252602082019150602081019050602083039250610f2c565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191660001916815260200190815260200160002060006101000a81548160ff0219169083151502179055507f9e854cfefd293f12a3d57e50652dd623ba2880249fd212fa50f89c32a468c26d838360405180836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561101c578082015181840152602081019050611001565b50505050905090810190601f1680156110495780820380516001836020036101000a031916815260200191505b50935050505060405180910390a1505050565b600360009054906101000a900460ff1681565b6004602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60025481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561113157600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161415151561118e57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6040805190810160405280600581526020017f61646d696e0000000000000000000000000000000000000000000000000000008152506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806112685750611267816107f7565b5b151561127357600080fd5b6004600085600019166000191681526020019081526020016000206000846040518082805190602001908083835b6020831015156112c657805182526020820191506020810190506020830392506112a1565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191660001916815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff02191690557f4fbccdb14b9a6cf4300c7a6ec5bf09d09677d23ac78f755e9249094d80cd6e27848484604051808460001916600019168152602001806020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828103825284818151815260200191508051906020019080838360005b838110156113fa5780820151818401526020810190506113df565b50505050905090810190601f1680156114275780820380516001836020036101000a031916815260200191505b5094505050505060405180910390a150505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16633037cea3600254846040518082805190602001908083835b6020831015156114b55780518252602082019150602081019050602083039250611490565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808360001916600019168152602001826000191660001916815260200192505050602060405180830381600087803b151561155357600080fd5b6102c65a03f1151561156457600080fd5b505050604051805190509050919050565b6040805190810160405280600581526020017f61646d696e0000000000000000000000000000000000000000000000000000008152506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061160b575061160a816107f7565b5b151561161657600080fd5b6005600084600019166000191681526020019081526020016000206000836040518082805190602001908083835b6020831015156116695780518252602082019150602081019050602083039250611644565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191660001916815260200190815260200160002060009054906101000a900460ff1615156116c557600080fd5b6005600084600019166000191681526020019081526020016000206000836040518082805190602001908083835b60208310151561171857805182526020820191506020810190506020830392506116f3565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191660001916815260200190815260200160002060006101000a81549060ff02191690557f5c012fe87ecf5fc2e083217e8ce9c77a88d3dd15c311bd6725ebbb9421147902838360405180836000191660001916815260200180602001828103825283818151815260200191508051906020019080838360005b838110156117dc5780820151818401526020810190506117c1565b50505050905090810190601f1680156118095780820380516001836020036101000a031916815260200191505b50935050505060405180910390a15050505600a165627a7a72305820a65ba696d26e69edd717ff2f93700d84f210c8732eb7ef7d2548418e47d0180c0029

Swarm Source

bzzr://a65ba696d26e69edd717ff2f93700d84f210c8732eb7ef7d2548418e47d0180c

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
[ 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.