What is the difference between if() and require() statement in solidity??

+1 vote
if() and require() both have condition based execution, they both require some condition before execution, so can they be used interchangeably??
Apr 17, 2018 in Blockchain by anonymous
335 views

1 answer to this question.

+1 vote
Best answer

If() and require() have separate functions and cannot be used interchangeably.

if(): when the first condition becomes false the next condition i.e else block gets executed.

require(): it has a diffrent function. It is actually an error handling statement, and when the require condition is false, the execution stops and the transaction gets rolled back.

answered Apr 18, 2018 by Shashank
• 10,330 points

selected Aug 7, 2018 by Omkar

Related Questions In Blockchain

0 votes
1 answer

What is the difference between o and --> in Fabric Composer?

'o' indicates has-a relationship '-->' indicates pass by ...READ MORE

answered Aug 24, 2018 in Blockchain by Perry
• 17,010 points
35 views
0 votes
1 answer
0 votes
2 answers

What is the difference between full node and partial node?

We need different types of nodes to ...READ MORE

answered May 30 in Blockchain by Sourav kumar
130 views
0 votes
1 answer

What is the difference between Blockchin and Bitcoin

Blockchain has potential beyond Bitcoin and cryptocurrency. ...READ MORE

answered Jul 13, 2018 in Blockchain by shweta
• 440 points
80 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
123 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 27,630 points
2,475 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

What are the differences between tendermint and hashgraph?

Hashgraph uses Superior distributed ledger technology. Hashgraph ...READ MORE

answered Apr 7, 2018 in Blockchain by Shashank
• 10,330 points
136 views