CRYPTO NEWS

"Election" hit an invalid opcode while deploying. truffle migrate

I’m just getting started with Solidity and ran into a problem that I can’t solve. The error below displays when you try to migrate

truffle migrate --reset 
2_deploy_contracts.js =====================     Replacing 'Election'    --------------------  Error:  *** Deployment Failed ***  "Election" hit an invalid opcode while deploying. Try:    * Verifying that your constructor params satisfy all assert conditions.    * Verifying your constructor code doesn't access an array out of bounds.    * Adding reason strings to your assert statements. 

I do not understand why this is happening, I have tried many solutions, but still without effect. Updating the truffle version did not help, and neither did the subsequent changes to the Election.sol structure. I am using ganache v2.5.4

Election.sol

// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.8.20; pragma experimental ABIEncoderV2; contract Election {     struct Elections {         uint id;         string title;         string description;         uint creationDate;         uint expirationDate;         Candidate[] candidates;     }     uint public electionsCount;     Elections[] elections;      struct Candidate {         uint id;         string name;         uint voteCount;     }     uint public candidatesCount;      function addElections (string memory _title, string memory _description, uint _amountOfHours, string[] memory _names) private {         electionsCount ++;         elections[electionsCount].id = electionsCount;         elections[electionsCount].title = _title;         elections[electionsCount].description = _description;         elections[electionsCount].creationDate = block.timestamp;         elections[electionsCount].expirationDate = block.timestamp + _amountOfHours;          Candidate[] memory candidates;         for (uint i = 0; i < _names.length; i++) {             candidatesCount ++;             string memory name = _names[i];             candidates[candidatesCount] = Candidate(candidatesCount, name, 0);             elections[electionsCount].candidates.push(candidates[i]);         }     }     string[] names= ["AAAA", "BBBBB", "CCCCCC"];      constructor () public {         addElections("Voted", "vote for your candidate", 8, names);     } } 

SHARE DATA BETWEEN BLOCKCHAINS (BSC,Polygon,ETH)

I have this smart contract that i’m going to deploy on BSC, ETH and Polygon networks. contract Color is ERC721Full { string [] public colors; mapping (string => bool) _colorExists; constructor () ERC721Full("Color", "COLOR") public {} // Example color = ‘#FFFFFF’ function mint(string memory _color) public { require(!_colorExists[_color]); uint _id = colors.push(_color); _mint(msg.sender, _id); _colorExists[_color]::Listen

I have this smart contract that i’m going to deploy on BSC, ETH and Polygon networks.

contract Color is ERC721Full { string [] public colors; mapping (string => bool) _colorExists;  constructor () ERC721Full("Color", "COLOR") public {}  // Example color = '#FFFFFF' function mint(string memory _color) public {     require(!_colorExists[_color]);     uint _id = colors.push(_color);     _mint(msg.sender, _id);     _colorExists[_color] = true; } } 

The problem is that data is not shared between blockchais, ie:

If I create a color #FF00FF in Ethereum Blockchain, i need that this color is not available for create in the BSC and Polygon.

Is there any way to do this, or is this problem not solved yet?

"Election" hit an invalid opcode while deploying. truffle migrate

Shopping cart
There are no products in the cart!
Continue shopping
0