1

I was reading the IBM Example about smartSponsor, and there is this following code:

personal.unlockAccount(thesponsor,"password"); 
ss.pledge("Good luck with the run!", {from: thesponsor, value: 10000000, gas: 3000000}); 

While the function pledge is:

function pledge(bytes32 _message) {
  if (msg.value == 0 || complete || refunded) throw;
  pledges[numPledges] = Pledge(msg.value, msg.sender, _message);
  numPledges++;
}

struct Pledge {
  uint amount;
  address eth_address;
  bytes32 message;
}

I was looking for "send" or "transfer" functions. But I could not find any. Therefore I was confused how were the ethers sent from the sponsor to the smart contract?

Update:

How did the sender send the ethers? I was expecting something like .transfer(uint256 amount) or .send(uint256 amount). But it seems that there is no such function call?

4

1 回答 1

2

它们在神奇的变量msg中。函数质押在以下行中使用此变量:

pledges[numPledges] = Pledge(msg.value, msg.sender, _message);
于 2017-05-04T02:36:17.187 回答