I have two functions I am running on Autotask, one works fine, then the same simple type of function throws this error after trying to run it:
cannot estimate gas; transaction may fail or may require manual gas limit (error={"reason":"cannot estimate gas; transaction may fail or may require manual gas limit","code":"UNPREDICTABLE_GAS_LIMIT","error":{"code":3,"data":"0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002843616e206f6e6c79206c6f636b20726f756e642077697468696e206275666665725365636f6e6473000000000000000000000000000000000000000000000000"},"method":"estimateGas","transaction":{"from":"0x3f063AC8E4B260E96c331526b89D2DAFf3F95233","to":"0xE205743C142188e72494b4cf21561E58E4C62Fde","data":"0xd9d55eac","accessList":null}}, tx={"data":"0xd9d55eac","to":{},"from":"0x3f063ac8e4b260e96c331526b89d2daff3f95233","gasLimit":{},"speed":"fast"}, code=UNPREDICTABLE_GAS_LIMIT, version=defender-relay-client)
I'm happy to share more details but I'm just using a simple task with no parameters, just a function that runs every 5 minutes.
Any help will be much appreciated.
Environment
Using the front-end web interface to write/deploy the function.
Avalanche Test Network Fuji
Node.js
Details
Keeps experiencing a failure with 'UNPREDICTABLE_GAS_LIMIT' after trying to run the genesisLockRound
function on this contract: 0xE205743C142188e72494b4cf21561E58E4C62Fde
As a side note, I have tried setting the max gas limit as well, and it still fails to send the actual gas limit through the live transaction.
Code to reproduce
const ethers = require('ethers');
const ADDRESS = '0xE205743C142188e72494b4cf21561E58E4C62Fde'
const ABI = [
{
"inputs": [
{
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
}
],
"name": "betBear",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
}
],
"name": "betBull",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_oracleAddress",
"type": "address"
},
{
"internalType": "address",
"name": "_adminAddress",
"type": "address"
},
{
"internalType": "address",
"name": "_operatorAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "_intervalSeconds",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_bufferSeconds",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_minBetAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_oracleUpdateAllowance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_treasuryFee",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "BetBear",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "BetBull",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256[]",
"name": "epochs",
"type": "uint256[]"
}
],
"name": "claim",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "Claim",
"type": "event"
},
{
"inputs": [],
"name": "claimTreasury",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "roundId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "int256",
"name": "price",
"type": "int256"
}
],
"name": "EndRound",
"type": "event"
},
{
"inputs": [],
"name": "executeRound",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "genesisLockRound",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "genesisStartRound",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"indexed": true,
"internalType": "uint256",
"name": "roundId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "int256",
"name": "price",
"type": "int256"
}
],
"name": "LockRound",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "admin",
"type": "address"
}
],
"name": "NewAdminAddress",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "bufferSeconds",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "intervalSeconds",
"type": "uint256"
}
],
"name": "NewBufferAndIntervalSeconds",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "minBetAmount",
"type": "uint256"
}
],
"name": "NewMinBetAmount",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "operator",
"type": "address"
}
],
"name": "NewOperatorAddress",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "oracle",
"type": "address"
}
],
"name": "NewOracle",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "oracleUpdateAllowance",
"type": "uint256"
}
],
"name": "NewOracleUpdateAllowance",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "treasuryFee",
"type": "uint256"
}
],
"name": "NewTreasuryFee",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"inputs": [],
"name": "pause",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
}
],
"name": "Pause",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "Paused",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "_token",
"type": "address"
},
{
"internalType": "uint256",
"name": "_amount",
"type": "uint256"
}
],
"name": "recoverToken",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "rewardBaseCalAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "rewardAmount",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "treasuryAmount",
"type": "uint256"
}
],
"name": "RewardsCalculated",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "_adminAddress",
"type": "address"
}
],
"name": "setAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_bufferSeconds",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_intervalSeconds",
"type": "uint256"
}
],
"name": "setBufferAndIntervalSeconds",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_minBetAmount",
"type": "uint256"
}
],
"name": "setMinBetAmount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_operatorAddress",
"type": "address"
}
],
"name": "setOperator",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_oracle",
"type": "address"
}
],
"name": "setOracle",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_oracleUpdateAllowance",
"type": "uint256"
}
],
"name": "setOracleUpdateAllowance",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_treasuryFee",
"type": "uint256"
}
],
"name": "setTreasuryFee",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
}
],
"name": "StartRound",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "token",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "TokenRecovery",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "TreasuryClaim",
"type": "event"
},
{
"inputs": [],
"name": "unpause",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
}
],
"name": "Unpause",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "Unpaused",
"type": "event"
},
{
"inputs": [],
"name": "adminAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "bufferSeconds",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "claimable",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "currentEpoch",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "genesisLockOnce",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "genesisStartOnce",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "cursor",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "size",
"type": "uint256"
}
],
"name": "getUserRounds",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
},
{
"components": [
{
"internalType": "enum PancakePredictionV2.Position",
"name": "position",
"type": "uint8"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "bool",
"name": "claimed",
"type": "bool"
}
],
"internalType": "struct PancakePredictionV2.BetInfo[]",
"name": "",
"type": "tuple[]"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "getUserRoundsLength",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "intervalSeconds",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "ledger",
"outputs": [
{
"internalType": "enum PancakePredictionV2.Position",
"name": "position",
"type": "uint8"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "bool",
"name": "claimed",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MAX_TREASURY_FEE",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "minBetAmount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "operatorAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "oracle",
"outputs": [
{
"internalType": "contract AggregatorV3Interface",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "oracleLatestRoundId",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "oracleUpdateAllowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "paused",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"internalType": "address",
"name": "user",
"type": "address"
}
],
"name": "refundable",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "rounds",
"outputs": [
{
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "startTimestamp",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "lockTimestamp",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "closeTimestamp",
"type": "uint256"
},
{
"internalType": "int256",
"name": "lockPrice",
"type": "int256"
},
{
"internalType": "int256",
"name": "closePrice",
"type": "int256"
},
{
"internalType": "uint256",
"name": "lockOracleId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "closeOracleId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "totalAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "bullAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "bearAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "rewardBaseCalAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "rewardAmount",
"type": "uint256"
},
{
"internalType": "bool",
"name": "oracleCalled",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "treasuryAmount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "treasuryFee",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "userRounds",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
]
exports.handler = async function(event) {
const provider = new DefenderRelayProvider(event);
const signer = new DefenderRelaySigner(event, provider, { speed: 'fast' });
// Use provider and signer for querying or sending txs from ethers, for example...
const contract = new ethers.Contract(ADDRESS, ABI, signer);
await contract.genesisLockRound();
}```