Skip to content

Instantly share code, notes, and snippets.

@shobhitic
Last active January 15, 2023 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shobhitic/54250ba4519052385af66b0864b712a2 to your computer and use it in GitHub Desktop.
Save shobhitic/54250ba4519052385af66b0864b712a2 to your computer and use it in GitHub Desktop.
Testing on real blockchain data without tokens - https://www.youtube.com/watch?v=VGZb2orvYJE
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract Checker {
function check(address _token, address user) view public returns (uint256) {
return IERC20(_token).balanceOf(user);
}
}
// to create hardhat project
npx hardhat init
// to run a local blockchain
npx hardhat node
// to fork a blockchain and run locally
npx hardhat node --fork "RPC_URL"
// to connect to locally running blockchain node
npx hardhat console --network localhost
require("@nomicfoundation/hardhat-toolbox");
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.17",
networks: {
hardhat: {
forking: {
url: "https://cloudflare-eth.com/",
}
}
}
};
@sahilrajput03
Copy link

Awesome, thanks for this. You are really great teacher and programmer. 😘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment