trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 676 forks source link

Getting "insufficient funds" error although it seems like I have funds. #4168

Closed benams closed 1 year ago

benams commented 1 year ago

I'm trying to replay this transaction using my code:

const transaction = {
    from: '0x5b5a922e065a425ee7e9b70185ba563ef270afcd',
    to: '0xa5025faba6e70b84f74e9b1113e5f7f4e7f4859f',
    value: '0x' + (90000000000000000).toString(16), // value in wei
    data: '0x8e031cb6000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000c4a0d67800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001900000000000000000000000060b33034dcb74f32fec91f3636149c88bc6cb8af00000000000000000000000000000000000000000000000000000000a0d4fb34000000000000000000000000e2a3c03c9585b01f76fe2d7ea0f3e9a6eefb9ded00000000000000000000000000000000000000000000000000000000430e23400000000000000000000000003b9d4ebc664e447bcb58d735ddcd142506bd685d00000000000000000000000000000000000000000000000000000000430e2340000000000000000000000000dfb30590bcfbbe60f332c9082d3584bf24b8237200000000000000000000000000000000000000000000000000000000b2b3c1c800000000000000000000000027ccfb2b04e5be79d98d41eddc6c4c362829e01b000000000000000000000000000000000000000000000000000000009502f900000000000000000000000000e565d5b3197d7fa0f264ed170edc3783b06aa5880000000000000000000000000000000000000000000000000000000193d24bc000000000000000000000000069188b028f692028d3167504b3a02649db46ea9800000000000000000000000000000000000000000000000000000000cf4b65e800000000000000000000000002b1ccde97a82c5d560fca5e2d2f6faa5fc03a2d00000000000000000000000000000000000000000000000000000000566d3e800000000000000000000000003059945877c4e40a5032781614664e334f1a05d300000000000000000000000000000000000000000000000000000000566d3e80000000000000000000000000077e43dcca20da9859daa3fd78b5998b81f794f700000000000000000000000000000000000000000000000000000000b2b3c1c80000000000000000000000003d4bbd322373e3627eb05e433e1d4d4a0c2b53e3000000000000000000000000000000000000000000000000000000015e419a88000000000000000000000000de23b22e95d4d0627c764abdd3a8cf68eddd59240000000000000000000000000000000000000000000000000000000092080880000000000000000000000000307b9570a666ff9567ce7907c58903135b319c6d0000000000000000000000000000000000000000000000000000000092080880000000000000000000000000c51262a2f7a3ed9b34ca903c02dbae018b477e7700000000000000000000000000000000000000000000000000000001b075926400000000000000000000000058ad9d4fe350df9a5aaf14c8c6a8210fb484a57100000000000000000000000000000000000000000000000000000000b44dd640000000000000000000000000ba18744e906de36dff47eb196f52d86d46fac367000000000000000000000000000000000000000000000000000000000e4bd210000000000000000000000000da9fc70b4bbbb3fd1aad7103f90727084f56e1540000000000000000000000000000000000000000000000000000000005f5e100000000000000000000000000624e40d9030c95042112a472a06da78dc35a2cc20000000000000000000000000000000000000000000000000000000007735940000000000000000000000000121ea239e02ada2717052469e9e4d1cd6f7fe50c00000000000000000000000000000000000000000000000000000000b2b3c1c8000000000000000000000000329b07d82df5ada2efee4ed43c88052da95a8ffa000000000000000000000000000000000000000000000000000000004a817c8000000000000000000000000071832f36517f88e14b5ed0c185834e11ebce9e03000000000000000000000000000000000000000000000000000000000392f484000000000000000000000000faae5ebf0a1fc16044af18917aa5e467ca2b401700000000000000000000000000000000000000000000000000000000017d7840000000000000000000000000123e4a1322a3e10e4b78ce7f0ce9df2b8a2581dc000000000000000000000000000000000000000000000000000000000ab8dd8c00000000000000000000000021627745bf03c265b0965ab159daa0745627a93200000000000000000000000000000000000000000000000000000000047868c000000000000000000000000059282bace81cc22fa46691d2338b4b7f670e6b7a00000000000000000000000000000000000000000000000000000000047868c0',
    gasPrice: '0x' + (12208148709).toString(16),
    gas: '0x' + (793721).toString(16),
    nonce: '0x' + (1974).toString(16)
}

const provider = ganache.provider({
    fork: { network: "mainnet", blockNumber: 16245181 },
    wallet: {
        unlockedAccounts: [
              "0x5b5a922e065a425ee7e9b70185ba563ef270afcd"
        ]
    },
    chain: {
        chainId: 1
    }
});

let rawTransaction = typeof transaction === 'string' ? transaction : await provider.request({
    method: 'eth_signTransaction',
    params: [transaction]
});
let transactionHash: string = '';
try {
    transactionHash = await provider.request({
        method: "eth_sendRawTransaction",
        params: [rawTransaction]
    });
} catch (err) {
    console.error(`[ERROR] Could not execute the transaction: ${err.message}`)
}

I always get the error: "[ERROR] Could not execute the transaction: insufficient funds for gas price + value", although it looks like this account have a balance of 99151525241130818179, while `gas price + value` = 99689864001456200