Loading Learn Solidity basics/Notes.md +75 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,9 @@ Covers getting started: using Remix, creating smart contracts <https://www.youtube.com/watch?v=sngKPYfUgkc&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo> ### Part 1 related .sol files ### Part 1 notes - Remix: allows you to write Solidity code; allows you to write, compile, and run the code on eth blockchain Loading Loading @@ -39,6 +42,8 @@ Covers variable types <https://www.youtube.com/watch?v=C70XrG5yGQo&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=2> ### Part 2 related .sol files ### Part 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 Loading Loading @@ -71,6 +76,8 @@ continuing usage of variables with more interesting concepts, covering the `addr <https://www.youtube.com/watch?v=AFma5JYgIIE&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=4> ### Part 3 related .sol files ### Part 3 notes - address types were created, but they should properly be typecasted (are they really primitives then...?) Loading Loading @@ -108,6 +115,8 @@ this tutorial talks about operators you can use in Solidity <https://www.youtube.com/watch?v=KlO23rhqEnw&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=5> ### Part 4 related .sol files ### Part 4 notes - see **MyOperators.sol** for a list of operators you can use Loading @@ -121,6 +130,8 @@ this tutorial talks about measurement units (wei, gwei, ether) available in Soli <https://www.youtube.com/watch?v=64SiCO_GzDo&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=6> ### Part 5 related .sol files ### Part 5 notes - smart contracts always work with the unit **wei** Loading Loading @@ -148,3 +159,67 @@ uint256 costOfNFT = 0.05 ether; - price of the gas is usually set, and the higher the gas price, the higher priority it will be to be mined first - higher the gas price -> higher the tx fee, and the quicker it gets mined on the block - the gas spent is usually on the transaction: how long it took for the contract to run through the program and execute what it needed to execute ## Part 6 ### Part 6 video link <https://www.youtube.com/watch?v=t9Ar0i_IwZ0&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=6> ### Part 6 related .sol files ### Part 6 notes - Solidity gives us the saame familiar if/else statements and for/while loops as you see in other languages - this section covers enums, arrays, mappings - lots of good information on how minting works by mutating the contract's state ## Part 7 ### Part 7 video link ### Part 7 related .sol files ### Part 7 notes ## Part 8 ### Part 8 video link ### Part 8 related .sol files ### Part 8 notes ## Part 9 ### Part 9 video link ### Part 9 related .sol files ### Part 9 notes ## Part 10 ### Part 10 video link ### Part 10 related .sol files ### Part 10 notes ## Part 11 ### Part 11 video link ### Part 11 related .sol files ### Part 11 notes ## Part 12 ### Part 12 video link ### Part 12 related .sol files ### Part 12 notes Learn Solidity basics/contracts/MyArray.sol 0 → 100644 +28 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyArray { uint256[] arr_1; uint256[] arr_2 = [3, 2, 4]; uint256[5] arr_3; // the [5] specifies the length of the array // read from array: arr_2[1] == 2 // // here's how to write to an array // arr_2.push(9); // I'm not sure why this is erroring, it's the same as the example in the video // arr_2.pop(); // gets rid of last element in array // delete arr_2[0]; // gets rid of specified element in array function getValueOfIndex(uint256 _index) view public returns (uint256) { if (_index >= arr_2.length) { return type(uint256).max; } return arr_2[_index]; } function addToArray(uint256 _value) public { arr_2.push(_value); } } No newline at end of file Learn Solidity basics/contracts/MyEnums.sol 0 → 100644 +24 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyEnums { // uint8 rarity = 0; // 0 is original, 1 is rare, 2 is super rare enum Rarity { original, // 0 rare, // 1 super_rare // 2 } Rarity public rarity; // constructors only kick off once in the lifetime of a smart contract constructor() { rarity = Rarity.rare; } function makeSuperRare() public { rarity = Rarity.super_rare; } } No newline at end of file Learn Solidity basics/contracts/MyIfElse.sol 0 → 100644 +24 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyIfElse { uint256 public revealState = 0; bool public isNowRevealed = false; string public status = "Not yet revealed"; // be cautious with strings because they cost a lot of gas function addToRevealState() public { revealState++; } function isRevealed() public { if (revealState >= 5) { isNowRevealed = true; status = "Is now revealed!"; } else if (revealState >= 3) { status = "Almost there..."; } else { status = "Nope, still not revealed"; } } } No newline at end of file Learn Solidity basics/contracts/MyLoop.sol 0 → 100644 +19 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyLoop { function myLoop() public pure { for (uint256 i = 0; i < 5; i++) { if (i == 3) { break; } } uint256 j = 0; while (j < 10) { // do any actions j++; } } } No newline at end of file Loading
Learn Solidity basics/Notes.md +75 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,9 @@ Covers getting started: using Remix, creating smart contracts <https://www.youtube.com/watch?v=sngKPYfUgkc&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo> ### Part 1 related .sol files ### Part 1 notes - Remix: allows you to write Solidity code; allows you to write, compile, and run the code on eth blockchain Loading Loading @@ -39,6 +42,8 @@ Covers variable types <https://www.youtube.com/watch?v=C70XrG5yGQo&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=2> ### Part 2 related .sol files ### Part 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 Loading Loading @@ -71,6 +76,8 @@ continuing usage of variables with more interesting concepts, covering the `addr <https://www.youtube.com/watch?v=AFma5JYgIIE&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=4> ### Part 3 related .sol files ### Part 3 notes - address types were created, but they should properly be typecasted (are they really primitives then...?) Loading Loading @@ -108,6 +115,8 @@ this tutorial talks about operators you can use in Solidity <https://www.youtube.com/watch?v=KlO23rhqEnw&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=5> ### Part 4 related .sol files ### Part 4 notes - see **MyOperators.sol** for a list of operators you can use Loading @@ -121,6 +130,8 @@ this tutorial talks about measurement units (wei, gwei, ether) available in Soli <https://www.youtube.com/watch?v=64SiCO_GzDo&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=6> ### Part 5 related .sol files ### Part 5 notes - smart contracts always work with the unit **wei** Loading Loading @@ -148,3 +159,67 @@ uint256 costOfNFT = 0.05 ether; - price of the gas is usually set, and the higher the gas price, the higher priority it will be to be mined first - higher the gas price -> higher the tx fee, and the quicker it gets mined on the block - the gas spent is usually on the transaction: how long it took for the contract to run through the program and execute what it needed to execute ## Part 6 ### Part 6 video link <https://www.youtube.com/watch?v=t9Ar0i_IwZ0&list=PLvfQp12V0hS2PQd9-X-E2AjmXj1o05WOo&index=6> ### Part 6 related .sol files ### Part 6 notes - Solidity gives us the saame familiar if/else statements and for/while loops as you see in other languages - this section covers enums, arrays, mappings - lots of good information on how minting works by mutating the contract's state ## Part 7 ### Part 7 video link ### Part 7 related .sol files ### Part 7 notes ## Part 8 ### Part 8 video link ### Part 8 related .sol files ### Part 8 notes ## Part 9 ### Part 9 video link ### Part 9 related .sol files ### Part 9 notes ## Part 10 ### Part 10 video link ### Part 10 related .sol files ### Part 10 notes ## Part 11 ### Part 11 video link ### Part 11 related .sol files ### Part 11 notes ## Part 12 ### Part 12 video link ### Part 12 related .sol files ### Part 12 notes
Learn Solidity basics/contracts/MyArray.sol 0 → 100644 +28 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyArray { uint256[] arr_1; uint256[] arr_2 = [3, 2, 4]; uint256[5] arr_3; // the [5] specifies the length of the array // read from array: arr_2[1] == 2 // // here's how to write to an array // arr_2.push(9); // I'm not sure why this is erroring, it's the same as the example in the video // arr_2.pop(); // gets rid of last element in array // delete arr_2[0]; // gets rid of specified element in array function getValueOfIndex(uint256 _index) view public returns (uint256) { if (_index >= arr_2.length) { return type(uint256).max; } return arr_2[_index]; } function addToArray(uint256 _value) public { arr_2.push(_value); } } No newline at end of file
Learn Solidity basics/contracts/MyEnums.sol 0 → 100644 +24 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyEnums { // uint8 rarity = 0; // 0 is original, 1 is rare, 2 is super rare enum Rarity { original, // 0 rare, // 1 super_rare // 2 } Rarity public rarity; // constructors only kick off once in the lifetime of a smart contract constructor() { rarity = Rarity.rare; } function makeSuperRare() public { rarity = Rarity.super_rare; } } No newline at end of file
Learn Solidity basics/contracts/MyIfElse.sol 0 → 100644 +24 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyIfElse { uint256 public revealState = 0; bool public isNowRevealed = false; string public status = "Not yet revealed"; // be cautious with strings because they cost a lot of gas function addToRevealState() public { revealState++; } function isRevealed() public { if (revealState >= 5) { isNowRevealed = true; status = "Is now revealed!"; } else if (revealState >= 3) { status = "Almost there..."; } else { status = "Nope, still not revealed"; } } } No newline at end of file
Learn Solidity basics/contracts/MyLoop.sol 0 → 100644 +19 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyLoop { function myLoop() public pure { for (uint256 i = 0; i < 5; i++) { if (i == 3) { break; } } uint256 j = 0; while (j < 10) { // do any actions j++; } } } No newline at end of file