Skip to content
Verified contractPartial

DSBalanceDB

Address0xcb6dc6e7bed090c0b22c90eb5c10a7b8b97c9e71
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.1.3

 

Same code

2 more contracts

 

Details

Compiler
solc 0.1.3+commit.028f561d
Language
solidity
Optimization
No
License
Not stated
Match
Partialcreation code: no, runtime code: yes
Verified on Sourcify
Created in block
196,687
Creation transaction
0x0bc28d1d2e…d2915b4f07

DSBalanceDB.sol

// Recovered by EthereumHistory (ethereumhistory.com) -sw
contract DSAuthority {
    function can_call( address caller
                     , address callee
                     , bytes4 sig )
             constant
             returns (bool);
}

contract DSAuth {
    // TODO use enums
    // 0x0:   authority == sender
    // 0x1:   authority._ds_is_authorized( sender, this, sig )
    byte                    public   _ds_auth_mode;
    address                 public   _ds_authority;

    function DSAuth() {
        _ds_authority = msg.sender;
    }

    modifier auth() {
        if( authed() ) {
            _
        }
    }
    function authed() internal returns (bool authorized)
    {
        if ( _ds_auth_mode == 0x0 ) {
            return msg.sender == _ds_authority;
        }
        if (_ds_auth_mode == 0x1) {
            var A = DSAuthority(_ds_authority);
            var can = A.can_call( msg.sender, address(this), msg.sig );
            if( can ) {
                return true;
            }
            return msg.sender == _ds_authority;
        }
        return false;
    }
    function _ds_set_authority( address authority
                              , byte mode )
             auth()
             returns (bool)
    {
        _ds_authority = authority;
        _ds_auth_mode = mode;
        return true;
    }
}

contract DSBalanceDB is DSAuth {
    uint public supply;
    mapping (address => uint) public balances;

    function add_balance(address to, uint amount) auth returns (bool) {
        if (supply + amount < supply) return false;
        balances[to] += amount;
        supply += amount;
        return true;
    }

    function sub_balance(address from, uint amount) auth returns (bool) {
        if (balances[from] < amount) return false;
        balances[from] -= amount;
        supply -= amount;
        return true;
    }

    function direct_transfer(address from, address to, uint amount) returns (bool) {
        if (msg.sender == from || authed()) {
            if (balances[from] < amount) return false;
            balances[from] -= amount;
            balances[to] += amount;
            return true;
        }
        return false;
    }
}

contract DSBalanceDBFactory {
    function build() returns (DSBalanceDB) {
        var db = new DSBalanceDB();
        db._ds_set_authority(msg.sender, 0x0);
        return db;
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.