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,050 points
614 views

5 answers 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

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,330 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
• 16,450 points
26 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
• 27,620 points
31 views
0 votes
1 answer

How to make sure transactions take no fee in a private Ethereum blockchain?

In a private ethereum network you have ...READ MORE

answered Mar 26, 2018 in Blockchain by Christine
• 15,790 points

edited Mar 26, 2018 by Christine 59 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
65 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
• 27,620 points
1,558 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,330 points
227 views
0 votes
1 answer

© 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.