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

missing provider (operation="getTransactionCount") despite using version=6.13.4 #4866

Closed
undrcollective opened this issue Oct 22, 2024 · 1 comment
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@undrcollective
Copy link

undrcollective commented Oct 22, 2024

Ethers Version

6.13.4

Search Terms

getNonce

Describe the Problem

I am using version=6.13.4 of ethers.js and when I call the getNonce() function it tells me I need to give a provider.
It was my understanding that if I supply the private key, I do not need to supply a provider considering this is running on a back-end server.
This is the code

    import { ethers } from "ethers";


    const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!);
    const nonce = await wallet.getNonce();

and this is the errror:

Error: missing provider (operation="getTransactionCount", code=UNSUPPORTED_OPERATION, version=6.13.4)
at makeError (.../node_modules/ethers/src.ts/utils/errors.ts:694:21)
at assert (...//node_modules/ethers/src.ts/utils/errors.ts:715:25)
at checkProvider (.../node_modules/ethers/src.ts/providers/abstract-signer.ts:28:5)
at _Wallet.getNonce (.../node_modules/ethers/src.ts/providers/abstract-signer.ts:87:16)
at run (...myFunction.ts:37:34)

getTransactionCount is the old function from v5 that has been wrapped with getNonce I believe?

Should this just work with the private key or did my misunderstand the documentation

Code Snippet

import { ethers } from "ethers";


    const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!);
    const nonce = await wallet.getNonce();

Contract ABI

No response

Errors

Error: missing provider (operation="getTransactionCount", code=UNSUPPORTED_OPERATION, version=6.13.4)
at makeError (.../node_modules/ethers/src.ts/utils/errors.ts:694:21)
at assert (...//node_modules/ethers/src.ts/utils/errors.ts:715:25)
at checkProvider (.../node_modules/ethers/src.ts/providers/abstract-signer.ts:28:5)
at _Wallet.getNonce (.../node_modules/ethers/src.ts/providers/abstract-signer.ts:87:16)
at run (...myFunction.ts:37:34)

Environment

node.js (v12 or newer)

Environment (Other)

No response

@undrcollective undrcollective added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Oct 22, 2024
@undrcollective
Copy link
Author

Ah it seems like this is not a real issue.
Re-reading the docs for v6, it is not possible to get a nonce without a provider.
Not a bug, just confusion between reading different doc versions

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. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants