The One Question bounty closes Thursday 10 December.

Join in
We Them Media logo We Them Media Support us

Web3bridge Students (cohort 11) Share What They’ve Learned: Function Visibility

The picture loads from YouTube. The player loads only when you press Play. Turn on captions in the player if you need them.

Rahima, a Web3 Bridge Cohort 11 student, says the week was exciting but stressful because class moved from theory to hands-on Solidity. Rahima then explains function visibility: public, private, external and internal, and who can call each kind.

Not by We Them Media Channel: Web3Bridge. Published Tuesday 15 October 2024.

Titles are the owner’s. It plays from their channel.

Transcript

This transcript may contain errors. This video belongs to Web3Bridge. Letters mark each change of speaker.

These are the speakers’ own words. We have not checked their claims.

0:00 A: This video is brought to you by Lix, the official sponsors for Cohort 11.

0:05 B: Hi everyone, my name is Rahima and I'm here to share my experience during this week at Web3 Bridge Cohort 11. So this week we started learning Solidity.

0:15 C: It was exciting because we've been learning theoretical aspects all previous weeks and it was kind of fun that we actually had to do hands-on coding experiences. It was stressful a bit because you are basically learning a new language, but I mean, that's why we are here.

0:32 D: And if you'd like to learn more about our experience at Wycliffe Bridge, like, share, and subscribe.

0:38 C: So today I'll be talking about function visibility. Now, function visibility defines how functions are viewed and accessed in a smart contract. There are 4 types of function visibilities: public, private, external, and internal.

0:58 D: So, uh, what are public functions? These are functions that are available to be accessed by, um, EOE, other contracts, and other functions within the contract. So by default, if you don't give the function any visibility type, default it will inherit the public. So what are public functions used for? They are to make your contracts available externally or internally. So, and it's very gas efficient to use. What are internal functions? They are used to call, to make your contracts available externally. That is outside the contract. So, and there are also some techniques you can make it to be available within the contract by using what we call this keyword. But this keyword is gas inefficient because it can cost you more gas. But it has an advantage that it makes your code to be secure by isolating it from other processes.

1:53 B: Internal functions are like the opposite of external functions. External functions can be called from outside a contract and can also be inherited and be called from an inheriting contract. But internal functions cannot be called from outside of a contract, although if a contract inherits that contract, then it can also use the internal function. But a function with its visibility set to private is only owned by the contract that defines the function. It cannot be called from outside the function or the contract, and it cannot be called from a contract that inherits that particular contract. So for more of these updates, like, subscribe, and share this video.

More from this hub

Something wrong, or a video you want off this page? Write to wethem.xyz@gmail.com and it is fixed or taken down within 48 hours.