gleeth/nonce
Nonce manager for tracking and auto-incrementing transaction nonces.
Fetches the initial nonce from the network and increments locally on
each call to next, avoiding redundant RPC round-trips when sending
multiple transactions in sequence.
Types
Tracks the current nonce for an address.
Use next to get the next nonce and advance the counter.
pub type NonceManager {
NonceManager(
address: String,
current: option.Option(Int),
provider_url: String,
)
}
Constructors
-
NonceManager( address: String, current: option.Option(Int), provider_url: String, )
Values
pub fn new(
provider: provider.Provider,
address: String,
) -> Result(NonceManager, types.GleethError)
Create a new nonce manager for the given address. Fetches the current pending nonce from the network.
pub fn next(
manager: NonceManager,
) -> Result(#(NonceManager, String), types.GleethError)
Get the next nonce as a hex string and return an updated manager.
The first call returns the nonce fetched during new.
Subsequent calls increment locally without an RPC call.
pub fn reset(
manager: NonceManager,
provider: provider.Provider,
) -> Result(NonceManager, types.GleethError)
Reset the nonce manager by re-fetching the nonce from the network.