0

Error

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
    Returned error: {"jsonrpc":"2.0","error":"VM Exception while processing transaction: invalid opcode","id":1595760994985969}

I try to deploy smart contract in ganach blockchain through metamask wallet, and direactly and also inject provider method but every time given error and errors are difference but not excuted. Other thing is I deploy another smart contract thourgh this prorperly this smart contract compile correctly but when deploy it given error. that code given below

pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Strings.sol";



    contract Ballot{
    
    // uint x=DateTimeLibrary._daysFromDate(2021,3,2);
    struct proposals{
        string proposal_id;
        string prop_name;
        string prop_details;
        uint vote_count;
    }
    struct BallotDetails{
        uint ballot_id;
        string owner_email; 
        string ballot_name;
        string ballot_description;
        string ballot_owner_name;
        address ballot_owner_address;
        uint open_date;
        uint closing_date;
        string ballot_type;
        uint proposals_count; 
        uint full_vote_count;
        address[] followers;
        // proposals proposals;
    }
    struct voters{
    address [] voter_address;
    }
    
    struct dashboardData{
    uint [] ballots_ids;
    }
    struct privateballotids{
        uint [] private_ballot_ids;
    }
    
    
    struct privateballots{
        address[] voters;
     
    }
    
    struct followingballots{
        uint[] ballots_id;
    }
     
    mapping(uint => BallotDetails) Ballots;
    BallotDetails[] public ballots_arr;
    
    mapping(string => proposals) Proposal;
    proposals[] public proposals_arr;
    
    mapping(uint=>voters) Voters;
    
    mapping(address=>dashboardData) Dashboard;
    
    mapping(uint=>privateballots) PrivateBallot;
    
    mapping(address=>privateballotids) OwnPrivateIds;
    
    mapping(address=>followingballots) FollowingBallots;
     
    //create ballot
    function createBallot(
        string memory o_email,
        string memory b_name,
        string memory b_description,
        string memory b_owner_name,
        address b_owner_address,
        uint start_d,
        uint end_d,
        string memory b_type) public returns(bool){
        require(start_d >= block.timestamp && end_d >= block.timestamp && start_d < end_d,'Invalid dates, plz check');
        uint b_id=ballots_arr.length;
        Ballots[b_id].ballot_id=b_id;
        Ballots[b_id].owner_email=o_email;
        Ballots[b_id].ballot_name=b_name;
        Ballots[b_id].ballot_description=b_description;
        Ballots[b_id].ballot_owner_name=b_owner_name;
        Ballots[b_id].ballot_owner_address=b_owner_address;
        Ballots[b_id].open_date=start_d;
        Ballots[b_id].closing_date=end_d;
        Ballots[b_id].ballot_type=b_type;
        ballots_arr.push(Ballots[b_id]);
        Dashboard[b_owner_address].ballots_ids.push(b_id);
        return true;
     }
}

can you help to solve this problem

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.