Is {from: thesponsor, value: 10000000, gas: 3000000} considered as a transaction object?

0 votes

I was going through the IDM Example for Ethereum smart contract and i came across the following code:

personal.unlockAccount(thesponsor,"password");

ss.pledge("Good luck with the run!", {from: thesponsor, value: 10000000, gas: 3000000});

and the pledge function is as follows:

function pledge(bytes32 _message) {

  if (msg.value == 0 || complete || refunded) throw;

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

  numPledges++;

}

I am getting a little confused here. Is the solidity seeing {from: thesponsor, value: 10000000, gas: 3000000} as a

msg object that is used to transfer ethers? If yes, then if i write a json object with the keywords "from"and "value",

would it make a fund transaction accidentally?

Jul 25, 2018 in Blockchain by slayer
• 29,050 points
19 views

1 answer to this question.

0 votes

Yes, {from: thesponsor, value: 10000000, gas: 3000000} is considered and interpreted as a transactionObject. Let me

explain why it is so. Any transaction on Ethereum that causes a state change(create, update or delete) requires a

transactionObject. So in the above code mentioned in your question, it is interpreted as a transactionObject.

Look at the example of the pledge function mentioned below:

1   // add a new pledge

2   function pledge(bytes32 _message) {

3    if (msg.value == 0 || complete || refunded) throw;

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

5    numPledges++;

}

In this code snippet, you can see that lines 4 and 5 cause state change. To cause these state changes, it is required that you provide gas. The pledge function also has a msg.value which is the Ethereum amount you want to send in the pledge and it is denoted by value.

To know the structure of the transactionObject and to know more about it, you can visit: https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethsendtransaction

answered Jul 25, 2018 by digger
• 27,620 points

Related Questions In Blockchain

0 votes
2 answers
+1 vote
1 answer

How does a miner get to know that a transaction is verified by all the nodes?

Contrary to the popular belief, it is ...READ MORE

answered Mar 26, 2018 in Blockchain by Johnathon
• 9,070 points
55 views
0 votes
1 answer

How can we decrypt a transaction payload when confidentiality is on?

You can try the following: you can only ...READ MORE

answered May 2, 2018 in Blockchain by Shashank
• 10,330 points
55 views
0 votes
1 answer

How a transaction validity is verified in blockchain?

Blockchain has the records the of all ...READ MORE

answered May 11, 2018 in Blockchain by Johnathon
• 9,070 points
34 views
0 votes
1 answer
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
+1 vote
5 answers

Where does the smart contracts stored and executed on blockchain?

Ethereum smart contracts are executed on EVM ...READ MORE

answered May 2, 2018 in Blockchain by Shashank
• 10,330 points
560 views
0 votes
1 answer