经典综合案例——众筹
pragma solidity ^0.5.10;
// 流程: 创建众筹事件 --> 投资人投资 --> 为受益人提款
contract crowdfunding{
// 投资者对象
struct Funder{
address funderAddr; // 投资人地址
uint amount; // 投资金额
}
// 受益人对象
struct Campaign{
address payable beneficiary; // 受益人地址
uint goal; // 目标金额
uint amount; // 当前已募集的金额
uint funderNum; // 投资者数量
// 映射,将投资者ID => 投资人对象绑定,从而可以得知是谁给当前受益人投资
mapping(uint => Funde