• Alchemy

    • create account
    • create app
    • confirm email
    • select network: Rinkbey
  • Moralis

    • create account
    • select
    $ npx hardhat
    $ npm install --save-dev hardhat
    $ npm install --save-dev @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ethers
    $ npx hardhat compile // will install compiler
    $ npx hardhat compile // nothing to compile
    $ npx hardhat compile --force
    $ npx hardhat node --fork <https://eth-mainnet.alchemyapi.io/v2/><key> --fork-block-number 11095000
    $ npx hardhat run scripts/nameoffiel.js --network localhost
    

    Account Impersonation

    • forking to your local instance
    • documentation

    hardhat_impersonateAccount

    await hre.network.provider.request({
      method: "hardhat_impersonateAccount",
      params: ["0x364d6D0333432C3Ac016Ca832fb8594A8cE43Ca6"],
    });
    
    const signer = await ethers.getSigner("0x364d6D0333432C3Ac016Ca832fb8594A8cE43Ca6")
    signer.sendTransaction(...)
    
    $ hardhat init
    // initializes files HRE(hardhat runtime environment) members available in global scope 
    

    hardhat_setStorageAt

    await network.provider.send("hardhat_setStorageAt", [
      "0x0d2026b3EE6eC71FC6746ADb6311F6d3Ba1C000B",
      "0x0",
      "0x0000000000000000000000000000000000000000000000000000000000000001",
    ]);
    
    contract Foo {
      uint public x;
    }
    

    hard fork and account impersonification will be beneficial when you’ll be testing. Tools like hardhat and foundry have implementation addresses called cheat code contract(inherit that contract) prank call

    Nobody writes smart contracts for fun anymore they write for production and if you’re writing for production you need to test and you'll need a customizable EVM. Can’t deploy without main-net forking & impersonation

    Do it on your own and understand different use-cases it will be important at some point

    • using random strings in solidity

    Know where you’ve declared mapping and you’ll put the mapping storage...documentation doesn’t provide information about mapping but just the state. It is to google for the answer and it will be you alone.

    • All about mappings in solidity: article

      • Introduction to mappings
      • What mappings are used for?
      contract ERC20 is Context, IERC20 {    
          using SafeMath for uint256;    
          using Address for address;     
          mapping (address => uint256) private _balances;
          ...
      }
      
      • How mappings are represented in storage?(entry has key & value - slot 3-4)
      contract StorageTest {
          uint256 a;     // slot 0
          uint256[2] b;  // slots 1-2
          struct Entry {
              uint256 id;
              uint256 value;
          }
          Entry c;       // slots 3-4
          Entry[] d;     // slot 5 for length, keccak256(5)+ for data
          // slot 5 will be for key 
      		mapping(uint256 => uint256) e; // they are not normal types
          mapping(uint256 => uint256) f;
      }
      
      mapping(T1 => T2) v // v is the key of mapping // mapping will be stored in keccak256(key & v's slot)
      
      • Key and Values types allowed
      • Operations on Mappings
      • Nested Mappings
      • Mappings as function parameters
      • Structs as value types of mappings
      • Mappings Limitations

    constant & immutable: storage is skipped. Immutable we might not know their value in deploy so they’re not stored

    storage layout in solidity

    • declare mappings without knowing how it works or arranged is risky/careless...mapping is always in storage
    • generate a location for an address/key
    • write storage in hardhat
      • Consensys Diligence Team: winners - SamCzSun
      • Online Solidity Decompiler