Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with network #4574

Open
printerwhale opened this issue Feb 2, 2024 · 1 comment
Open

Issue with network #4574

printerwhale opened this issue Feb 2, 2024 · 1 comment
Assignees
Labels
investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5

Comments

@printerwhale
Copy link

printerwhale commented Feb 2, 2024

Ethers Version

5.7.2

Search Terms

No response

Describe the Problem

I have the following code :

    const wallet = new ethers.Wallet(process.env.PRIVATE_KEY_AVAX, provider);
    const contract = new ethers.Contract(process.env.ERC721_POTION_ADRESS, abi, wallet);
    const functionName = 'safeMint';
    const type = Math.floor(Math.random() * 3) + 1;
    const functionArgs = [address,type]; 
    const transaction = await contract[functionName](...functionArgs);
    const receipt = await transaction.wait();
    console.log(`Confirmed transaction. Hash: ${receipt.transactionHash}`);

And I always get : "Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)"

Code Snippet

    const provider = new ethers.providers.JsonRpcProvider("https://avalanche-fuji.infura.io/v3/API_KEY");
    const wallet = new ethers.Wallet(process.env.PRIVATE_KEY_AVAX, provider);
    const contract = new ethers.Contract(process.env.ERC721_POTION_ADRESS, abi, wallet);
    const functionName = 'safeMint';
    const type = Math.floor(Math.random() * 3) + 1;
    const functionArgs = [address,type]; 
    const transaction = await contract[functionName](...functionArgs);
    const receipt = await transaction.wait();
    console.log(`Confirmed transaction. Hash: ${receipt.transactionHash}`);

Contract ABI

No response

Errors

Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)

Environment

No response

Environment (Other)

No response

@printerwhale printerwhale added investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5 labels Feb 2, 2024
@printerwhale
Copy link
Author

It happens with nextjs 14 and Ethers 5. After upgrading to Ethers v6, the issue has been solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v5 Issues regarding legacy-v5
Projects
None yet
Development

No branches or pull requests

2 participants