Skip to content

TIDYMOUSE/BCHHFundMe

Repository files navigation

SETUP :

npm i yarn
yarn add hardhat
yarn add --dev @nomiclabs/hardhat-solhint
yarn add --dev @chainlink/contracts
yarn add --dev hardhat-deploy
yarn add --dev  @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers ethers
yarn add --dev solidity-coverage
yarn add --dev dotenv

NOTES :

  1. you have to add following code in hardhat.config.js when using getNamedAccounts();
namedAccounts: {
    deployer: {
        default: 0, // here this will by default take the first account as deployer
    },
},
  1. Please keep sol filenames initialized with capital letter. (error thrown in deploy() in 01-deploy-fundMe.js)
  2. There are two ways to get a contract :
    1. contract factory method :
const contractFact = await ethers.getContractFactory("contractName");
const contract = await contractFact.deploy()
await contract.waitForDeployment(); // optional 
2) .getContract() : 
await deployments.fixture(["ur tags from ur deploy scripts"]);
let contract = await deployments.get("ContractName");
contract = await ethers.getContractAt("ContractName", contract.address);
  1. When eth value is going to be returned , remember to use .toString()

  2. ALL VARIABLES OF A CONTRACT ARE FUNCTIONS IN SCRIPTS

  3. use .add() on bigNumbers

  4. use a transactionResponse and Receipt for withdraw

NEW :

let oneEth = ethers.utils.parseEther("1");
  1. two methods to send money through scripts using signers/providers(ContractRunner):
// from existing myContract 
const [owner, myAdd] = await ethers.getSigners() // 0 is owner.. think abt it
const newContract = await myContract.connect(myAdd.address)
// newContract is like calling myContract from an different address such that owner remains same as original ( newContract.owner() != myAdd.address but newContract.runner == myAdd.address)
// using signer.sendTransaction
const [owner, myAdd] = await ethers.getSigners()
const transactionResponse = await myAdd.sendTransaction({
    to: contract.address, // or (await deployments.get("contract")).deployer
    value: ethers.parseEther("1")
    })
const transactionReceipt = await transactionResponse.wait(1);

About

pain in the arse

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published