Address io1ca3dqw7s8rcq4d40ky3y0hcgvgnxgc6fm7dn87

Contract Overview

Balance:
0 IOTX

IOTX Value:
$ 0

Token:
Txn Hash
Block
From
To
Value [Txn Fee]
749f1f5c5f1e05aaf000b4456709a31b7cc18d449e912accfb3f70f5c138c038 23941079 2023-12-25 07:20:20 +0000 UTC 5 months ago io1l7440usxyqa9mectrrqkanzpw0yg9q607y5eev  IN    Contract: DevicesRegistry 0 IOTX 0.043165
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DevicesRegistry

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
No with 200 runs

Other Settings:
default evmVersion, None license

Contract Source Code (Solidity)

/** 
 *  SourceUnit: /Users/mz/Codes/my-ws-app/blockchain/contracts/DeviceBinding.sol
*/
            
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}




/** 
 *  SourceUnit: /Users/mz/Codes/my-ws-app/blockchain/contracts/DeviceBinding.sol
*/
            
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

////import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}




/** 
 *  SourceUnit: /Users/mz/Codes/my-ws-app/blockchain/contracts/DeviceBinding.sol
*/
            
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
pragma solidity ^0.8.0;

////import "@openzeppelin/contracts/access/Ownable.sol";

contract DevicesRegistry is Ownable {
    event DeviceRegistered(bytes32 indexed _deviceId);
    event DeviceDeleted(bytes32 indexed _deviceId);
    event DeviceSuspended(bytes32 indexed _deviceId);
    event DeviceActivated(bytes32 indexed _deviceId);

    struct Device {
        bool isRegistered;
        bool isActive;
    }

    mapping(bytes32 => Device) public devices;

    constructor() {}

    modifier onlyRegisteredDevice(bytes32 _deviceId) {
        require(
            devices[_deviceId].isRegistered,
            "Data Source is not registered"
        );
        _;
    }

    modifier onlyUnregisteredDevice(bytes32 _deviceId) {
        require(
            !devices[_deviceId].isRegistered,
            "Data Source already registered"
        );
        _;
    }

    modifier onlyActiveDevice(bytes32 _deviceId) {
        require(devices[_deviceId].isActive, "Data Source is suspended");
        _;
    }

    modifier onlySuspendedDevice(bytes32 _deviceId) {
        require(!devices[_deviceId].isActive, "Data Source is active");
        _;
    }

    function registerDevice(
        bytes32 _deviceId
    ) public onlyOwner onlyUnregisteredDevice(_deviceId) {
        devices[_deviceId] = Device(true, true);
        emit DeviceRegistered(_deviceId);
    }

    function removeDevice(
        bytes32 _deviceId
    ) public onlyOwner onlyRegisteredDevice(_deviceId) {
        delete devices[_deviceId];
        emit DeviceDeleted(_deviceId);
    }

    function suspendDevice(
        bytes32 _deviceId
    )
        public
        onlyOwner
        onlyRegisteredDevice(_deviceId)
        onlyActiveDevice(_deviceId)
    {
        devices[_deviceId].isActive = false;
        emit DeviceSuspended(_deviceId);
    }

    function activateDevice(
        bytes32 _deviceId
    )
        public
        onlyOwner
        onlyRegisteredDevice(_deviceId)
        onlySuspendedDevice(_deviceId)
    {
        devices[_deviceId].isActive = true;
        emit DeviceActivated(_deviceId);
    }

    function isAuthorizedDevice(
        bytes32 _deviceId
    )
        public
        view
        onlyRegisteredDevice(_deviceId)
        onlyActiveDevice(_deviceId)
        returns (bool)
    {
        return true;
    }
}

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_deviceId","type":"bytes32"}],"name":"DeviceActivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_deviceId","type":"bytes32"}],"name":"DeviceDeleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_deviceId","type":"bytes32"}],"name":"DeviceRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_deviceId","type":"bytes32"}],"name":"DeviceSuspended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"bytes32","name":"_deviceId","type":"bytes32"}],"name":"activateDevice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"devices","outputs":[{"internalType":"bool","name":"isRegistered","type":"bool"},{"internalType":"bool","name":"isActive","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_deviceId","type":"bytes32"}],"name":"isAuthorizedDevice","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_deviceId","type":"bytes32"}],"name":"registerDevice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_deviceId","type":"bytes32"}],"name":"removeDevice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_deviceId","type":"bytes32"}],"name":"suspendDevice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Contract Creation Code

