区块链学习——智能赞助代码

pragma solidity 0.4.24;
contract smartSponsor{
address public owner;//合约的实施方
address public benefactor;//受益人
bool public refunded;
bool public complete;
uint public numPledges;
struct Pledge{
uint amount;
address eth_address;
bytes32 message;
}//Pledge结构描述一个捐赠
mapping (uint =>Pledge) public pledges;//记录一组Pledge
//constructor
function smartSponsor(address _benefactor){
owner = msg.sender;
numPledges = 0 ;
refunded = false;
complete = false;
benefactor = _benefactor;
}//初始化数据,读入受益者
function pledge(bytes32 _message){
if(msg.value ==0||complete||refunded)throw;//转账的以太币数量value
pledges[numPledges] =Pledge(msg.value,msg.sender,_message);
numPledges++;
}//添加募捐者
function getPot() constant returns (uint){
return this.balance;
}
function refund(){
if(msg.sender!=owner||complete||refunded)throw;
for(uint i = 0 ;i

猜你喜欢

转载自blog.csdn.net/qq_36344771/article/details/81092646