ETH Price: $1,993.65 (+0.40%)

Contract

0xB5E1448b2B6eC042Aa0AF9067e9816E29B2E48C3

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
VotingSystem

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 1 : VotingSystem.sol
// SPDX-License-Identifier: Unlicensed

// Deployed with the Atlas IDE
// https://app.atlaszk.com

pragma solidity ^0.8.19;

contract VotingSystem {
    struct Candidate {
        uint id;
        string name;
        uint voteCount;
    }

    mapping(uint => Candidate) public candidates;
    mapping(address => bool) public voters;
    uint public candidatesCount;

    event votedEvent (
        uint indexed _candidateId
    );

    constructor() {
        addCandidate("Candidate 1");
        addCandidate("Candidate 2");
    }

    function addCandidate (string memory _name) private {
        candidatesCount ++;
        candidates[candidatesCount] = Candidate(candidatesCount, _name, 0);
    }

    function vote (uint _candidateId) public {
        require(!voters[msg.sender], "You have already voted.");
        require(_candidateId > 0 && _candidateId <= candidatesCount, "Invalid candidate.");

        voters[msg.sender] = true;
        candidates[_candidateId].voteCount ++;

        emit votedEvent(_candidateId);
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "libraries": {},
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_candidateId","type":"uint256"}],"name":"votedEvent","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"candidates","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"voteCount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"candidatesCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_candidateId","type":"uint256"}],"name":"vote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"voters","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b5060408051808201909152600b81526a43616e646964617465203160a81b602082015261003c9061006c565b60408051808201909152600b81526a21b0b73234b230ba32901960a91b60208201526100679061006c565b610259565b6002805490600061007c836100d4565b909155505060408051606081018252600254808252602080830185815260008486018190529283529082905292902081518155915190919060018201906100c3908261019a565b506040820151816002015590505050565b6000600182016100f457634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061012557607f821691505b60208210810361014557634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561019557600081815260208120601f850160051c810160208610156101725750805b601f850160051c820191505b818110156101915782815560010161017e565b5050505b505050565b81516001600160401b038111156101b3576101b36100fb565b6101c7816101c18454610111565b8461014b565b602080601f8311600181146101fc57600084156101e45750858301515b600019600386901b1c1916600185901b178555610191565b600085815260208120601f198616915b8281101561022b5788860151825594840194600190910190840161020c565b50858210156102495787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6103df806102686000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630121b93f146100515780632d35a8a2146100665780633477ee2e14610082578063a3ec138d146100a4575b600080fd5b61006461005f3660046102a2565b6100d7565b005b61006f60025481565b6040519081526020015b60405180910390f35b6100956100903660046102a2565b6101f7565b604051610079939291906102bb565b6100c76100b2366004610318565b60016020526000908152604090205460ff1681565b6040519015158152602001610079565b3360009081526001602052604090205460ff161561013c5760405162461bcd60e51b815260206004820152601760248201527f596f75206861766520616c726561647920766f7465642e00000000000000000060448201526064015b60405180910390fd5b60008111801561014e57506002548111155b61018f5760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b21031b0b73234b230ba329760711b6044820152606401610133565b336000908152600160208181526040808420805460ff191690931790925583835282905281206002018054916101c483610348565b909155505060405181907ffff3c900d938d21d0990d786e819f29b8d05c1ef587b462b939609625b684b1690600090a250565b600060208190529081526040902080546001820180549192916102199061036f565b80601f01602080910402602001604051908101604052809291908181526020018280546102459061036f565b80156102925780601f1061026757610100808354040283529160200191610292565b820191906000526020600020905b81548152906001019060200180831161027557829003601f168201915b5050505050908060020154905083565b6000602082840312156102b457600080fd5b5035919050565b83815260006020606081840152845180606085015260005b818110156102ef578681018301518582016080015282016102d3565b506000608082860101526080601f19601f83011685010192505050826040830152949350505050565b60006020828403121561032a57600080fd5b81356001600160a01b038116811461034157600080fd5b9392505050565b60006001820161036857634e487b7160e01b600052601160045260246000fd5b5060010190565b600181811c9082168061038357607f821691505b6020821081036103a357634e487b7160e01b600052602260045260246000fd5b5091905056fea2646970667358221220a6ba58fcaa205305c14b6bc273f18ea8c660276f17f679f6e2bf0508763f2fdf64736f6c63430008130033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630121b93f146100515780632d35a8a2146100665780633477ee2e14610082578063a3ec138d146100a4575b600080fd5b61006461005f3660046102a2565b6100d7565b005b61006f60025481565b6040519081526020015b60405180910390f35b6100956100903660046102a2565b6101f7565b604051610079939291906102bb565b6100c76100b2366004610318565b60016020526000908152604090205460ff1681565b6040519015158152602001610079565b3360009081526001602052604090205460ff161561013c5760405162461bcd60e51b815260206004820152601760248201527f596f75206861766520616c726561647920766f7465642e00000000000000000060448201526064015b60405180910390fd5b60008111801561014e57506002548111155b61018f5760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b21031b0b73234b230ba329760711b6044820152606401610133565b336000908152600160208181526040808420805460ff191690931790925583835282905281206002018054916101c483610348565b909155505060405181907ffff3c900d938d21d0990d786e819f29b8d05c1ef587b462b939609625b684b1690600090a250565b600060208190529081526040902080546001820180549192916102199061036f565b80601f01602080910402602001604051908101604052809291908181526020018280546102459061036f565b80156102925780601f1061026757610100808354040283529160200191610292565b820191906000526020600020905b81548152906001019060200180831161027557829003601f168201915b5050505050908060020154905083565b6000602082840312156102b457600080fd5b5035919050565b83815260006020606081840152845180606085015260005b818110156102ef578681018301518582016080015282016102d3565b506000608082860101526080601f19601f83011685010192505050826040830152949350505050565b60006020828403121561032a57600080fd5b81356001600160a01b038116811461034157600080fd5b9392505050565b60006001820161036857634e487b7160e01b600052601160045260246000fd5b5060010190565b600181811c9082168061038357607f821691505b6020821081036103a357634e487b7160e01b600052602260045260246000fd5b5091905056fea2646970667358221220a6ba58fcaa205305c14b6bc273f18ea8c660276f17f679f6e2bf0508763f2fdf64736f6c63430008130033

Block Transaction Gas Used Reward
view all blocks sequenced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.