Loading Learn Solidity basics part 1/MyContract.sol→Learn Solidity basics/MyContract.sol +0 −0 File moved. View file Learn Solidity basics/MyTypes.sol 0 → 100644 +20 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyTypes { bool public myBoolean = false; uint256 public myUint = 566778778787; uint32 public myUint32 = 6756567; uint16 public myUint16 = 6773; uint8 public myUint8 = 0; // 0 to 255 | 2 ** 8 - 1 = 255 int256 private myInt = -566778778787; int32 private myInt32 = -6756567; int16 internal myInt16 = -6773; int8 internal myInt8 = -127; // 0 to 255 | 2 ** 8 - 1 = 255 address public myAddress = sample address; address internal myContractAddress = sample contract address; } No newline at end of file Learn Solidity basics part 1/Notes.md→Learn Solidity basics/Notes.md +68 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ ## Part 1 Covers getting started: using Remix, creating smart contracts ### Video link https://www.youtube.com/watch?v=sngKPYfUgkc&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo Loading @@ -28,4 +30,39 @@ contract SampleContract { - this is because the setters will usually require logic - setters utilize functions and actions - call it a "function" because a function does something, with rules and parameters - No newline at end of file ## Part 2 Covers variable types ### Video link <https://www.youtube.com/watch?v=C70XrG5yGQo&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=2> ### Notes - keep usage of strings to a minimum: strings are bytes bundled together, which means they can cost a lot of gas when used in smart contracts - keep usage of strings to a minimum and rely on primitve types instead - bools, integers, addresses, etc. - creating a MyTypes contract: - types documentation: https://docs.soliditylang.org/en/latest/types.html - a lot of this video covered types, like the difference between uint and int, the bit sizes (*int___: 8, 16, 32, 64, 128, 256) - going from uint to int means that the numerical range is cut in half (signed bit) - there is an `address` type as well - this type gives you a lot of flexibility - address values can be for wallets or other contracts on the blockchain - variables in contracts are private by default - declaring: public, internal, private - to make a variable public: - refactor `bool myBoolean = false` to `bool public myBoolean = false` - the variables will be readable in the blockchain - a best practice is to keep all public, internal, and private variables separate - easier compilation, easier readability - you can use explicit `private` keywords - `internal` keyword: only the smart contract has access to this internal value as well as other smart contracts that inherit from the smart contract - make variables `public` as long as it isn't sensitive data - don't store sensitive information inside a smart contract ## Part 3 continuing usage of variables with more interesting concepts Loading
Learn Solidity basics part 1/MyContract.sol→Learn Solidity basics/MyContract.sol +0 −0 File moved. View file
Learn Solidity basics/MyTypes.sol 0 → 100644 +20 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyTypes { bool public myBoolean = false; uint256 public myUint = 566778778787; uint32 public myUint32 = 6756567; uint16 public myUint16 = 6773; uint8 public myUint8 = 0; // 0 to 255 | 2 ** 8 - 1 = 255 int256 private myInt = -566778778787; int32 private myInt32 = -6756567; int16 internal myInt16 = -6773; int8 internal myInt8 = -127; // 0 to 255 | 2 ** 8 - 1 = 255 address public myAddress = sample address; address internal myContractAddress = sample contract address; } No newline at end of file
Learn Solidity basics part 1/Notes.md→Learn Solidity basics/Notes.md +68 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ ## Part 1 Covers getting started: using Remix, creating smart contracts ### Video link https://www.youtube.com/watch?v=sngKPYfUgkc&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo Loading @@ -28,4 +30,39 @@ contract SampleContract { - this is because the setters will usually require logic - setters utilize functions and actions - call it a "function" because a function does something, with rules and parameters - No newline at end of file ## Part 2 Covers variable types ### Video link <https://www.youtube.com/watch?v=C70XrG5yGQo&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=2> ### Notes - keep usage of strings to a minimum: strings are bytes bundled together, which means they can cost a lot of gas when used in smart contracts - keep usage of strings to a minimum and rely on primitve types instead - bools, integers, addresses, etc. - creating a MyTypes contract: - types documentation: https://docs.soliditylang.org/en/latest/types.html - a lot of this video covered types, like the difference between uint and int, the bit sizes (*int___: 8, 16, 32, 64, 128, 256) - going from uint to int means that the numerical range is cut in half (signed bit) - there is an `address` type as well - this type gives you a lot of flexibility - address values can be for wallets or other contracts on the blockchain - variables in contracts are private by default - declaring: public, internal, private - to make a variable public: - refactor `bool myBoolean = false` to `bool public myBoolean = false` - the variables will be readable in the blockchain - a best practice is to keep all public, internal, and private variables separate - easier compilation, easier readability - you can use explicit `private` keywords - `internal` keyword: only the smart contract has access to this internal value as well as other smart contracts that inherit from the smart contract - make variables `public` as long as it isn't sensitive data - don't store sensitive information inside a smart contract ## Part 3 continuing usage of variables with more interesting concepts