【发布时间】:2022-01-01 16:53:11
【问题描述】:
我正在编写一个函数,它应该接收一个 uint 数组,并且我想要求数组中的所有元素都不相同 并且 中的所有元素数组是属于数组的预选元素的一部分。到目前为止,我有:
function vote(uint[] memory proposals) external
{
Voter storage sender = voters[msg.sender];
require(sender.weight != 0, "Has no right to vote.");
require(!sender.voted, "Already voted.");
mapping(uint => bool) duplicateVotes;
require(!duplicateVotes, "Cannot vote for a proposal more than once.");
sender.voted = true;
sender.vote = proposals;
proposals[proposals].voteCount += sender.weight;
}
但我得到一个错误:
The data location must be "storage", "memory" or "calldata" for variable, but none was given.
但我认为这个错误只是一个更大问题的症状。谁能帮我找出解决这个问题的办法?
【问题讨论】:
标签: arrays blockchain ethereum solidity smartcontracts