Estoy usando Remix, Metamask, ROPSTEN y no puedo implementar ningún contrato... siempre recibo el mismo mensaje... solía funcionar... ya no funciona... sucede en diferentes máquinas, sucede con Chrome o Firefox ...parece estar relacionado con la rutina de estimación...
ESTIMACIÓN DE GAS FALLIDA
Error de estimación de gas con el siguiente mensaje (ver más abajo). Es probable que la ejecución de la transacción falle. ¿Quieres forzar el envío? Error: el gas requerido excede la asignación o siempre falla la transacción en chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/background.js:1:1723632 en chrome-
Avíseme si tiene una configuración similar y funciona... o si tiene algún problema conocido...
Gracias !
Aquí está el código:
pragma solidity ^0.4.20;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
struct Proposal {
uint voteCount;
}
address chairperson;
mapping(address => Voter) voters;
Proposal[] proposals;
/// Create a new ballot with $(_numProposals) different proposals.
function Ballot(uint8 _numProposals) public {
chairperson = msg.sender;
voters[chairperson].weight = 1;
proposals.length = 3;
}
/// Give $(toVoter) the right to vote on this ballot.
/// May only be called by $(chairperson).
function giveRightToVote(address toVoter) public {
if (msg.sender != chairperson || voters[toVoter].voted) return;
voters[toVoter].weight = 1;
}
/// Delegate your vote to the voter $(to).
function delegate(address to) public {
Voter storage sender = voters[msg.sender]; // assigns reference
if (sender.voted) return;
while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender)
to = voters[to].delegate;
if (to == msg.sender) return;
sender.voted = true;
sender.delegate = to;
Voter storage delegateTo = voters[to];
if (delegateTo.voted)
proposals[delegateTo.vote].voteCount += sender.weight;
else
delegateTo.weight += sender.weight;
}
/// Give a single vote to proposal $(toProposal).
function vote(uint8 toProposal) public {
Voter storage sender = voters[msg.sender];
if (sender.voted || toProposal >= proposals.length) return;
sender.voted = true;
sender.vote = toProposal;
proposals[toProposal].voteCount += sender.weight;
}
function winningProposal() public constant returns (uint8 _winningProposal) {
uint256 winningVoteCount = 0;
for (uint8 prop = 0; prop < proposals.length; prop++)
if (proposals[prop].voteCount > winningVoteCount) {
winningVoteCount = proposals[prop].voteCount;
_winningProposal = prop;
}
}
}
Límite de gas: 3000000 Valor: 1 éter
Vea si puede implementar esto en ROPSTEN...
A su código le falta la constructor()
función, consulte aquí .
function Ballot()
, pero incluso en ese caso eso no debería causar una falla.su código funciona bien en mi máquina.
1) Supongo que la compilación Remix está teniendo algún problema, crear un nuevo archivo de solidez con el mismo código y volver a implementarlo podría ayudar. 2) también, intente recargar Chrome (pestaña Remix) 3) de lo contrario, reinstale Metamask.
¡Espero eso ayude!
Raghav Sood
ismael