我刚刚开始学习稳固,我正在工作的投标合同,允许投标人投标的运动。我有竞选的结构。投标人有详细的信息(地址,姓名),我想存储投标人与他们的信息内的运动。竞选活动可以有一个以上的投标者。
这是我的竞选活动和投标结构
struct Campaign {
uint256 campaignID;
uint256 budget;
uint256 bidCount;
}
struct Bidder {
bool bided;
uint256 bid;
string name;
address bidderAddress;
}
mapping(address => Bidder) public bidders;
Campaign[] public campaigns;我在这里写了一个出价函数,它接受竞选的索引,然后填充bidCount。
function bid(uint256 _bidIndex, uint256 _twitterID) public {
require(!bidders[msg.sender].bided);
bidders[msg.sender].bid = _bidIndex;
campaigns[_bidIndex].bidCount += 1;
totalBids += 1;
}所以竞选活动可以像这样(如果可能的话)。
0: campaignID 1
1: budget 2ETH
2: bidCount 3
3: Bidder {0: name Bidder1, 1: address 0xahaaahha}
{0: name Bidder2, 2: address 0x2334jddd}任何帮助都将不胜感激。谢谢
发布于 2022-05-25 14:25:29
结构中的结构数组示例.
在一个操作中可以有多个ActionData结构(就像在一个活动中有投标人一样)
interface IWallet {
struct Operation {
uint256 nonce;
IWallet.ActionData[] actions;
}
struct ActionData {
uint256 ethValue;
address contractAddress;
bytes encodedFunction;
}
...
}(https://github.com/web3well/bls-wallet/blob/main/contracts/contracts/interfaces/IWallet.sol#L9-L18)
https://ethereum.stackexchange.com/questions/128942
复制相似问题