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+:
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:
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¶
See On-chain balances.
Where next¶
- Signing modes — pick browser, KMS, or a local key deliberately.
- Orders and Liquidity.
- SDK reference — the full API, generated from the source.