608060405234801561001057600080fd5b50600436106100935760003560e01c80637fe93f3a116100665780637fe93f3a146100f6578063882ec35a146101265780638da5cb5b14610142578063c5c400de14610160578063f2fde38b1461019157610093565b80631707873a146100985780631d266200146100b4578063568f9ce1146100d0578063715018a6146100ec575b600080fd5b6100b260048036038101906100ad9190610951565b6101ad565b005b6100ce60048036038101906100c99190610951565b6102de565b005b6100ea60048036038101906100e59190610951565b6103b9565b005b6100f46104ea565b005b610110600480360381019061010b9190610951565b6104fe565b60405161011d9190610999565b60405180910390f35b610140600480360381019061013b9190610951565b6105d3565b005b61014a6106e2565b60405161015791906109f5565b60405180910390f35b61017a60048036038101906101759190610951565b61070b565b604051610188929190610a10565b60405180910390f35b6101ab60048036038101906101a69190610a65565b610749565b005b6101b56107cc565b806001600082815260200190815260200160002060000160009054906101000a900460ff16610219576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161021090610aef565b60405180910390fd5b816001600082815260200190815260200160002060000160019054906101000a900460ff1661027d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161027490610b5b565b60405180910390fd5b60006001600085815260200190815260200160002060000160016101000a81548160ff021916908315150217905550827fa947cf0c91ed1ea7709488fa092d67427ecbacfb336c838cac9a8895fd4d5ee960405160405180910390a2505050565b6102e66107cc565b806001600082815260200190815260200160002060000160009054906101000a900460ff1661034a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161034190610aef565b60405180910390fd5b60016000838152602001908152602001600020600080820160006101000a81549060ff02191690556000820160016101000a81549060ff02191690555050817fa7484d3d596d311cfc3107dcff9228ce00f3d751f41579c18250db44bba095ff60405160405180910390a25050565b6103c16107cc565b806001600082815260200190815260200160002060000160009054906101000a900460ff16610425576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161041c90610aef565b60405180910390fd5b816001600082815260200190815260200160002060000160019054906101000a900460ff161561048a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048190610bc7565b60405180910390fd5b600180600085815260200190815260200160002060000160016101000a81548160ff021916908315150217905550827ff88d777bd2714787b6f9dc2fd4b7ed3f966999c3dd99710e89a7c625921a098660405160405180910390a2505050565b6104f26107cc565b6104fc600061084a565b565b6000816001600082815260200190815260200160002060000160009054906101000a900460ff16610564576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161055b90610aef565b60405180910390fd5b826001600082815260200190815260200160002060000160019054906101000a900460ff166105c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105bf90610b5b565b60405180910390fd5b600192505050919050565b6105db6107cc565b806001600082815260200190815260200160002060000160009054906101000a900460ff1615610640576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161063790610c33565b60405180910390fd5b6040518060400160405280600115158152602001600115158152506001600084815260200190815260200160002060008201518160000160006101000a81548160ff02191690831515021790555060208201518160000160016101000a81548160ff021916908315150217905550905050817f543b01d8fc03bd0f400fb055a7c379dc964b3c478f922bb2e198fa9bccb8e71460405160405180910390a25050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60016020528060005260406000206000915090508060000160009054906101000a900460ff16908060000160019054906101000a900460ff16905082565b6107516107cc565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036107c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b790610cc5565b60405180910390fd5b6107c98161084a565b50565b6107d461090e565b73ffffffffffffffffffffffffffffffffffffffff166107f26106e2565b73ffffffffffffffffffffffffffffffffffffffff1614610848576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161083f90610d31565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b600080fd5b6000819050919050565b61092e8161091b565b811461093957600080fd5b50565b60008135905061094b81610925565b92915050565b60006020828403121561096757610966610916565b5b60006109758482850161093c565b91505092915050565b60008115159050919050565b6109938161097e565b82525050565b60006020820190506109ae600083018461098a565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006109df826109b4565b9050919050565b6109ef816109d4565b82525050565b6000602082019050610a0a60008301846109e6565b92915050565b6000604082019050610a25600083018561098a565b610a32602083018461098a565b9392505050565b610a42816109d4565b8114610a4d57600080fd5b50565b600081359050610a5f81610a39565b92915050565b600060208284031215610a7b57610a7a610916565b5b6000610a8984828501610a50565b91505092915050565b600082825260208201905092915050565b7f4461746120536f75726365206973206e6f742072656769737465726564000000600082015250565b6000610ad9601d83610a92565b9150610ae482610aa3565b602082019050919050565b60006020820190508181036000830152610b0881610acc565b9050919050565b7f4461746120536f757263652069732073757370656e6465640000000000000000600082015250565b6000610b45601883610a92565b9150610b5082610b0f565b602082019050919050565b60006020820190508181036000830152610b7481610b38565b9050919050565b7f4461746120536f75726365206973206163746976650000000000000000000000600082015250565b6000610bb1601583610a92565b9150610bbc82610b7b565b602082019050919050565b60006020820190508181036000830152610be081610ba4565b9050919050565b7f4461746120536f7572636520616c726561647920726567697374657265640000600082015250565b6000610c1d601e83610a92565b9150610c2882610be7565b602082019050919050565b60006020820190508181036000830152610c4c81610c10565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610caf602683610a92565b9150610cba82610c53565b604082019050919050565b60006020820190508181036000830152610cde81610ca2565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610d1b602083610a92565b9150610d2682610ce5565b602082019050919050565b60006020820190508181036000830152610d4a81610d0e565b905091905056fea2646970667358221220e1b1f0c4dc5b3bd26427295d2bc9f7b354417e2258ac6fa960416302edcd7a6e64736f6c63430008110033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.