Skip to content
Verified contractPartial

DMap3

Address0x06f9bd03385757fedfa650e5e3012fc3f02a526a
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.5.10

 

Same code

3 more contracts

 

Details

Compiler
solc 0.5.10+commit.5a6ea5b1
Language
solidity
Optimization
Yes, 200 runs
EVM version
petersburg
License
Not stated
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
8,201,141
Creation transaction
0x483309f11f…a0f1f09665

DMap3.sol

pragma solidity ^0.5.10;

contract ValueProvider {
    function getValue(bytes32 key) public view returns (bytes32 value);
    event ValueUpdate(bytes32 indexed key, bytes32 indexed value);
}

contract DMap3 is ValueProvider {
    address                   public allocator;
    mapping(bytes32=>bool)    public locked;
    mapping(bytes32=>bytes32) public values;
    mapping(bytes32=>address) public owners;
    mapping(bytes32=>address) public offered;

    event ValueUpdate( bytes32 indexed key
                     , bytes32 indexed value );
    event ValueLocked( bytes32 indexed key
                     , bytes32 indexed value );
    event OwnerUpdate( bytes32 indexed key
                     , address indexed oldOwner
                     , address indexed newOwner );

    constructor() public {
        allocator = msg.sender;
    }
    function setAllocator(address newAllocator) public {
        assert(msg.sender == allocator);
        allocator = newAllocator;
    }
    function allocate(bytes32 key, address owner) public {
        assert( ! locked[key]);
        assert(msg.sender == allocator);
        assert(owner != address(0));
        assert(owners[key] != address(0));
        owners[key] = owner;
        emit OwnerUpdate(key, address(this), owner);
    }
    function lock(bytes32 key) public {
        assert( ! locked[key]); // one lock event
        assert(msg.sender == owners[key]);
        locked[key] = true;
        owners[key] = address(0);
        offered[key] = address(0);
        emit ValueLocked(key, values[key]);
    }
    function offer(bytes32 key, address to) public {
        assert( ! locked[key]);
        assert(msg.sender == owners[key]);
        offered[key] = to;
    }
    function accept(bytes32 key) public {
        assert( ! locked[key]);
        assert(msg.sender == offered[key]);
        emit OwnerUpdate(key, owners[key], offered[key]);
        owners[key] = msg.sender;
        offered[key] = address(0);
    }
    function setValue(bytes32 key, bytes32 value) public {
        assert( ! locked[key]);
        assert(msg.sender == owners[key]);
        values[key] = value;
        emit ValueUpdate(key, value);
    }
    function getValue(bytes32 key) public view returns (bytes32) {
        return values[key];
    }
}
Compiler settingsShow
{
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "petersburg",
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.