Skip to content

Quickstart: Python SDK

Script PrimeDelta from Python. This gets you from install to a first swap; each step links to the detail.

Real funds

swap_exact_input signs a real transaction. Start on testnet with a dedicated agent wallet, and read Risk & responsible use.

1. Install

Python 3.10+:

pip install "primedelta @ git+https://github.com/PrimeDeltaCorp/primedelta-python.git"

More options (KMS extra, editable install): Install the SDK.

2. Connect and log in

The client needs a signer and an RPC URL. web3_provider_url is required — the SDK has no default RPC.

from decimal import Decimal
from primedelta import PrimeDelta, SwapSide

pd = PrimeDelta(
    private_key="0x…",  # a dedicated agent wallet, not your personal key
    web3_provider_url="https://chain.testnet.primedelta.io",
    network="testnet",
)
pd.login()

Pass either private_key or a signer (KMS, browser, …), never both. See Signing modes. The SDK supports network="dev" and network="testnet".

3. Make sure you can trade

Trading is gated by a KYC-verified, minted Digital Identity:

print(pd.get_account_status())   # aim for AccountStatus.DID_MINTED

If it isn't minted yet, see Log in & claim a Digital Identity.

4. Quote, then swap

Always derive a real minimum-out from a quote — never pass zero.

quote = pd.quote_swap("AMMT1", SwapSide.STABLECOIN_TO_STOCK, Decimal("10"))

tx = pd.swap_exact_input(
    "AMMT1",
    SwapSide.STABLECOIN_TO_STOCK,
    amount_in=Decimal("10"),
    min_amount_out=pd.min_out_from_quote(quote, slippage_bps=100),  # 1%
)
print("swap tx:", tx)

SwapSide.STABLECOIN_TO_STOCK is a buy (dUSD → token); STOCK_TO_STABLECOIN is a sell. Amounts are Decimal. Full walkthrough: Place a swap and Quote & simulate.

5. Check balances

print(pd.get_onchain_balances())   # {"dUSD": Decimal(...), "AMMT1": Decimal(...), ...}

See On-chain balances.

Where next