Loading Learn Solidity basics/Notes.md +21 −0 Original line number Diff line number Diff line Loading @@ -265,12 +265,33 @@ errors and checks ## Part 10 covers interfaces ### Part 10 video link <https://www.youtube.com/watch?v=KQ8bTt6Jhjk> ### Part 10 related .sol files - [MyInterface.sol](./contracts/MyInterface.sol) - [MyPayable.sol](./contracts/MyPayable.sol) ### Part 10 notes - when looking at OpenZeppelin contracts, ERC721 inherits IERC721 which is an interface (blueprint) - anything that implements an interface has to implement the functions defined in it - this is basically a list of function definitions - interfaces can inherit from other interfaces - in interface, all declarations of functions must be external - calls will come from the outside - an interface can't have its own constructor - you cannot declare state variables in a contract either - if you add `payable` to an `address` type variable, that address will actually be able to receive eth - you can make constructors and functions payable if you want to send ether to them - allows for extra functionality - if a constructor is payable, you have to send the ether with the contract deployment - ## Part 11 ### Part 11 video link Loading Learn Solidity basics/contracts/MyInterface.sol 0 → 100644 +0 −0 Empty file added. Learn Solidity basics/contracts/MyPayable.sol 0 → 100644 +22 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyPayable { address payable public myAddress; constructor() payable { myAddress = payable(msg.sender); } // function deposit() public payable { // payable(msg.sender).transfer(1); // transfers 1 eth to the contract creator // } function deposit() public payable {} function getThisContractBalance() public view returns (uint256) { uint256 amount = address(this).balance; return amount; } } No newline at end of file Loading
Learn Solidity basics/Notes.md +21 −0 Original line number Diff line number Diff line Loading @@ -265,12 +265,33 @@ errors and checks ## Part 10 covers interfaces ### Part 10 video link <https://www.youtube.com/watch?v=KQ8bTt6Jhjk> ### Part 10 related .sol files - [MyInterface.sol](./contracts/MyInterface.sol) - [MyPayable.sol](./contracts/MyPayable.sol) ### Part 10 notes - when looking at OpenZeppelin contracts, ERC721 inherits IERC721 which is an interface (blueprint) - anything that implements an interface has to implement the functions defined in it - this is basically a list of function definitions - interfaces can inherit from other interfaces - in interface, all declarations of functions must be external - calls will come from the outside - an interface can't have its own constructor - you cannot declare state variables in a contract either - if you add `payable` to an `address` type variable, that address will actually be able to receive eth - you can make constructors and functions payable if you want to send ether to them - allows for extra functionality - if a constructor is payable, you have to send the ether with the contract deployment - ## Part 11 ### Part 11 video link Loading
Learn Solidity basics/contracts/MyPayable.sol 0 → 100644 +22 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract MyPayable { address payable public myAddress; constructor() payable { myAddress = payable(msg.sender); } // function deposit() public payable { // payable(msg.sender).transfer(1); // transfers 1 eth to the contract creator // } function deposit() public payable {} function getThisContractBalance() public view returns (uint256) { uint256 amount = address(this).balance; return amount; } } No newline at end of file