IBM 示例中的以太币是如何发送到智能合约的
How are the ethers sent to smart contract in the IBM example
我正在阅读有关 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;
}
我正在寻找 "send" 或 "transfer" 函数。但我找不到任何。因此我很困惑以太币是如何从赞助商发送到智能合约的?
更新:
发件人是如何发送以太币的?我期待像 .transfer(uint256 amount) 或 .send(uint256 amount) 这样的东西。但是好像没有这个函数调用?
他们在魔法变量msg中。函数承诺在以下行中使用此变量:
pledges[numPledges] = Pledge(msg.value, msg.sender, _message);
我正在阅读有关 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;
}
我正在寻找 "send" 或 "transfer" 函数。但我找不到任何。因此我很困惑以太币是如何从赞助商发送到智能合约的?
更新:
发件人是如何发送以太币的?我期待像 .transfer(uint256 amount) 或 .send(uint256 amount) 这样的东西。但是好像没有这个函数调用?
他们在魔法变量msg中。函数承诺在以下行中使用此变量:
pledges[numPledges] = Pledge(msg.value, msg.sender, _message);