Start a project and test it on a local chain

pyrxd new creates a small app with a working Glyph mint and a test that runs it on a throwaway local Radiant chain. The test passes before you change anything, so you start from green and keep it green.

Create the project

pyrxd new my-token-app
cd my-token-app
pip install -e ".[test]"
pyrxd regtest setup      # once per machine: builds the node image (needs docker)
pytest

pyrxd new writes files and nothing else. It refuses a name that would shadow pyrxd, your tests or a standard-library module, and it never writes into a directory that already has files in it (--dir PATH picks another location).

What you get:

Path

What it is

pyproject.toml

Depends on the pyrxd series that generated it (for example pyrxd>=0.28.0,<0.29), plus pytest as the test extra.

src/<package>/mint.py

mint_nft(client, wallet, pending_dir, name=...), and a main() for python -m <package>.mint.

tests/conftest.py

One line that loads the pyrxd.testing fixtures.

tests/test_mint.py

Mints, then asks the node whether the reveal is mined and which output holds the new token.

.github/workflows/ci.yml

Runs the same three steps on every push.

The test fixtures

pyrxd.testing.pytest_plugin is opt-in. Load it in any project’s conftest.py:

pytest_plugins = ["pyrxd.testing.pytest_plugin"]

Fixture

Scope

Gives you

regtest_node

session

A fresh radiantd -regtest in its own docker container, removed at the end of the run.

regtest_client

test

A client with broadcast and get_transaction_verbose. It mines a block after each broadcast; build RegtestClient(node, auto_mine=False) to hold a transaction in the mempool.

regtest_wallet

test

A new key funded with 10 RXD. It works anywhere GlyphMinter wants a wallet.

regtest_wallet_factory

test

factory(amount_rxd) for a second or third wallet.

The session shares one chain, and every test gets its own wallet. The keys are generated by pyrxd, not by the node’s wallet, so funding one test can never spend another test’s coins.

The node runs at mainnet’s relay floor, and pyrxd.testing refuses to hand back a node that enforces anything lower, so a transaction your test gets mined also clears mainnet’s fee floor.

If docker or the node image is missing, the fixtures fail the test with the command that fixes it. They do not skip, because a skipped chain test reports green.

The helpers under the fixtures (start_test_node, RegtestClient, RegtestWallet) are in pyrxd.testing and do not need pytest, so a script or notebook can use them too.

Make the template from code

pyrxd.starter.render_project(name) returns the project as {path: text} without touching disk, and write_project(name, directory) writes it. Both take overrides={path: text} to replace a file, such as src/<package>/mint.py, with your own code. Override text is written as given.

Moving off regtest

Everything above runs on regtest, whose coins are worthless. For mainnet, pass mint_nft an ElectrumXClient and an HdWallet instead of the regtest pair, and read Troubleshoot common errors first. A test that passes on regtest shows the transaction is valid and clears the fee floor. It says nothing about the security of your keys or your app.