Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x5Fbfd832D829901008Ed27478F3E0f3DDe56e768
Balance 0 ETH
Nonce 1
Code Size 2675 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

2675 bytes
0x608060405234801561000f575f5ffd5b506004361061007b575f3560e01c80637ef4aa7b116100595780637ef4aa7b146100d55780638da5cb5b146100f3578063c142b16914610111578063f2fde38b146101415761007b565b80630fae38ac1461007f5780632a4a1b73146100af578063715018a6146100cb575b5f5ffd5b610099600480360381019061009491906107ae565b61015d565b6040516100a69190610818565b60405180910390f35b6100c960048036038101906100c49190610831565b610192565b005b6100d3610466565b005b6100dd610479565b6040516100ea9190610890565b60405180910390f35b6100fb610485565b60405161010891906108b8565b60405180910390f35b61012b600480360381019061012691906107ae565b6104ac565b6040516101389190610818565b60405180910390f35b61015b600480360381019061015691906108d1565b61054a565b005b6001602052825f5260405f20602052815f5260405f20602052805f5260405f205f92509250509054906101000a900460ff1681565b60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8381526020019081526020015f205f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff1615610266576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161025d90610956565b60405180910390fd5b5f8373ffffffffffffffffffffffffffffffffffffffff16638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102b0573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906102d49190610988565b90508373ffffffffffffffffffffffffffffffffffffffff166323b872dd338367016345785d8a00006040518463ffffffff1660e01b815260040161031b939291906109b3565b6020604051808303815f875af1158015610337573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061035b9190610a12565b506001805f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8581526020019081526020015f205f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055503373ffffffffffffffffffffffffffffffffffffffff16838573ffffffffffffffffffffffffffffffffffffffff167fecf612ba4699d1adae61f25a29d86224891134426a6f3e515be94947fd96e121856040516104589190610890565b60405180910390a450505050565b61046e6105ce565b6104775f610655565b565b67016345785d8a000081565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b5f60015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8481526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff1690509392505050565b6105526105ce565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036105c2575f6040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016105b991906108b8565b60405180910390fd5b6105cb81610655565b50565b6105d6610716565b73ffffffffffffffffffffffffffffffffffffffff166105f4610485565b73ffffffffffffffffffffffffffffffffffffffff161461065357610617610716565b6040517f118cdaa700000000000000000000000000000000000000000000000000000000815260040161064a91906108b8565b60405180910390fd5b565b5f5f5f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f5f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f33905090565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61074a82610721565b9050919050565b61075a81610740565b8114610764575f5ffd5b50565b5f8135905061077581610751565b92915050565b5f819050919050565b61078d8161077b565b8114610797575f5ffd5b50565b5f813590506107a881610784565b92915050565b5f5f5f606084860312156107c5576107c461071d565b5b5f6107d286828701610767565b93505060206107e38682870161079a565b92505060406107f486828701610767565b9150509250925092565b5f8115159050919050565b610812816107fe565b82525050565b5f60208201905061082b5f830184610809565b92915050565b5f5f5f606084860312156108485761084761071d565b5b5f61085586828701610767565b93505060206108668682870161079a565b92505060406108778682870161079a565b9150509250925092565b61088a8161077b565b82525050565b5f6020820190506108a35f830184610881565b92915050565b6108b281610740565b82525050565b5f6020820190506108cb5f8301846108a9565b92915050565b5f602082840312156108e6576108e561071d565b5b5f6108f384828501610767565b91505092915050565b5f82825260208201905092915050565b7f416c726561647920766f746564000000000000000000000000000000000000005f82015250565b5f610940600d836108fc565b915061094b8261090c565b602082019050919050565b5f6020820190508181035f83015261096d81610934565b9050919050565b5f8151905061098281610751565b92915050565b5f6020828403121561099d5761099c61071d565b5b5f6109aa84828501610974565b91505092915050565b5f6060820190506109c65f8301866108a9565b6109d360208301856108a9565b6109e06040830184610881565b949350505050565b6109f1816107fe565b81146109fb575f5ffd5b50565b5f81519050610a0c816109e8565b92915050565b5f60208284031215610a2757610a2661071d565b5b5f610a34848285016109fe565b9150509291505056fea2646970667358221220a7b4ef905793917ac6b3f08a6f7dc623ff09ba2a1d0ac43189a24d0d6d73ed2264736f6c634300081e0033

Verified Source Code Full Match

Compiler: v0.8.30+commit.73712a01 EVM: prague Optimization: No
TokenVoting.sol 52 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

interface IOwnable {
    function owner() external view returns (address);
}

contract TokenVoting is Ownable {
    uint256 public constant VOTE_FEE = 0.1 ether; // 0.1 токена (18 decimals)
    
    // token => pollId => voter => voted
    mapping(address => mapping(uint256 => mapping(address => bool))) public hasVoted;
    
    event Voted(
        address indexed token,
        uint256 indexed pollId,
        address indexed voter,
        uint256 option
    );
    
    constructor() Ownable(msg.sender) {}
    
    function vote(
        address token,
        uint256 pollId,
        uint256 option
    ) external {
        require(!hasVoted[token][pollId][msg.sender], "Already voted");
        
        // Получаем овнера токена
        address tokenOwner = IOwnable(token).owner();
        
        // Списываем 0.1 токена в пользу овнера
        IERC20(token).transferFrom(msg.sender, tokenOwner, VOTE_FEE);
        
        // Отмечаем что проголосовал
        hasVoted[token][pollId][msg.sender] = true;
        
        emit Voted(token, pollId, msg.sender, option);
    }
    
    function hasUserVoted(
        address token,
        uint256 pollId,
        address voter
    ) external view returns (bool) {
        return hasVoted[token][pollId][voter];
    }
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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);
    }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @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;
    }
}

Read Contract

VOTE_FEE 0x7ef4aa7b → uint256
hasUserVoted 0xc142b169 → bool
hasVoted 0x0fae38ac → bool
owner 0x8da5cb5b → address

Write Contract 3 functions

These functions modify contract state and require a wallet transaction to execute.

renounceOwnership 0x715018a6
No parameters
transferOwnership 0xf2fde38b
address newOwner
vote 0x2a4a1b73
address token
uint256 pollId
uint256 option

Recent Transactions

No transactions found for this address