Skip to main content

neutronx-sdk

Python SDK for the NeutronX perpetuals chain: keys and agent keys, transaction building and signing, short-term orders, gRPC queries and broadcasting.

Install

pip install neutronx-sdk   # or: uv add neutronx-sdk

Python 3.10+.

Quick start

The example places one short-term order on the testnet, signed with an agent key. An agent key trades for an account and cannot withdraw or transfer its funds, so it is the key to give a bot. Agent keys are created at exchange.neutronx.com/api-keys.

import asyncio
import os
from decimal import Decimal

from neutronx_sdk import TESTNET, AccountSequence, NodeClient, OrderRequest, Side, TxBuilder, Wallet
from neutronx_sdk.orders import good_til_block, place_short_term_order_msg


async def main() -> None:
    wallet = Wallet.agent(
        os.environ["NEUTRONX_AGENT_KEY"],
        account=os.environ["NEUTRONX_ACCOUNT"],
        key_id=int(os.environ["NEUTRONX_AGENT_KEY_ID"]),
    )
    async with NodeClient(TESTNET) as client:
        status = await client.node.status()
        sequence = AccountSequence(client.auth, wallet.address, agent=wallet.is_agent)
        slot = await sequence.current()
        request = OrderRequest(
            pair="BTC/USDC",
            side=Side.BUY,
            price=Decimal("65000"),
            quantity=Decimal("0.001"),
            leverage=Decimal("3"),
            client_id=1,
        )
        msg = place_short_term_order_msg(wallet.address, request, good_til_block(status.height))
        tx = TxBuilder(wallet, TESTNET.chain_id).short_term(
            [msg], account_number=slot.account_number, sequence=slot.sequence
        )
        result = await client.tx.broadcast(tx)
        print(result.tx_hash, result.height)


asyncio.run(main())

To sign with the account's own key instead, use Wallet.from_hex(...) or Wallet.from_mnemonic(...). MAINNET is the other built-in network; Network.with_endpoint points either one at a node of your own.

What is in the package

Module Purpose
neutronx_sdk.wallet, neutronx_sdk.crypto keys, addresses, account and agent wallets
neutronx_sdk.orders order requests and the chain messages built from them
neutronx_sdk.tx signing, fees, gas floors, decoding of transaction responses
neutronx_sdk.node gRPC queries, broadcasting, account sequence, TxSender
neutronx_sdk.indexer models and paths of the public indexer API
neutronx_sdk.network MAINNET and TESTNET endpoints

Chain rules the SDK follows

  • Short-term orders live at most 20 blocks past the height they are signed at. A short-term tx pays no fee and does not advance the account sequence: sign it with AccountSequence.current(), sign regular txs with AccountSequence.reserve().
  • A tx that places orders must carry a minimum of gas, and a short-term tx at most the chain's short_term_max_gas_wanted. On chain v1.82 the minimum is 60 000, plus 90 000 per order and 40 000 per cancel, and a cancel by order id costs 15 000 more. Chain v1.81.2 starts from 40 000 and has no extra for cancels by id, so gas sized for the newer rule is accepted by both. neutronx_sdk.tx.tx_prefill_gas_floor computes the minimum for a list of messages.
  • An agent key signs for an account it cannot move funds from. Its txs carry the key id in a non-critical extension and sequence 0; its regular txs are unordered, with a timeout from UnorderedNonce.
  • Limit prices sit on the market's tick grid; snap_to_tick rounds bids down and asks up.
  • UserOrders may not list every short-term order; read the book with OrderBook.

Protobuf isolation

Chain and Cosmos SDK descriptors load into a private descriptor pool, never the global one, so the SDK runs next to other Cosmos SDKs in one process. neutronx_sdk.proto.descriptors_ref() names the chain release they were built from.

The descriptors ship with the package, so using the SDK needs nothing else. They hold only the messages and query methods the SDK uses; the list is in scripts/trim_descriptors.py. scripts/gen_descriptors.sh is the maintainers' tool that rebuilds them for a new chain release. It reads the chain's proto files, which are not public yet, from the checkout named in CHAIN_REPO at the tag named in CHAIN_REF:

CHAIN_REPO=/path/to/chain CHAIN_REF=v1.82.0 scripts/gen_descriptors.sh

Development

git clone https://github.com/neutronx-protocol/neutronx-hummingbot.git
cd neutronx-hummingbot/sdk
uv sync
uv run pytest
uv run pytest -m live        # reads the public testnet; NEUTRONX_LIVE_NETWORK=mainnet for mainnet
uv run ruff check
uv run ruff format --check
uv run pyright

Metadata

Release files for neutronx-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neutronx-sdk 0.1.0
File Size Uploaded Provenance Actions
neutronx_sdk-0.1.0.tar.gz 59.6 kB With provenance Details for neutronx_sdk-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for neutronx-sdk 0.1.0
File Interpreter ABI Platform Actions
neutronx_sdk-0.1.0-py3-none-any.whl Python 3 none any Details for neutronx_sdk-0.1.0-py3-none-any.whl

Total release size: 109.0 kB

Release files / neutronx_sdk-0.1.0.tar.gz

Download URL neutronx_sdk-0.1.0.tar.gz
Size 59.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b9a03d27e365c57ebb6f3f36e63c346af14e388901e8f0e4e615803a53672dcd
BLAKE2b-256 checksum
How to use checksums
87ddf7b8deb75cd13c5fff233af061e2826fa7a6e75057016c171332488b1dd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / neutronx_sdk-0.1.0-py3-none-any.whl

Download URL neutronx_sdk-0.1.0-py3-none-any.whl
Size 49.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
642bbc05fb7fb341f52ceab777554e107c5896aa367d976246f534364445b8c6
BLAKE2b-256 checksum
How to use checksums
aab29fa33fff83237e7361abbc6ca3128feeae89dba257e2b495252cb2246153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for neutronx-sdk 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for neutronx_sdk-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page