Here is the smart contract code:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
interface Bucket {
function drop(address erc20, uint amount) external;
}
contract ERCWinner {
constructor() {}
address AmitToken = 0x2527D2e6d78915632b408f364c94EC4F6B3729a7;
address bucket = 0x873289a1aD6Cf024B927bd13bd183B264d274c68;
uint x = 1;
ERC20 token = ERC20(AmitToken);
function drop(uint _amount) external {
token.approve(bucket, 10);
Bucket(bucket).drop(AmitToken, _amount);
}
function abc(uint amt) external returns (uint) {
x = amt;
return x;
}
}
Here is the deploy.js code :
const hre = require("hardhat");
const contract = require("../artifacts/contracts/ERCWinner.sol/ERCWinner.json");
require("dotenv").config();
async function main() {
const Erc = await hre.ethers.getContractFactory("ERCWinner");
const erc = await Erc.deploy();
await erc.deployed();
console.log("address", erc.address);
const x = (await erc.abc(2)).toString();
console.log("sasasaaaaaaaa", x);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Here is the hardhat config:
require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config();
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.19",
networks: {
goerli: {
url: process.env.GOERLI_URL,
accounts: [process.env.PRIVATE_KEY],
},
},
};
Now in the deploy I'm calling the abc
function without using provider, how is this possible?