我正在阅读关于smartSponsor的IBM Example,并且有以下代码:
personal.unlockAccount(thesponsor,"password");
ss.pledge("Good luck with the run!", {from: thesponsor, value: 10000000, gas: 3000000});
虽然功能承诺是:
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;
}
我一直在寻找"发送"或"转移"功能。但我找不到任何东西。因此,我很困惑,从赞助商那里发送的醚类是如何进入智能合约的?
更新
发件人是如何发送醚类的?我期待像.transfer(uint256金额)或.send(uint256金额)这样的东西。但似乎没有这样的函数调用?
答案 0 :(得分:2)
它们是神奇的变量msg。函数pledge在以下行中使用此变量:
pledges[numPledges] = Pledge(msg.value, msg.sender, _message);