What is the difference between if and require statement in solidity

0 votes
if() and require() both have condition based execution, they both require some condition before execution, so can they be used interchangeably??
Apr 18, 2018 in Blockchain by anonymous
5,037 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,400 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 25, 2018 in Blockchain by Perry
• 17,100 points
737 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 31, 2019 in Blockchain by Sourav kumar
5,732 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
2,074 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,901 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
• 26,740 points
45,141 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,424 views
0 votes
1 answer

What are the differences between chain and state database in hyperledger fabric?

There are two place which "store" data ...READ MORE

answered Jul 11, 2018 in Blockchain by Shashank
• 10,400 points
2,327 views
0 votes
1 answer

What are the differences between tendermint and hashgraph?

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

answered Apr 8, 2018 in Blockchain by Shashank
• 10,400 points
957 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