Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| - | 8104706 | 2443 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x28715528...d6a12564e The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
Reputation
Compiler Version
v0.5.4+commit.9549d8ff
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity)
/**
*Submitted for verification at Etherscan.io on 2019-03-07
*/
// File: openzeppelin-solidity/contracts/ownership/Ownable.sol
pragma solidity ^0.5.0;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor () internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
/**
* @return the address of the owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner());
_;
}
/**
* @return true if `msg.sender` is the owner of the contract.
*/
function isOwner() public view returns (bool) {
return msg.sender == _owner;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// File: contracts/Reputation.sol
pragma solidity ^0.5.4;
/**
* @title Reputation system
* @dev A DAO has Reputation System which allows peers to rate other peers in order to build trust .
* A reputation is use to assign influence measure to a DAO'S peers.
* Reputation is similar to regular tokens but with one crucial difference: It is non-transferable.
* The Reputation contract maintain a map of address to reputation value.
* It provides an onlyOwner functions to mint and burn reputation _to (or _from) a specific address.
*/
contract Reputation is Ownable {
uint8 public decimals = 18; //Number of decimals of the smallest unit
// Event indicating minting of reputation to an address.
event Mint(address indexed _to, uint256 _amount);
// Event indicating burning of reputation for an address.
event Burn(address indexed _from, uint256 _amount);
/// @dev `Checkpoint` is the structure that attaches a block number to a
/// given value, the block number attached is the one that last changed the
/// value
struct Checkpoint {
// `fromBlock` is the block number that the value was generated from
uint128 fromBlock;
// `value` is the amount of reputation at a specific block number
uint128 value;
}
// `balances` is the map that tracks the balance of each address, in this
// contract when the balance changes the block number that the change
// occurred is also included in the map
mapping (address => Checkpoint[]) balances;
// Tracks the history of the `totalSupply` of the reputation
Checkpoint[] totalSupplyHistory;
/// @notice Constructor to create a Reputation
constructor(
) public
{
}
/// @dev This function makes it easy to get the total number of reputation
/// @return The total number of reputation
function totalSupply() public view returns (uint256) {
return totalSupplyAt(block.number);
}
////////////////
// Query balance and totalSupply in History
////////////////
/**
* @dev return the reputation amount of a given owner
* @param _owner an address of the owner which we want to get his reputation
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balanceOfAt(_owner, block.number);
}
/// @dev Queries the balance of `_owner` at a specific `_blockNumber`
/// @param _owner The address from which the balance will be retrieved
/// @param _blockNumber The block number when the balance is queried
/// @return The balance at `_blockNumber`
function balanceOfAt(address _owner, uint256 _blockNumber)
public view returns (uint256)
{
if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) {
return 0;
// This will return the expected balance during normal situations
} else {
return getValueAt(balances[_owner], _blockNumber);
}
}
/// @notice Total amount of reputation at a specific `_blockNumber`.
/// @param _blockNumber The block number when the totalSupply is queried
/// @return The total amount of reputation at `_blockNumber`
function totalSupplyAt(uint256 _blockNumber) public view returns(uint256) {
if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
return 0;
// This will return the expected totalSupply during normal situations
} else {
return getValueAt(totalSupplyHistory, _blockNumber);
}
}
/// @notice Generates `_amount` reputation that are assigned to `_owner`
/// @param _user The address that will be assigned the new reputation
/// @param _amount The quantity of reputation generated
/// @return True if the reputation are generated correctly
function mint(address _user, uint256 _amount) public onlyOwner returns (bool) {
uint256 curTotalSupply = totalSupply();
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
uint256 previousBalanceTo = balanceOf(_user);
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_user], previousBalanceTo + _amount);
emit Mint(_user, _amount);
return true;
}
/// @notice Burns `_amount` reputation from `_owner`
/// @param _user The address that will lose the reputation
/// @param _amount The quantity of reputation to burn
/// @return True if the reputation are burned correctly
function burn(address _user, uint256 _amount) public onlyOwner returns (bool) {
uint256 curTotalSupply = totalSupply();
uint256 amountBurned = _amount;
uint256 previousBalanceFrom = balanceOf(_user);
if (previousBalanceFrom < amountBurned) {
amountBurned = previousBalanceFrom;
}
updateValueAtNow(totalSupplyHistory, curTotalSupply - amountBurned);
updateValueAtNow(balances[_user], previousBalanceFrom - amountBurned);
emit Burn(_user, amountBurned);
return true;
}
////////////////
// Internal helper functions to query and set a value in a snapshot array
////////////////
/// @dev `getValueAt` retrieves the number of reputation at a given block number
/// @param checkpoints The history of values being queried
/// @param _block The block number to retrieve the value at
/// @return The number of reputation being queried
function getValueAt(Checkpoint[] storage checkpoints, uint256 _block) internal view returns (uint256) {
if (checkpoints.length == 0) {
return 0;
}
// Shortcut for the actual value
if (_block >= checkpoints[checkpoints.length-1].fromBlock) {
return checkpoints[checkpoints.length-1].value;
}
if (_block < checkpoints[0].fromBlock) {
return 0;
}
// Binary search of the value in the array
uint256 min = 0;
uint256 max = checkpoints.length-1;
while (max > min) {
uint256 mid = (max + min + 1) / 2;
if (checkpoints[mid].fromBlock<=_block) {
min = mid;
} else {
max = mid-1;
}
}
return checkpoints[min].value;
}
/// @dev `updateValueAtNow` used to update the `balances` map and the
/// `totalSupplyHistory`
/// @param checkpoints The history of data being updated
/// @param _value The new number of reputation
function updateValueAtNow(Checkpoint[] storage checkpoints, uint256 _value) internal {
require(uint128(_value) == _value); //check value is in the 128 bits bounderies
if ((checkpoints.length == 0) || (checkpoints[checkpoints.length - 1].fromBlock < block.number)) {
Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++];
newCheckPoint.fromBlock = uint128(block.number);
newCheckPoint.value = uint128(_value);
} else {
Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
oldCheckPoint.value = uint128(_value);
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_user","type":"address"},{"name":"_amount","type":"uint256"}],"name":"mint","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_blockNumber","type":"uint256"}],"name":"balanceOfAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_blockNumber","type":"uint256"}],"name":"totalSupplyAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_user","type":"address"},{"name":"_amount","type":"uint256"}],"name":"burn","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]Contract Creation Code
0x60806040526000805460a060020a60ff0219167412000000000000000000000000000000000000000017905534801561003757600080fd5b5060008054600160a060020a0319163317808255604051600160a060020a039190911691907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a36108d7806100906000396000f3fe608060405234801561001057600080fd5b50600436106100c6576000357c010000000000000000000000000000000000000000000000000000000090048063715018a61161008e578063715018a6146101955780638da5cb5b1461019f5780638f32d59b146101c3578063981b24d0146101cb5780639dc29fac146101e8578063f2fde38b14610214576100c6565b806318160ddd146100cb578063313ce567146100e557806340c10f19146101035780634ee2cd7e1461014357806370a082311461016f575b600080fd5b6100d361023a565b60408051918252519081900360200190f35b6100ed61024b565b6040805160ff9092168252519081900360200190f35b61012f6004803603604081101561011957600080fd5b50600160a060020a03813516906020013561026c565b604080519115158252519081900360200190f35b6100d36004803603604081101561015957600080fd5b50600160a060020a038135169060200135610335565b6100d36004803603602081101561018557600080fd5b5035600160a060020a03166103c7565b61019d6103db565b005b6101a7610445565b60408051600160a060020a039092168252519081900360200190f35b61012f610454565b6100d3600480360360208110156101e157600080fd5b5035610465565b61012f600480360360408110156101fe57600080fd5b50600160a060020a0381351690602001356104b9565b61019d6004803603602081101561022a57600080fd5b5035600160a060020a0316610570565b600061024543610465565b90505b90565b60005474010000000000000000000000000000000000000000900460ff1681565b6000610276610454565b151561028157600080fd5b600061028b61023a565b905082810181111561029c57600080fd5b60006102a7856103c7565b90508381018111156102b857600080fd5b6102c5600285840161058f565b600160a060020a03851660009081526001602052604090206102e99082860161058f565b604080518581529051600160a060020a038716917f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885919081900360200190a26001925050505b92915050565b600160a060020a03821660009081526001602052604081205415806103915750600160a060020a03831660009081526001602052604081208054849290811061037a57fe5b6000918252602090912001546001608060020a0316115b1561039e5750600061032f565b600160a060020a03831660009081526001602052604090206103c09083610697565b905061032f565b60006103d38243610335565b90505b919050565b6103e3610454565b15156103ee57600080fd5b60008054604051600160a060020a03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031690565b600054600160a060020a0316331490565b600254600090158061049a5750816002600081548110151561048357fe5b6000918252602090912001546001608060020a0316115b156104a7575060006103d6565b6104b2600283610697565b90506103d6565b60006104c3610454565b15156104ce57600080fd5b60006104d861023a565b90508260006104e6866103c7565b9050818110156104f4578091505b610501600283850361058f565b600160a060020a03861660009081526001602052604090206105259083830361058f565b604080518381529051600160a060020a038816917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a250600195945050505050565b610578610454565b151561058357600080fd5b61058c816107e7565b50565b6001608060020a03811681146105a457600080fd5b815415806105d8575081544390839060001981019081106105c157fe5b6000918252602090912001546001608060020a0316105b1561064c57815460009083906105f18260018301610864565b815481106105fb57fe5b600091825260209091200180546001608060020a03848116700100000000000000000000000000000000024382166fffffffffffffffffffffffffffffffff19909316929092171617905550610693565b81546000908390600019810190811061066157fe5b600091825260209091200180546001608060020a03808516700100000000000000000000000000000000029116179055505b5050565b815460009015156106aa5750600061032f565b8254839060001981019081106106bc57fe5b6000918252602090912001546001608060020a03168210610719578254839060001981019081106106e957fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a0316905061032f565b82600081548110151561072857fe5b6000918252602090912001546001608060020a031682101561074c5750600061032f565b8254600090600019015b818111156107a757845460028383016001010490859087908390811061077857fe5b6000918252602090912001546001608060020a03161161079a578092506107a1565b6001810391505b50610756565b84828154811015156107b557fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a031695945050505050565b600160a060020a03811615156107fc57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b8154818355818111156108885760008381526020902061088891810190830161088d565b505050565b61024891905b808211156108a75760008155600101610893565b509056fea165627a7a723058203bca0af92dfcfede9bd26af6f6a767b02b188e0c1c60a9df19141bf497b87ecc0029
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100c6576000357c010000000000000000000000000000000000000000000000000000000090048063715018a61161008e578063715018a6146101955780638da5cb5b1461019f5780638f32d59b146101c3578063981b24d0146101cb5780639dc29fac146101e8578063f2fde38b14610214576100c6565b806318160ddd146100cb578063313ce567146100e557806340c10f19146101035780634ee2cd7e1461014357806370a082311461016f575b600080fd5b6100d361023a565b60408051918252519081900360200190f35b6100ed61024b565b6040805160ff9092168252519081900360200190f35b61012f6004803603604081101561011957600080fd5b50600160a060020a03813516906020013561026c565b604080519115158252519081900360200190f35b6100d36004803603604081101561015957600080fd5b50600160a060020a038135169060200135610335565b6100d36004803603602081101561018557600080fd5b5035600160a060020a03166103c7565b61019d6103db565b005b6101a7610445565b60408051600160a060020a039092168252519081900360200190f35b61012f610454565b6100d3600480360360208110156101e157600080fd5b5035610465565b61012f600480360360408110156101fe57600080fd5b50600160a060020a0381351690602001356104b9565b61019d6004803603602081101561022a57600080fd5b5035600160a060020a0316610570565b600061024543610465565b90505b90565b60005474010000000000000000000000000000000000000000900460ff1681565b6000610276610454565b151561028157600080fd5b600061028b61023a565b905082810181111561029c57600080fd5b60006102a7856103c7565b90508381018111156102b857600080fd5b6102c5600285840161058f565b600160a060020a03851660009081526001602052604090206102e99082860161058f565b604080518581529051600160a060020a038716917f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885919081900360200190a26001925050505b92915050565b600160a060020a03821660009081526001602052604081205415806103915750600160a060020a03831660009081526001602052604081208054849290811061037a57fe5b6000918252602090912001546001608060020a0316115b1561039e5750600061032f565b600160a060020a03831660009081526001602052604090206103c09083610697565b905061032f565b60006103d38243610335565b90505b919050565b6103e3610454565b15156103ee57600080fd5b60008054604051600160a060020a03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a36000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031690565b600054600160a060020a0316331490565b600254600090158061049a5750816002600081548110151561048357fe5b6000918252602090912001546001608060020a0316115b156104a7575060006103d6565b6104b2600283610697565b90506103d6565b60006104c3610454565b15156104ce57600080fd5b60006104d861023a565b90508260006104e6866103c7565b9050818110156104f4578091505b610501600283850361058f565b600160a060020a03861660009081526001602052604090206105259083830361058f565b604080518381529051600160a060020a038816917fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5919081900360200190a250600195945050505050565b610578610454565b151561058357600080fd5b61058c816107e7565b50565b6001608060020a03811681146105a457600080fd5b815415806105d8575081544390839060001981019081106105c157fe5b6000918252602090912001546001608060020a0316105b1561064c57815460009083906105f18260018301610864565b815481106105fb57fe5b600091825260209091200180546001608060020a03848116700100000000000000000000000000000000024382166fffffffffffffffffffffffffffffffff19909316929092171617905550610693565b81546000908390600019810190811061066157fe5b600091825260209091200180546001608060020a03808516700100000000000000000000000000000000029116179055505b5050565b815460009015156106aa5750600061032f565b8254839060001981019081106106bc57fe5b6000918252602090912001546001608060020a03168210610719578254839060001981019081106106e957fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a0316905061032f565b82600081548110151561072857fe5b6000918252602090912001546001608060020a031682101561074c5750600061032f565b8254600090600019015b818111156107a757845460028383016001010490859087908390811061077857fe5b6000918252602090912001546001608060020a03161161079a578092506107a1565b6001810391505b50610756565b84828154811015156107b557fe5b60009182526020909120015470010000000000000000000000000000000090046001608060020a031695945050505050565b600160a060020a03811615156107fc57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b8154818355818111156108885760008381526020902061088891810190830161088d565b505050565b61024891905b808211156108a75760008155600101610893565b509056fea165627a7a723058203bca0af92dfcfede9bd26af6f6a767b02b188e0c1c60a9df19141bf497b87ecc0029
Swarm Source
bzzr://3bca0af92dfcfede9bd26af6f6a767b02b188e0c1c60a9df19141bf497b87ecc
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.