Solidity code to change value of name

0 votes

I am following tutorial and I have two tasks to do.

  1. setName function should allow setting value of name
  2. increaseCounter should increase the counter by 10 whenever it is called

I have completed writing the other methods and it works fine but I’m stuck with this. Can someone tell how can I implement this?

Jul 29, 2018 in Blockchain by digger
• 26,550 points
44 views

1 answer to this question.

0 votes

Try this for setName:

function setName(string _name) public {

    name = _name;

  }

And this for increaseCounter:

function increaseCounter() public {

    counter += 10;

  }

This should work.

answered Jul 29, 2018 by slayer
• 29,170 points

Related Questions In Blockchain

+1 vote
1 answer

I am unable to change port of composer-rest-server. Please help!

Use full format for running a business ...READ MORE

answered Mar 27, 2018 in Blockchain by Christine
• 15,790 points
308 views
+1 vote
1 answer

what is use of msg.sender in solidity code?

msg.sender(address) function indicated the sender of the ...READ MORE

answered Apr 24, 2018 in Blockchain by Shashank
• 10,350 points
508 views
0 votes
1 answer

Can I change the code of the node and runit usually?

Say, you run an unmodified ethereum node, ...READ MORE

answered Jun 18, 2018 in Blockchain by charlie_brown
• 7,720 points
21 views
0 votes
1 answer

How to set web3 solidity variable value?

The setLog transaction has not yet been mined by ...READ MORE

answered Jul 6, 2018 in Blockchain by Christine
• 15,790 points
159 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
172 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to get return value from solidity contract?

Once you call a constant function, you ...READ MORE

answered Aug 16, 2018 in Blockchain by slayer
• 29,170 points
576 views
0 votes
1 answer

How to get value from solidity contract using java?

web3j caters for this very use case. It ...READ MORE

answered Sep 28, 2018 in Blockchain by slayer
• 29,170 points
288 views