Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't verify and publish smart contract #500

Open
NTP-996 opened this issue Nov 27, 2018 · 1 comment
Open

Can't verify and publish smart contract #500

NTP-996 opened this issue Nov 27, 2018 · 1 comment

Comments

@NTP-996
Copy link

NTP-996 commented Nov 27, 2018

After successfully deploy my smart contract on tomotestnet with remix and metamask.
https://scan.testnet.tomochain.com/address/0xfffeabd61f00ab5f9b26af4fad70ec3eba0bb58e#transactions
screenshot from 2018-11-27 17-07-21
screenshot from 2018-11-27 17-08-11
screenshot from 2018-11-27 17-09-58
I can't verify and publish my smart contract.
screenshot from 2018-11-27 17-10-50
screenshot from 2018-11-27 17-12-37
Here is the code :

pragma solidity 0.5.0;

contract RecurringLottery {
    struct Round {
        uint endBlock;
        uint drawBlock;
        Entry[] entries;
        uint totalQuantity;
        address winner;
    }
    struct Entry {
        address buyer;
        uint quantity;
    }

    uint constant public TICKET_PRICE = 1e15;

    mapping(uint => Round) public rounds;
    uint public round;
    uint public duration;
    mapping (address => uint) public balances;

    // duration is in blocks. 1 day = ~5500 blocks
    constructor (uint _duration) public {
        duration = _duration;
        round = 1;
        rounds[round].endBlock = block.number + duration;
        rounds[round].drawBlock = block.number + duration + 5;
    }

    function buy () payable public {
        require(msg.value % TICKET_PRICE == 0);

        if (block.number > rounds[round].endBlock) {
            round += 1;
            rounds[round].endBlock = block.number + duration;
            rounds[round].drawBlock = block.number + duration + 5;
        }

        uint quantity = msg.value / TICKET_PRICE;
        Entry memory entry = Entry(msg.sender, quantity);
        rounds[round].entries.push(entry);
        rounds[round].totalQuantity += quantity;
    }

    function drawWinner (uint roundNumber) public {
        Round storage drawing = rounds[roundNumber];
        require(drawing.winner ==  address(0));
        require(block.number > drawing.drawBlock);
        require(drawing.entries.length > 0);

        // pick winner
        bytes32 rand = keccak256(
            abi.encode(blockhash(drawing.drawBlock))
        );
        uint counter = uint(rand) % drawing.totalQuantity;
        for (uint i=0; i < drawing.entries.length; i++) {
            uint quantity = drawing.entries[i].quantity;
            if (quantity > counter) {
                drawing.winner = drawing.entries[i].buyer;
                break;
            }
            else
                counter -= quantity;
        }
        
        balances[drawing.winner] += TICKET_PRICE * drawing.totalQuantity;
    }

    function withdraw () public {
        uint amount = balances[msg.sender];
        balances[msg.sender] = 0;
        msg.sender.transfer(amount);
    }

    function deleteRound (uint _round) public {
        require(block.number > rounds[_round].drawBlock + 100);
        require(rounds[_round].winner != address(0));
        delete rounds[_round];
    }

    function () payable external {
        buy();
    }
}
@khaihkd
Copy link
Contributor

khaihkd commented Nov 28, 2018

I find 2 reasons

  • we using solc-js (npm install solc) to verify source code but we use old version (0.4.23) but we list all version
  • if upgrade to latest version 0.5.0, we cannot verify too. Maybe something wrong from this library

So we need to handle solidity compile in the next time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants