Difference between internal-external private-public in function

+1 vote

According to the Solidity docs, by default, function types are internal, so the internal keyword can be omitted. In contrast, contract functions themselves are public by default, only when used as the name of a type, the default is internal.

I have a doubt here. How is it possible that a function can be internal and public at the same time? Can somebody tell me the difference between internal-external, public-private in regards to the functions??

Apr 8, 2018 in Blockchain by Johnathon
• 9,090 points
9,196 views

5 answers to this question.

+2 votes
Best answer

External: These functions are part of the contract interface and can be called from other contracts and via transactions. An external function cannot be called internally. 

Public: These can be called internally or via messages. 

Internal: these functions and variables can only be accessed internally. (from the current or the derived contract) 

Private: these functions and state variables are only visible for the contract they are defined in and not the derived contracts.

answered Apr 8, 2018 by Shashank
• 10,400 points

selected Aug 7, 2018 by Omkar
+1 vote
When a function is public, anybody can access it. When it is private, only the contract in which the function exists can access it.
answered May 3, 2019 by Karan
+1 vote
A function that calls a function in the same contract is called an internal function. And a function that calls a function that's from a different smart contract is called an external function.
answered May 3, 2019 by Krish
+1 vote

An internal function is similar to protected access specifier in Object Oriented programming languages. When you specify a function as internal, only the functions of that contract and the functions derived from that contract can access that internal-specified function. This is to provide protection for the functions so that it cannot be accessed by other smart contracts. 

answered May 3, 2019 by Esha
0 votes
When a function is internal and public, it means that the function can be called only by the calls from within that smart contract or from the calls derived from that smart contract.
answered May 3, 2019 by Umar

Related Questions In Blockchain

0 votes
1 answer
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
780 views
0 votes
1 answer

How to call function in one contract from another contract in private blockchain?

Please check whether you have byzantiumBlock: 0 in your ...READ MORE

answered Oct 1, 2018 in Blockchain by digger
• 26,740 points
865 views
0 votes
1 answer
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,928 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,226 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,456 views
0 votes
1 answer

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

If() and require() have separate functions and ...READ MORE

answered Apr 18, 2018 in Blockchain by Shashank
• 10,400 points
5,059 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,378 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