A Solidity smart contract implementation that demonstrates external contract interaction on the Ethereum blockchain.
This is the answer to stackoverflow question: Error: cannot estimate gas; transaction may fail or may require manual gas limit (Sepolia test Network)
The EventWinner project showcases a smart contract that can interact with other contracts through their interfaces. It implements a pattern for making external calls to contracts that expose an attempt() function.
- Solidity ^0.8.27
- Hardhat
- TypeScript
- Ethers.js
The main contract contains:
- Interface definition for target contracts
- External function to interact with other contracts
- Low-level call implementation for robust contract interaction
- External contract interaction
- Interface-based calling
- Gas-efficient implementation
- Error handling
The contract can be used to interact with any contract that implements the attempt() function:
// Get contract instance
const eventWinner = await EventWinner.deploy();
// Call target contract
await eventWinner.callWinner(targetContractAddress);- Clone the repository
git clone https://github.com/imcrazysteven/Hardhat-Winner-Event.git- Install dependencies:
npm install- Compile contracts:
npx hardhat compile- Run deployment script:
npx hardhat run scripts/deploy.ts --network sepolia- Sepolia
- Local hardhat Network
This project is licensed under the MIT License.
- Email: imcrazysteven143@gmail.com
- GitHub: Steven (@imcrazysteven)
- Telegram: @imcrazysteven
- Twitter: @imcrazysteven
- Instagram: @imcrazysteven