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

In the EVM client, use PendingNonceAt instead of NonceAt #137

Open
lukerhoads opened this issue Dec 10, 2021 · 0 comments
Open

In the EVM client, use PendingNonceAt instead of NonceAt #137

lukerhoads opened this issue Dec 10, 2021 · 0 comments

Comments

@lukerhoads
Copy link

// AccountNonce returns the current nonce of the account. This is the nonce to
// be used while building a new transaction.
func (client *Client) AccountNonce(ctx context.Context, addr address.Address) (pack.U256, error) {
	targetAddr, err := NewAddressFromHex(string(pack.String(addr)))
	if err != nil {
		return pack.U256{}, fmt.Errorf("bad to address '%v': %v", addr, err)
	}
	nonce, err := client.EthClient.NonceAt(ctx, common.Address(targetAddr), nil)
	if err != nil {
		return pack.U256{}, fmt.Errorf("failed to get nonce for '%v': %v", addr, err)
	}

	return pack.NewU256FromU64(pack.NewU64(nonce)), nil
}

Shouldn't this function use PendingNonceAt? After all, the comment above says that it should be used to craft the next Tx, but in Ethereum docs (https://pkg.go.dev/github.com/ethereum/go-ethereum/ethclient#Client.PendingNonceAt) it says to use PendingNonceAt. Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@lukerhoads and others