Developers Forum for XinFin XDC Network

dustinggreenery
dustinggreenery

Posted on

[Solved]XDC Transaction Error

When trying to use tx.wait(1) while under the XDC Apothem testnet, I run into an error:
invalid address (argument="address", value="xdc0000000000000000000000000000000000000000", code=INVALID_ARGUMENT, version=address/5.7.0)

The same functionality works on the sepolia testnet, but not here.

I'm using Moralis in a frontend in this scenario.

Here is the moralis function:
const { runContractFunction: createProductOrder } = useWeb3Contract({
abi: factoryAbi,
contractAddress: factoryAddress,
functionName: "createProductOrder",
params: {
vendorAddress: vendorAddress,
PONo: PONo,
timeToAccept: timeToAccept,
timeToShip: timeToShip,
},
msgValue: moneySent * 10 ** 18,
});

This is the part that handles the transaction, also the origin of the error (The body could just be await tx.wait(1) and the same error would be produced)
const handleCreateContract = async function (tx) {
await tx.wait(1).then((result) => {
setAddress(result.events[0].args.PO);
});
handleNewNotification(tx);
};

This is the button calling this function:
<button onClick={() => createProductOrder({ onSuccess: handleCreateContract })}>New Contract!</button>

I did find this github discussion with the same issue, and one person replied saying it was caused by a different prefix. Is this the case? How can I go about fixing this error?
https://github.com/ethers-io/ethers.js/discussions/3333

Discussion (3)

Collapse
shashankgupta10 profile image
Shashank Gupta • Edited on

Hey I am getting the same error i also changed thr RPC url but to no avail
can you please send me your hardhat config file how you did it?

my code:
require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config({ path: ".env" });

const XINFIN_PRIVATE_KEY = process.env.XINFIN_PRIVATE_KEY;

module.exports = {
solidity: "0.8.0",
networks: {
xinfin: {
url: ["erpc.apothem.network", "apothem.xdcrpc.com", "rpc.apothem.network "], accounts: [XINFIN_PRIVATE_KEY],
},
},
};

Collapse
mitali_blocksscan profile image
Mitali_BlocksScan

Hey @dustinggreenery
You can employ this RPC (erpc.apothem.network/) to effectively address and resolve your concern.
Feel free to ask if you have any query.
Thank you!

Collapse
dustinggreenery profile image
dustinggreenery Author

It worked! Thanks a lot for the help!

Also, sorry for asking a question this late.