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
1,942 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
206 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
1,774 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
628 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,830 points
691 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,720 points
28,412 views
0 votes
1 answer
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
1,059 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
352 views