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 withAccountSequence.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_floorcomputes the minimum for a list of messages. - A regular tx pays its fee in the margin denom from the account's bank balance, not from the trading subaccount; a tx signed by an agent key is paid by the account it signs for.
- 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_tickrounds bids down and asks up. UserOrdersmay not list every short-term order; read the book withOrderBook.
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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| neutronx_sdk-0.1.1.tar.gz | 60.1 kB | With provenance | Details for neutronx_sdk-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| neutronx_sdk-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for neutronx_sdk-0.1.1-py3-none-any.whl |
Total release size: 109.8 kB
Release files / neutronx_sdk-0.1.1.tar.gz
| Download URL | neutronx_sdk-0.1.1.tar.gz |
|---|---|
| Size | 60.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f1767ea8a75c5510eecf5adc3e9ee107b75cf9966c93e07cd2270ace33e04da
|
|
BLAKE2b-256 checksum How to use checksums |
a5fed820554d806d533064155356aa06f4b530796e430925cf0bafc37c188629
|
| 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 logRelease files / neutronx_sdk-0.1.1-py3-none-any.whl
| Download URL | neutronx_sdk-0.1.1-py3-none-any.whl |
|---|---|
| Size | 49.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
56fc3a2dc9584b939d94787a453336a1766afa771bc3470429ca4b3c00ecffaa
|
|
BLAKE2b-256 checksum How to use checksums |
c160837ec7d264c4cbee1a622df7180f8b714e60f84870d44012df23a11e82a3
|
| 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 logSecurity for neutronx-sdk 0.1.1
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.
Attestation for neutronx_sdk-0.1.1.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 logA 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.