在etherscan.io上验证我的令牌合同时有问题。
接收以下错误:注意:契约是在Txn#结果期间创建的:与在此地址找到的输入创建字节码不匹配
错误!无法生成合同ByteCode和ABI
由于某些原因,输入数据的结尾没有给我一个工作字节码,以便在其他人使用的地方使用。这是订立合同的交易:0x776159bbc0f6e624e92a812ee98c1674e67a2a3
编译器警告(S):
myc:1:1: ParserError:预期的实用化、导入指令或契约/接口/库定义。[^任何帮助都是非常感谢的,我已经被困在这一点上好几天了,而且完全一无所知。
干杯!
pragma solidity ^0.4.0;
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 = _numProposals;
}
/// 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;
}
}
}发布于 2018-11-09 06:52:44
添加到@Harshad的答案中。
这些是你应该检查的东西:
(1)如@Harshad所说的编译版本。
(2)是否实现了优化。如果您使用的是混合,那么您将在编译部分中找到。
(3)如果您使用的是任何库(这似乎不是您所使用的库),则使用代码。但是为了双重确认),那么您也应该输入那些库。
(4)最后,实体代码必须是您用来编译的精确代码;)
祝好运!
发布于 2021-06-11 15:55:59
请查看build/contracts文件夹中的Contract-name.json,并在文件内容中找到pragma solidity。这显示了正确的编译版本。如果获得编译版本,请检查发布页的编译版本是否等于该版本。


衷心希望这对你有帮助。
发布于 2018-05-21 08:49:04
尝尝这个。
检查您的编译器版本在“验证和发布”步骤,如果它是正确的编译器版本。
您可以通过运行以下命令来检查它:
松露版
在我的例子中,输出是:
块菌v4.1.8 (核心: 4.1.8)坚固性v0.4.23 (solc-js)
因此,我从列表中选择的编译器版本是:
v0.4.23+commit.124ca40d.124ca40d
如果您没有松露或不知道它,您可以参考这个链接。
希望这能帮到别人!
https://ethereum.stackexchange.com/questions/42021
复制相似问题