Get the latest nonce

Retrieves the latest nonce values used by an account by inspecting the mempool and anchored transactions.

GET
/extended/v1/address/{principal}/nonces

Path Parameters

principalSTX Address & Smart Contract ID

Query Parameters

block_height?integer

Optionally get the nonce at a given block height.

Range1 <= value
block_hash?string

Optionally get the nonce at a given block hash. Note - Use either of the query parameters but not both at a time.

Response Body

The latest nonce values used by an account by inspecting the mempool, microblock transactions, and anchored transactions

TypeScript Definitions

Use the response body type in TypeScript.

last_mempool_tx_nonceinteger | null
last_executed_tx_nonceinteger | null
possible_next_nonceinteger

The likely nonce required for creating the next transaction, based on the last nonces seen by the API. This can be incorrect if the API's mempool or transactions aren't fully synchronized, even by a small amount, or if a previous transaction is still propagating through the Stacks blockchain network when this endpoint is called.

detected_missing_noncesarray<integer>

Nonces that appear to be missing and likely causing a mempool transaction to be stuck.

detected_mempool_noncesarray<integer>

Nonces currently in mempool for this address.

Default Response

TypeScript Definitions

Use the response body type in TypeScript.

errorstring
message?string
[key: string]any
curl -X GET "https://api.hiro.so//extended/v1/address/SP318Q55DEKHRXJK696033DQN5C54D9K2EE6DHRWP/nonces?block_height=66119&block_hash=0x72d53f3cba39e149dcd42708e535bdae03d73e60d2fe853aaf61c0b392f521e9"
fetch("https://api.hiro.so//extended/v1/address/SP318Q55DEKHRXJK696033DQN5C54D9K2EE6DHRWP/nonces?block_height=66119&block_hash=0x72d53f3cba39e149dcd42708e535bdae03d73e60d2fe853aaf61c0b392f521e9")
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {
  url := "https://api.hiro.so//extended/v1/address/SP318Q55DEKHRXJK696033DQN5C54D9K2EE6DHRWP/nonces?block_height=66119&block_hash=0x72d53f3cba39e149dcd42708e535bdae03d73e60d2fe853aaf61c0b392f521e9"

  req, _ := http.NewRequest("GET", url, nil)
  
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := ioutil.ReadAll(res.Body)

  fmt.Println(res)
  fmt.Println(string(body))
}
import requests

url = "https://api.hiro.so//extended/v1/address/SP318Q55DEKHRXJK696033DQN5C54D9K2EE6DHRWP/nonces?block_height=66119&block_hash=0x72d53f3cba39e149dcd42708e535bdae03d73e60d2fe853aaf61c0b392f521e9"

response = requests.request("GET", url)

print(response.text)
{
  "last_mempool_tx_nonce": 0,
  "last_executed_tx_nonce": 0,
  "possible_next_nonce": 0,
  "detected_missing_nonces": [
    0
  ],
  "detected_mempool_nonces": [
    0
  ]
}
{
  "error": "string",
  "message": "string"
}