Skip to main content

Python SDK for preparing and locally signing Swig wallet transactions

Project description

Swig Developer SDK for Python

Python parity for @swig-wallet/developer-sdk. The Swig API prepares wallet transactions; this SDK invokes application-owned signers and inserts signatures locally with solders.

pip install swig-developer-sdk

Prepare a transaction

from swig_developer_sdk import SwigClient

swig = SwigClient(api_key="swig_...", network="devnet")
wallet = swig.wallets.use(
    "SWIG_CONFIG_ADDRESS",
    requester_authority={"ed25519": {"publicKey": "USER_PUBLIC_KEY"}},
)

prepared = await wallet.transfer.sol(
    fee_payer="FEE_PAYER",
    destination="DESTINATION",
    amount=1_000_000,
)

Use wallet.build_transaction(...) to supply raw Solana instructions for the backend to wrap in the Swig signing flow. The returned transaction is still signed and submitted client-side.

wallet.transfer(...) and wallet.swap(...) are callable like their TypeScript counterparts. Their explicit sol, token, spl_token, and jupiter methods are available as well.

Sign locally

The generic signer helper works with an application-owned Ed25519 signer. The Swig signer helper patches secp256r1 or secp256k1 signatures into both legacy and versioned Solana transactions without sending signing material to the API.

from swig_developer_sdk import sign_prepared_swig_transaction

signed = await sign_prepared_swig_transaction(
    prepared,
    secp256r1=application_passkey_signer,
)

WebAuthn and EIP-1193 adapters are callback-based so applications can connect their browser, hardware, wallet, or remote signer without changing the transaction preparation API.

Local end-to-end test

With the swig-dev-portal Tilt stack running, this command seeds a temporary local API key and exercises wallet creation, real P-256 signing, direct and grouped SOL transfers, an SPL-token transfer, and the Python proxy through the Developer API. It also verifies the live paymaster balance endpoint and a sponsored transfer where the user pays no network fee. Every transaction is submitted to Surfpool and verified on-chain; the paymaster flow also retries with the same idempotency key and verifies that no balance changes repeat.

bun run e2e:developer-sdk:python

The defaults are http://localhost:8080 for the Developer API, http://localhost:8899 for Surfpool, and the Tilt Postgres instance on port 55432. Override them with SWIG_TRANSACTION_API_URL, SOLANA_RPC_URL, or SWIG_DATABASE_URL.

Jupiter and recovery are not counted by this local test: Jupiter needs a mainnet-backed Surfpool, while recovery setup needs a reachable operator signer.

See the repository-level parity matrix for the complete mapped surface.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swig_developer_sdk-0.7.0.tar.gz (81.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swig_developer_sdk-0.7.0-py3-none-any.whl (35.3 kB view details)

Uploaded Python 3

File details

Details for the file swig_developer_sdk-0.7.0.tar.gz.

File metadata

  • Download URL: swig_developer_sdk-0.7.0.tar.gz
  • Upload date:
  • Size: 81.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for swig_developer_sdk-0.7.0.tar.gz
Algorithm Hash digest
SHA256 5b0e755225248677920b3395f339fb1644030ebe0072c25edfd436df051c86a6
MD5 8dec49f0446a12c9ccfb0119829e30a2
BLAKE2b-256 0c825766c5b8918022d54644cd4b9a49d95b7dc1486e17905557566f46810840

See more details on using hashes here.

Provenance

The following attestation bundles were made for swig_developer_sdk-0.7.0.tar.gz:

Publisher: publish-python.yml on anagrambuild/swig-ts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swig_developer_sdk-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for swig_developer_sdk-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc8ab19f39a771e83719d05fbde1722e4ee27083542a481f8435a1e733df2b11
MD5 35c1fb0e290eea1e17aff81192683a89
BLAKE2b-256 93f7b5aa1cb040029ee59ff0547c837a7f71aa325a9d69606c56427ad72dd307

See more details on using hashes here.

Provenance

The following attestation bundles were made for swig_developer_sdk-0.7.0-py3-none-any.whl:

Publisher: publish-python.yml on anagrambuild/swig-ts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page