2017-05-03 54 views
1

我读IBM Example约smartSponsor,有这个下面的代码:如何醚发送到智能合同在IBM例如

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; 
} 

我正在寻找“发送”或“传送”功能。但我找不到任何。因此,我很困惑从赞助商那里派来的醚如何被送到智能合约?

更新:

发件人如何发送ethers?我期待的东西就像.transfer(uint256金额)或.send(uint256金额)。但似乎没有这样的函数调用?

回答

2

它们在魔法变量msg中。功能祈愿在以下行中使用此变量:

pledges[numPledges] = Pledge(msg.value, msg.sender, _message); 
+0

但是,发件人是如何发送ethers的?我期待像

.transfer(uint256金额)或
.send(uint256金额)。但似乎没有这样的函数调用? –

+0

您的默认帐户用于此目的。 – Marcin

相关问题