I am attempting to send a transaction in the Ethereum Sepolia testnet, but I keep getting gas fees errors. I have had the transaction signed and sent using the web3 library.
const { Web3 } = require('web3');
const web3 = new Web3('https://eth-sepolia.g.alchemy.com/v2/9aHCL7I90Xo_YSRD3P1PxkyMEANMyWl7');
const marketABI = require('./abi/Market.json')
let dateInWeek = new Date();
dateInWeek.setDate(dateInWeek.getDate() + 7);
const deadline = Math.floor(dateInWeek.getTime() / 1000);
let tempContract = new web3_.eth.Contract(marketABI, '0xD72C08f47188a41E9182F793ed6d46192db61D9A')
const gasSuggestion = await web3.eth.getGasPrice();
const tx = {
from: '0xc768B39DBcBCCfD6dECae24b0a591e78BEA3382F',
to: '0xD72C08f47188a41E9182F793ed6d46192db61D9A',
gasPrice: web3.utils.toHex(gasSuggestion),
maxFeesPerGas: web3.utils.toHex(gasSuggestion),
gas: web3.utils.toHex(gasSuggestion),
data: tempContract.methods.createMarket('Title placeholder', 'description placeholder', 'crypto','http://google.com',deadline).encodeABI()}
const sign = await web3.eth.accounts.signTransaction(tx, privateKey);
web3.eth.sendSignedTransaction(sign.rawTransaction);
I get the following error:
Web3PromiEvent {
_emitter: EventEmitter {
_events: Events <[Object: null prototype] {}> {},
_eventsCount: 0,
maxListeners: 9007199254740991
},
_promise: Promise {
<pending>,
[Symbol(async_id_symbol)]: 6906,
[Symbol(trigger_async_id_symbol)]: 6
},
[Symbol(Symbol.toStringTag)]: 'Promise'
}
> Uncaught TransactionRevertInstructionError: Transaction has been reverted by the EVM
at /home/ahmed/Projects/market/node_modules/web3-eth/lib/commonjs/utils/get_transaction_error.js:48:21
at Generator.next (<anonymous>)
at /home/ahmed/Projects/market/node_modules/web3-eth/lib/commonjs/utils/get_transaction_error.js:24:71
at new Promise (<anonymous>)
at __awaiter (/home/ahmed/Projects/market/node_modules/web3-eth/lib/commonjs/utils/get_transaction_error.js:20:12)
at getTransactionError (/home/ahmed/Projects/market/node_modules/web3-eth/lib/commonjs/utils/get_transaction_error.js:33:12) {
cause: undefined,
reason: 'err: insufficient funds for gas * price + value: address 0xc768B39DBcBCCfD6dECae24b0a591e78BEA3382F have 89433739508822183 want 15035565005450000000 (supplied gas 550000000)',
signature: undefined,
receipt: undefined,
data: undefined,
code: 402
The wallet address already has 0.089433739508822183 ETH. The Contract is deployed on the Sepolia Testnet.
4