Moralis
$ 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
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
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
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
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
...
}
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)
constant & immutable: storage is skipped. Immutable we might not know their value in deploy so they’re not stored
storage layout in solidity