Contract Address Details

0x81591DC4997A76A870c13D383F8491B288E09344

Contract Name
BrightIDSnapshot
Creator
0xb9d52b–ab98c9 at 0xc2213b–f393a6
Balance
0 Ether
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
27983466
Contract name:
BrightIDSnapshot




Optimization enabled
false
Compiler version
v0.8.0+commit.c7dfd78e




EVM Version
default




Verified at
2022-01-21 03:37:09.574430Z

Constructor Arguments

000000000000000000000000f917c019349dd70be96dea78e75dc679dcd323f7736e617073686f74000000000000000000000000000000000000000000000000

Arg [0] (address) : 0xf917c019349dd70be96dea78e75dc679dcd323f7
Arg [1] (bytes32) : 736e617073686f74000000000000000000000000000000000000000000000000

              

Contract source code

// SPDX-License-Identifier: MIT
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;
}
}
/**
* @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 Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing 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);
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
interface IBrightIDSnapshot {
event Verified(address indexed addr);
function isVerifiedUser(address _user) external view returns (bool);
function history(address addr) external view returns (address);
}
//-------------------Contracts-------------------------------
contract BrightIDSnapshot is Ownable, IBrightIDSnapshot {
//-------------------Storage-----------------------------
IERC20 public verifierToken; // Address of verification Token
bytes32 public app; // Registered BrightID app name
uint32 constant public REGISTRATION_PERIOD = 86400; // A day
struct Verification {
uint256 time;
bool isVerified;
}
//-------------------Events-----------------------------
event VerifierTokenSet(IERC20 verifierToken);
event Sponsor(address indexed addr);
//-------------------Mappings---------------------------
mapping(address => Verification) public verifications;
mapping(address => address) override public history;
//-------------------Constructor-------------------------
/**
* @param _verifierToken verifier token
* @param _app BrightID app used for verifying users
*/
constructor(IERC20 _verifierToken, bytes32 _app) {
verifierToken = _verifierToken;
app = _app;
}
// emits a sponsor event for brightID nodes
function sponsor(address addr) public {
emit Sponsor(addr);
}
/**
* @notice Set verifier token
* @param _verifierToken verifier token
*/
function setVerifierToken(IERC20 _verifierToken) public onlyOwner {
verifierToken = _verifierToken;
emit VerifierTokenSet(_verifierToken);
}
/**
* @notice Register a user by BrightID verification
* @param addrs The history of addresses used by this user in the app
* @param timestamp The BrightID node's verification timestamp
* @param v Component of signature
* @param r Component of signature
* @param s Component of signature
*/
function verify(
address[] memory addrs,
uint timestamp,
uint8 v,
bytes32 r,
bytes32 s
) public {
require(verifications[addrs[0]].time < timestamp, "Newer verification registered before.");
require (timestamp > block.timestamp - REGISTRATION_PERIOD, "Verification too old. Try linking again.");
bytes32 message = keccak256(abi.encodePacked(app, addrs, timestamp));
address signer = ecrecover(message, v, r, s);
require(verifierToken.balanceOf(signer) > 0, "not authorized");
verifications[addrs[0]].time = timestamp;
verifications[addrs[0]].isVerified = true;
for(uint i = 1; i < addrs.length; i++) {
require(verifications[addrs[i]].time < block.timestamp - REGISTRATION_PERIOD * 2, "Address changed too recently. Wait for next registration period.");
verifications[addrs[i]].time = timestamp;
verifications[addrs[i]].isVerified = false;
history[addrs[i - 1]] = addrs[i];
}
emit Verified(addrs[0]);
}
/**
* @notice Check an address is verified or not
* @param _user The context id used for verifying users
*/
function isVerifiedUser(address _user) override external view returns (bool) {
return verifications[_user].isVerified;
}
}

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_verifierToken","internalType":"contract IERC20"},{"type":"bytes32","name":"_app","internalType":"bytes32"}]},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Sponsor","inputs":[{"type":"address","name":"addr","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Verified","inputs":[{"type":"address","name":"addr","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"VerifierTokenSet","inputs":[{"type":"address","name":"verifierToken","internalType":"contract IERC20","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"REGISTRATION_PERIOD","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"app","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"history","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isVerifiedUser","inputs":[{"type":"address","name":"_user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setVerifierToken","inputs":[{"type":"address","name":"_verifierToken","internalType":"contract IERC20"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"sponsor","inputs":[{"type":"address","name":"addr","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"time","internalType":"uint256"},{"type":"bool","name":"isVerified","internalType":"bool"}],"name":"verifications","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"verifierToken","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"verify","inputs":[{"type":"address[]","name":"addrs","internalType":"address[]"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]}]
            

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100b45760003560e01c8063867092b611610071578063867092b6146101785780638da5cb5b14610196578063931c7c68146101b4578063b76564bd146101e4578063e0f5409714610202578063f2fde38b14610220576100b4565b80630213c0c5146100b9578063080c98da146100d55780633da1c0c314610106578063715018a614610136578063766c4f371461014057806380d746b21461015c575b600080fd5b6100d360048036038101906100ce9190610f8c565b61023c565b005b6100ef60048036038101906100ea9190610f63565b6109ad565b6040516100fd92919061154b565b60405180910390f35b610120600480360381019061011b9190610f63565b6109de565b60405161012d91906113f5565b60405180910390f35b61013e610a37565b005b61015a60048036038101906101559190610f63565b610abf565b005b6101766004803603810190610171919061101b565b610b05565b005b610180610bfc565b60405161018d9190611470565b60405180910390f35b61019e610c22565b6040516101ab91906113da565b60405180910390f35b6101ce60048036038101906101c99190610f63565b610c4b565b6040516101db91906113da565b60405180910390f35b6101ec610c7e565b6040516101f99190611410565b60405180910390f35b61020a610c84565b6040516102179190611574565b60405180910390f35b61023a60048036038101906102359190610f63565b610c8b565b005b83600360008760008151811061027b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015410610301576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102f8906114ab565b60405180910390fd5b6201518063ffffffff1642610316919061166e565b8411610357576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161034e9061152b565b60405180910390fd5b60006002548686604051602001610370939291906113a1565b6040516020818303038152906040528051906020012090506000600182868686604051600081526020016040526040516103ad949392919061142b565b6020604051602081039080840390855afa1580156103cf573d6000803e3d6000fd5b5050506020604051035190506000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231836040518263ffffffff1660e01b815260040161043891906113da565b60206040518083038186803b15801561045057600080fd5b505afa158015610464573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104889190611044565b116104c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104bf906114eb565b60405180910390fd5b856003600089600081518110610507577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018190555060016003600089600081518110610590577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160006101000a81548160ff0219169083151502179055506000600190505b875181101561091f5760026201518061060c9190611630565b63ffffffff164261061d919061166e565b600360008a848151811061065a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000154106106e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d7906114cb565b60405180910390fd5b86600360008a848151811061071e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001819055506000600360008a84815181106107a6577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160006101000a81548160ff02191690831515021790555087818151811061083b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151600460008a600185610855919061166e565b8151811061088c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808061091790611747565b9150506105f3565b508660008151811061095a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff167f6a6455914f452787eb3985452aceedc1000fb545e394eb3b370e3d08958e0a5b60405160405180910390a250505050505050565b60036020528060005260406000206000915090508060000154908060010160009054906101000a900460ff16905082565b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160009054906101000a900460ff169050919050565b610a3f610d83565b73ffffffffffffffffffffffffffffffffffffffff16610a5d610c22565b73ffffffffffffffffffffffffffffffffffffffff1614610ab3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aaa9061150b565b60405180910390fd5b610abd6000610d8b565b565b8073ffffffffffffffffffffffffffffffffffffffff167f45731ed8c44f9ae4a6da66b49b81184a6565962041a2485f62942faa4da6df6060405160405180910390a250565b610b0d610d83565b73ffffffffffffffffffffffffffffffffffffffff16610b2b610c22565b73ffffffffffffffffffffffffffffffffffffffff1614610b81576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b789061150b565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f6ebcfc706686427d67aa7da746fbe1ac9454e8908eda7b346b4062fc1ab6759281604051610bf19190611470565b60405180910390a150565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60046020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60025481565b6201518081565b610c93610d83565b73ffffffffffffffffffffffffffffffffffffffff16610cb1610c22565b73ffffffffffffffffffffffffffffffffffffffff1614610d07576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cfe9061150b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d77576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6e9061148b565b60405180910390fd5b610d8081610d8b565b50565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000610e62610e5d846115c0565b61158f565b90508083825260208201905082856020860282011115610e8157600080fd5b60005b85811015610eb15781610e978882610ebb565b845260208401935060208301925050600181019050610e84565b5050509392505050565b600081359050610eca81611802565b92915050565b600082601f830112610ee157600080fd5b8135610ef1848260208601610e4f565b91505092915050565b600081359050610f0981611819565b92915050565b600081359050610f1e81611830565b92915050565b600081359050610f3381611847565b92915050565b600081519050610f4881611847565b92915050565b600081359050610f5d8161185e565b92915050565b600060208284031215610f7557600080fd5b6000610f8384828501610ebb565b91505092915050565b600080600080600060a08688031215610fa457600080fd5b600086013567ffffffffffffffff811115610fbe57600080fd5b610fca88828901610ed0565b9550506020610fdb88828901610f24565b9450506040610fec88828901610f4e565b9350506060610ffd88828901610efa565b925050608061100e88828901610efa565b9150509295509295909350565b60006020828403121561102d57600080fd5b600061103b84828501610f0f565b91505092915050565b60006020828403121561105657600080fd5b600061106484828501610f39565b91505092915050565b60006110798383611094565b60208301905092915050565b61108e816116a2565b82525050565b61109d816116a2565b82525050565b60006110ae826115fc565b6110b88185611614565b93506110c3836115ec565b8060005b838110156110f45781516110db888261106d565b97506110e683611607565b9250506001810190506110c7565b5085935050505092915050565b61110a816116b4565b82525050565b611119816116c0565b82525050565b61113061112b826116c0565b611790565b82525050565b61113f81611723565b82525050565b600061115260268361161f565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006111b860258361161f565b91507f4e6577657220766572696669636174696f6e207265676973746572656420626560008301527f666f72652e0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061121e60408361161f565b91507f41646472657373206368616e67656420746f6f20726563656e746c792e20576160008301527f697420666f72206e65787420726567697374726174696f6e20706572696f642e6020830152604082019050919050565b6000611284600e8361161f565b91507f6e6f7420617574686f72697a65640000000000000000000000000000000000006000830152602082019050919050565b60006112c460208361161f565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b600061130460288361161f565b91507f566572696669636174696f6e20746f6f206f6c642e20547279206c696e6b696e60008301527f6720616761696e2e0000000000000000000000000000000000000000000000006020830152604082019050919050565b611366816116fc565b82525050565b61137d611378826116fc565b61179a565b82525050565b61138c81611706565b82525050565b61139b81611716565b82525050565b60006113ad828661111f565b6020820191506113bd82856110a3565b91506113c9828461136c565b602082019150819050949350505050565b60006020820190506113ef6000830184611085565b92915050565b600060208201905061140a6000830184611101565b92915050565b60006020820190506114256000830184611110565b92915050565b60006080820190506114406000830187611110565b61144d6020830186611392565b61145a6040830185611110565b6114676060830184611110565b95945050505050565b60006020820190506114856000830184611136565b92915050565b600060208201905081810360008301526114a481611145565b9050919050565b600060208201905081810360008301526114c4816111ab565b9050919050565b600060208201905081810360008301526114e481611211565b9050919050565b6000602082019050818103600083015261150481611277565b9050919050565b60006020820190508181036000830152611524816112b7565b9050919050565b60006020820190508181036000830152611544816112f7565b9050919050565b6000604082019050611560600083018561135d565b61156d6020830184611101565b9392505050565b60006020820190506115896000830184611383565b92915050565b6000604051905081810181811067ffffffffffffffff821117156115b6576115b56117d3565b5b8060405250919050565b600067ffffffffffffffff8211156115db576115da6117d3565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b6000602082019050919050565b600081905092915050565b600082825260208201905092915050565b600061163b82611706565b915061164683611706565b92508163ffffffff0483118215151615611663576116626117a4565b5b828202905092915050565b6000611679826116fc565b9150611684836116fc565b925082821015611697576116966117a4565b5b828203905092915050565b60006116ad826116dc565b9050919050565b60008115159050919050565b6000819050919050565b60006116d5826116a2565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600063ffffffff82169050919050565b600060ff82169050919050565b600061172e82611735565b9050919050565b6000611740826116dc565b9050919050565b6000611752826116fc565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415611785576117846117a4565b5b600182019050919050565b6000819050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61180b816116a2565b811461181657600080fd5b50565b611822816116c0565b811461182d57600080fd5b50565b611839816116ca565b811461184457600080fd5b50565b611850816116fc565b811461185b57600080fd5b50565b61186781611716565b811461187257600080fd5b5056fea264697066735822122097b2b51682b66f271f3c020a2cf1f22b41100083a2a93fcadb4dbcc6a1dcbfdb64736f6c63430008000033