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 :Contract structure

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

Cohort 11 students share what they learned about smart contract structure in a tough first week of classes. They walk through the licence identifier, pragma directive and contract name, then explain value data types such as booleans, integers, addresses and enums, and reference types such as arrays, structs, strings and mappings.

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, your official sponsors for Cohort 11.

0:05 B: Um, classes this week was- I think it was just like an eye-opener to how the rest of the weeks are going to be, and that was tough.

0:13 C: So basically this week they taught us, um, contract structure, how to structure our contract.

0:19 D: It was hectic and so stressful, most especially on the day we deployed our first smart contract. the bugs we faced. We faced a lot of bugs, so we're trying to debug some stuff. So it was not easy though, but we are getting ourselves acclimatized with every process.

0:36 C: So first thing you need to do is specify your license identifier. So basically there are different types of license identifiers. There's one for MIT and Apache. So it basically tells you which, um, how someone can use your code, whether they can use it commercially or they can just contribute to it. So next thing you're going to do is you're going to state your pragma directive, which is the compiler version. Then the next one is define the name of your contract. Then after that, you're going to state the data types, your functions, and the rest.

1:18 B: So basically we have types of- or 2 categories of data types. We have the, um, value data types and then the reference data types. And then talking about the value data types, um, value data types basically store- they store the actual value. Like when you assign a value data type to a variable, that's how it is used. So different types of value data types, we have the boolean, that's like a true or false operator. We have the Integers, which consists of the unsigned and the signed integers. We have the address, which also consists of 20 bytes of Ethereum address. And then we have the enums, which practically houses or has like a collection, houses a collection of data values.

2:05 D: The reference data type in Solidity, they are just data types that points just like a pointer or an address that points to the actual data types which is stored in the value. We have 4 reference data types which are the array, the struct, the string, and the mapping. Uh, in array we have 2 types of array. We have the dynamic array and the static array. The static array, when declaring it or when initializing it, you need to state the the length of the array, the amount of values or the amount of inputs you want that array to, to accept. But in the dynamically array, the dynamic array, dynamic array can store any length of strings or integer or any, any value assigned to it. So we also have the map, the mapping. The mapping is just like you are trying to map like a dictionary key. Just like when you are looking for a word in the dictionary, you go to maybe L, you're looking for leave, you go to L. The L there is just like the, the key you used in searching for that word. So that is how the mapping, mapping data structure, the mapping data type works. So we also have the string. Which stores- it's just like an array of bytes. Then the struct stores multiple numbers of different data types, just like the integer, the strings, the boolean, and all of that. It packs it into one and stores it on the blockchain, on the memory.

3:55 B: For more updates like this, please like, share, and subscribe.

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.