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 7, 2018 in Blockchain by Johnathon
• 9,080 points
1,372 views

5 answers to this question.

+1 vote
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 7, 2018 by Shashank
• 10,350 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 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 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 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 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 24, 2018 in Blockchain by Perry
• 17,020 points
41 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,550 points
47 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
141 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,550 points
3,073 views
0 votes
1 answer
+1 vote
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,350 points
379 views
0 votes
1 answer