Closed manishraana closed 2 months ago
Hi @manishraana
Thank you for reporting this. Could you please provide me code example that demonstrates this problem?
we are using this code for deploying a token registry
import { TradeTrustToken__factory } from "@govtechsg/token-registry/contracts"
const deployTokenRegistry = async (
registryName: string,
registrySymbol: string,
titleEscrowFactoryAddress: string,
signer: Signer
) => {
const factory = new TradeTrustToken__factory(signer)
const tokenRegistry = await factory.deploy(
registryName,
registrySymbol,
titleEscrowFactoryAddress
)
tokenRegistry.deploymentTransaction()
return await tokenRegistry.getAddress()
}
and this for deploying the document store
const deployDocumentStore = async (signer: Signer) => {
try {
const factory = new DocumentStoreFactory(signer)
const documentStore = await factory.deploy(
"My Document Store",
await signer.getAddress()
)
documentStore.deploymentTransaction()
return await documentStore.getAddress()
} catch (error) {
console.log(error);
throw error;
}
}
@manish-raana
When we deploy a token registry or document store, it is a contract deployment transaction.
Note that there is no "to" address for a contract deployment transaction.
This is because when a contract is deployed, it does not have an address yet, as it does not exist on the blockchain. Therefore, the "to" field in the transaction is null.
@rongquan1
You are correct, this is a contract deployment transaction.
Our codebase used to work earlier on Polygon as well but recently it is causing this issue. We tried the same codebase on other chains like XDC Apothem or XDC Mainnet and on those chains it is working perfectly fine.
The only issue we are facing with polygon Mainnnet or polygon amoy chains.
Can you provide us some sample code where we can try it is working on a polygon chains? Is it working for you or your team on Polygon Ecosystem?
Please guide us to resolve this issue.
@manishraana
Can you provide the exact line of code that is causing this error?
From your previous description, it seems like you are trying to read the "to" field. As mentioned earlier, this value is null because it is a contract deployment transaction. If you are trying to get the address of the deployed token registry/document store, you should use the "contractAddress" field.
Hi @rongquan1,
const tokenRegistry = await factory.deploy(
registryName,
registrySymbol,
titleEscrowFactoryAddress
)
This is the exact line which is causing the issue while deploying, we are using the 0x5B5F8d94782be18E22420f3276D5ef5a1bc65C53 as a TitleEscrowFactory contract, we took this address from this repository https://github.com/TradeTrust/token-registry/blob/d45bee2863eb0d0c02585494e4b1c04dec5d320d/src/constants/contract-address.ts#L14
We are using the exact same code for XDC Mainnet and it is working perfectly fine and creating the token registry contract and returning it. But in case of Polygon Mainnet the transaction is getting executed on the blockchain side, but from SDK it is throwing the error.
@manishraana
Can you confirm if the transaction did get executed on the Polygon mainnet
?
Please also provide the library and its version you are using to call this function, as well as your ethers version.
@rongquan1
Yes, transaction got executed on Polygon Mainnet, you can find it here, https://polygonscan.com/tx/0x0eb22aee8255d1e2c0759992161d1628b3d554e96f78f9e31c94ab145348c74e
we are using this library
"@govtechsg/token-registry": "^4.3.0",
"ethers": "^6.10.0"
@manishraana
We recommend using @tradetrust-tt/token-registry
instead. Our library is developed using Ethers v5 and has been thoroughly tested. Ethers v6 might have some compatibility issues. Are you able to switch and try if it works?
@manishraana is it working for you after going back to Ethers v5?
Hi @rongquan1,
I tried with using @tradetrust-tt/token-registry module with Ethers v5, but still I am facing the same issue on ### Polygon Mainnet.
I tried on XDC chain with the same module and ### Ethers v5, it is working properly fine on XDC Mainnet.
Hi @rongquan1,
Any update on this ?
Hi @manish-raana,
Estimating gas fees on the Polygon network can sometimes be problematic. We might need to manually set the gas price and gas limit to ensure our transactions are processed efficiently. For more information, you can see this article and see how we handled it: Polygon Mainnet Workaround and see if it works for you.
ok let me try that, But I think that is not the case because the txn is going through successfully on blockchain.
@manishraana
Sure, give it a try and remember to use Ethers v5. This seems like a network-specific issue, as it is only happening on the Polygon mainnet in your case. Let me know what you find.
Hi @rongquan1,
It worked with custom gas from gas station, worked on both ethers v5 and ethers v6.
Thanks for the help.
We're encountering an issue specifically on the Polygon Mainnet where transactions are failing due to an invalid address error. The error message is as follows:
Error: invalid value for value.to (invalid address (argument="address", value="", code=INVALID_ARGUMENT, version=6.11.1)) (value={ "accessList": [], "blockHash": null, "blockNumber": null, "chainId": "0x89", "from": "0x3225E23c732763Ed284f22df7E7f71139C3c6CC6", "gas": "0x10e1c0", "gasPrice": "0x176487b88a", "hash": "0xf3135b39595c068fc943802bcd3589e10a88a279fd6e62df3c35fd4149dae336", "input": ....
This issue does not occur on other networks, only on the Polygon Mainnet.
Steps to Reproduce
Expected Behavior
The transaction should be processed without any errors regarding invalid addresses.
Actual Behavior
The transaction fails with an error indicating an invalid address for the
value.to
field.We tried with same code on other networks and it is working perfectly fine.
Another observation we did is when we creating document store, the transaction getting executed on the blockchain side but on the ui we are getting this error from the sdk.
Additional Context
value.to
field in the transaction object might be empty or incorrectly formatted.Any insights or suggestions on how to resolve this issue would be greatly appreciated.