Network Basics

Tokens

Stacks (STX) tokens are the native tokens on the Stacks blockchain. The smallest fraction is one micro-STX. 1,000,000 micro-STX make one Stacks (STX).

STX amounts should be stored as integers (8 bytes long), and represent the amount of micro-STX.

Fees

Fees are used to incentivize miners to confirm transactions on the Stacks blockchain. The fee is calculated based on the estimate fee rate and the size of the raw transaction in bytes. The fee rate is a market determined variable. For the testnet, it is set to 1 micro-STX.

Fee estimates can obtained through the GET /v2/fees/transferarrow-up-right endpoint of the API.

circle-info

Note that this example uses an external tool, Hiro's Stacks APIarrow-up-right. You can also use the native Stacks API envelopeif you would rather run your own node or connect to one.

The API will respond with the fee rate (as integer):

The Stacks Transactions JS libraryarrow-up-right supports fee estimation for:

  • token transfers (estimateTransfer)

  • contract deploys (estimateContractDeploy)

  • non read-only contract calls (estimateContractFunctionCall)

circle-info

For an implementation using a different language than JavaScript, please review this reference implementationarrow-up-right.

Nonces

Every account carries a nonce propertyarrow-up-right that indicates the number of transactions processed for the given account. Nonces are one-time codes, starting at 0 for new accounts, and incremented by 1 on every transaction.

Nonces are added to all transactions and help identify them in order to ensure transactions are processed in order and to avoid duplicated processing.

circle-info

The consensus mechanism also ensures that transactions aren't "replayed" in two ways. First, nodes query its unspent transaction outputs (UTXOs) in order to satisfy their spending conditions in a new transaction. Second, messages sent between nodes review sequence numbers.

When a new token transfer transaction is constructed, the most recent nonce of the account needs to be fetched and set.

circle-info

The API provides an endpoint to simplify nonce handlingarrow-up-right.

Querying

Stacks network details can be queried using the Stacks Blockchain APIarrow-up-right.

Health check

The status checkerarrow-up-right is a service that provides a user interface to quickly review the health of the Stacks blockchain.

Network info

The network information can be obtained using the GET /v2/infoarrow-up-right endpoint:

Sample response:

Last updated

Was this helpful?