Insufficient funds

I transferred MATIC to fund my ITX gas tank on the Polygon.

TX :Polygon Transaction Hash (Txhash) Details | PolygonScan


const ethers = require("ethers")

const wait = (milliseconds) => {
    return new Promise((resolve) => setTimeout(resolve, milliseconds));
};

function getChainID() {
    switch (process.env.ETHEREUM_NETWORK) {
        case "mainnet":
            return 1;
        case "kovan":
            return 42;
        case "rinkeby":
            return 4;
        case "goerli":
            return 5;
        case "ropsten":
            return 3;
        case "matic":
            return 137;
        default:
            throw new Error("You need to set ETHEREUM_NETWORK in your .env file.");
    }
}

async function main() {
    const itx = new ethers.providers.InfuraProvider(
        process.env.ETHEREUM_NETWORK,
        process.env.INFURA_PROJECT_ID
    );

    const signer = new ethers.Wallet(process.env.SIGNER_PRIVATE_KEY, itx);
    const tx = {
        to: "0x312017dcFa840a3656127e6FBF784a45ea1777d5",
        data: "0x11",
        gas: "50000",
        schedule: "fast",
    };

    const relayTransactionHashToSign = ethers.utils.keccak256(
        ethers.utils.defaultAbiCoder.encode(
            ["address", "bytes", "uint", "uint", "string"],
            [tx.to, tx.data, tx.gas, getChainID(), tx.schedule]
        )
    );
    const signature = await signer.signMessage(
        ethers.utils.arrayify(relayTransactionHashToSign)
    );

    const sentAtBlock = await itx.getBlockNumber();

    const { relayTransactionHash } = await itx.send("relay_sendTransaction", [
        tx,
        signature,
    ]);
    console.log(`ITX relay transaction hash: ${relayTransactionHash}`);

    console.log("Waiting to be mined...");
    while (true) {
        const {
            receivedTime,
            broadcasts,
        } = await itx.send("relay_getTransactionStatus", [relayTransactionHash]);

        // check each of these hashes to see if their receipt exists and
        // has confirmations
        if (broadcasts) {
            for (const broadcast of broadcasts) {
                const { broadcastTime, ethTxHash, gasPrice } = broadcast;
                const receipt = await itx.getTransactionReceipt(ethTxHash);

                if (receipt && receipt.confirmations && receipt.confirmations > 1) {
                    // The transaction is now on chain!
                    console.log(`Ethereum transaction hash: ${receipt.transactionHash}`);
                    console.log(`Sent at block ${sentAtBlock}`);
                    console.log(`Mined in block ${receipt.blockNumber}`);
                    console.log(`Total blocks ${receipt.blockNumber - sentAtBlock}`);
                    return;
                }
            }
        }
        await wait(1000);
    }
}

require("dotenv").config();
main();

When starting the call function, it returns the error Insufficient funds.
anyone can help?

2 Likes

Hey @442234856, thanks for raising this. Indeed am I am seeing that the relay balance for the 0x312017dcfa840a3656127e6fbf784a45ea1777d5 signing address is zero. Let me check internally and get back to you.
Thanks,
Radu

3 Likes

Hello Radu, any replies would be appreciated!

1 Like

Hey @442234856 , sorry for the delay, I am still waiting for internal feedback from our team.

2 Likes