How are the ethers sent to smart contract in the IBM example?

0 votes

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?

Sep 28, 2018 in Blockchain by slayer
• 29,050 points
14 views

1 answer to this question.

0 votes

They are in magical variable msg. The function pledge uses this variable in the following line:

pledges[numPledges] = Pledge(msg.value, msg.sender, _message);
answered Sep 28, 2018 by digger
• 27,620 points

Related Questions In Blockchain

0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 17,010 points
271 views
0 votes
1 answer

How to prevent the smart contract from being modified and deployed in the blockchain network?

To expand on Matthew's answer, each state ...READ MORE

answered Jul 5, 2018 in Blockchain by ariaholic
• 7,320 points
39 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
105 views
0 votes
1 answer
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,320 points
56 views
0 votes
1 answer

How to use real world/live data in my smart contract?

You cant access/embed real world data using ...READ MORE

answered Jul 12, 2018 in Blockchain by digger
• 27,620 points
50 views
0 votes
1 answer

How to interact with smart contract in GO?

I am providing an example. Modify it ...READ MORE

answered Jul 26, 2018 in Blockchain by digger
• 27,620 points
67 views