Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions developer-sdk/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Server-Side Developer SDK"
sidebarTitle: "Overview"
---

The Swig Developer SDK is a server-side toolkit for TypeScript and Python.
The Swig Developer SDK is a server-side toolkit for TypeScript, Python, and Rust.
It authenticates to Swig's hosted API, prepares wallet operations as unsigned
transactions, reads wallet state, and submits transactions your application
has signed.
Expand Down Expand Up @@ -35,9 +35,20 @@ creation and ParticipantSet support. Requires Python 3.10 or later.

</Tab>

<Tab title="Rust">

```bash
cargo add swig-developer-sdk@0.1.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Publish the crate before documenting this installation command

cargo +1.87.0 info swig-developer-sdk@0.1.0 currently fails with could not find swig-developer-sdk@0.1.0 in registry, so a new Rust user cannot get past the documented installation step. Please publish and verify version 0.1.0 before deploying these docs, or document a working pinned Git installation until the crate is available. The same crates.io instruction in developer-sdk/integration-paths.mdx needs to stay consistent.

```

Rust `0.1.0` requires Rust 1.87 or later. See
[Rust setup](/developer-sdk/integration-paths#rust) for client configuration.

</Tab>

</Tabs>

Both packages live in
All three SDKs live in
[anagrambuild/swig-developer-sdk](https://github.com/anagrambuild/swig-developer-sdk)
and default to `https://api.onswig.com`.

Expand All @@ -50,8 +61,7 @@ and default to `https://api.onswig.com`.
- wallet, role, paymaster, and ramp reads
- fiat ramp order operations, buying and selling
- sponsorship of application-signed transactions and mainnet bundles
- optional signing helpers that combine application-provided signatures with
prepared transactions
- local signing helpers for prepared transactions and participant approvals

## What your application owns

Expand All @@ -62,9 +72,10 @@ and default to `https://api.onswig.com`.
- confirmation and finality tracking after submission

The server SDK returns unsigned prepared transactions and signature-request
metadata. Your application obtains the signature. The optional signing helpers
can assemble that signature into the prepared transaction without receiving an
API key or private key.
metadata. Your application authorizes signing. TypeScript and Python helpers
use application callbacks. Rust also provides native signers that hold
application-supplied local keys. Signing helpers need no API key and make no
hosted request. Keep private keys in the runtime that owns signing.

## Choose the matching Swig product

Expand All @@ -83,7 +94,7 @@ appropriate authority's signature or approval proofs.

<CardGroup cols={2}>
<Card title="Choose a Language" icon="signs-post" href="/developer-sdk/integration-paths">
Initialize a TypeScript or Python server client
Initialize a TypeScript, Python, or Rust server client
</Card>
<Card title="API Keys" icon="key" href="/examples/dev-portal/create-api-key">
Connect your server to Swig's hosted API
Expand Down
53 changes: 40 additions & 13 deletions developer-sdk/integration-paths.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Choose an SDK Language"
sidebarTitle: "Choose a Language"
---

TypeScript and Python expose the same prepare-first server model. Choose the
TypeScript, Python, and Rust expose a prepare-first server model. Choose the
language that owns your trusted application runtime.

## TypeScript
Expand Down Expand Up @@ -37,17 +37,44 @@ swig = SwigClient(
Install from PyPI with `pip install swig-developer-sdk`. Python exposes signing
helpers from the package root.

## Rust

```rust
use std::env;
use swig_developer_sdk::{ClientConfig, Network, PaymasterClient, WalletClient};

let config = ClientConfig::new(env::var("SWIG_API_KEY")?, Network::Devnet);
let wallet = WalletClient::new(config.clone())?;
let paymaster = PaymasterClient::new(config.clone())?;
```

Install from crates.io with `cargo add swig-developer-sdk@0.1.0`.
Requires Rust 1.87 or later. In `Cargo.toml`, set `package.rust-version` to
`"1.87"` and `workspace.resolver` to `"3"` for compatible dependency resolution.
Commit `Cargo.lock` and add the crates imported by your chosen examples.

Reuse the clients and run task snippets in an async, `Result`-returning
function with a runtime such as Tokio. Rust uses native Solana `Pubkey`
addresses and `VersionedTransaction` values.

The network comes from `ClientConfig`. Use `Network::Mainnet` for mainnet
operations and the same network for your confirmation RPC.
Authorize operations before signing. See [Signers](/developer-sdk/signers)
for local signing and [Ramp](/developer-sdk/ramp#required-configuration)
for Ramp client configuration.

## Comparison

| Capability | TypeScript | Python |
| :--- | :--- | :--- |
| Wallet preparation | yes | yes |
| Wallet reads and ramp | yes | yes |
| Custom transactions | yes | yes |
| Sponsorship | yes | yes |
| Application-owned signing helpers | `/signers` | package root |

Both SDKs expose the full server surface: preparation, custom transactions,
wallet reads, ramp, paymaster balance, and sponsorship. Your application owns
its HTTP routes, authentication, authorization, validation, and response
format.
| Capability | TypeScript | Python | Rust |
| :--- | :--- | :--- | :--- |
| Wallet preparation | yes | yes | `WalletClient` |
| Wallet reads | yes | yes | `WalletClient` |
| Ramp | yes | yes | `RampClient` |
| Custom transactions | yes | yes | native `Instruction` inputs |
| Sponsorship | yes | yes | `PaymasterClient` |
| Local signing | `/signers` callbacks | package-root callbacks | native keys and signing traits |

The task pages describe supported operations and language-specific limits.
Rust has no hosted guardian-recovery or rent-claimer methods.
Your application owns its HTTP routes, authentication, authorization,
validation, and response format.
6 changes: 4 additions & 2 deletions overview/developer-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ sidebarTitle: "Developer SDK"
Use the Developer SDK section when a trusted server keeps the API key,
prepares wallet actions, and submits application-signed transactions. The SDK
does not expose the API client or API key in browser or mobile code. These docs
target TypeScript `0.10.0` and Python `0.9.0` from the standalone repository.
Both live in
cover TypeScript, Python, and Rust. All three live in
[anagrambuild/swig-developer-sdk](https://github.com/anagrambuild/swig-developer-sdk).

Start there for:
Expand All @@ -22,6 +21,9 @@ Start there for:
Go to the full Developer SDK documentation
</Card>

Use [Choose a Language](/developer-sdk/integration-paths) for package versions
and client configuration.

<Card title="Open Developer API Reference" icon="code" href="/developer-api">
Use the REST reference when you need endpoint paths and payload shapes
</Card>