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

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+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
• 16,450 points
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
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
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 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,620 points
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

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.