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,350 points
332 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
• 26,740 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,100 points
3,410 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 6, 2018 in Blockchain by aryya
• 7,450 points
662 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
1,731 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,258 views
+1 vote
1 answer

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

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,450 points
1,170 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
• 26,740 points
927 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
• 26,740 points
2,614 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP