How to Send Ether and ERC20 Tokens to a Smart Contract Address and Show the Balance - My First Project 11-3-2022

 

1. Entering receive code in remix

2. Connect to MetaMask

3. Funding MetaMask with goerli from Alchemy https://goerlifaucet.com/ and Link from Chainlink Faucet https://faucets.chain.link/

4. Compiling and Deploying

5. Copy the deployed contract address

6. Send the contract address from MetaMask Ether and Link

7.  Go to https://goerli.etherscan.io/ to check balance of contract address (and note for ERC20 tokens sent and Link in this example it is a subtree under Ether balance). This is the case in hardware wallets as well like Ledger with ERC20 tokens.

metamask


// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

//Recieve Ether basic code
contract gimmeSomeEtherReceiving {

receive( ) external payable {}

fallback( ) external payable {}
      function showmetheBalance() public view returns (uint) { 
      return address (this).balance; 
      } 
  }