Commit 72eadf9e authored by Chris's avatar Chris
Browse files

Solidity WIP part 10

parent d24e0b37
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -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
+0 −0

Empty file added.

+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