Quick Start
Get up and running with the current SW4P SDK contract.
Installation
bash · npm
npm install @sw4p/sdk
bash · pnpm
pnpm add @sw4p/sdk
bash · yarn
yarn add @sw4p/sdk
toml · Rust (Cargo.toml)
[dependencies]
sw4p-sdk = { path = "../sw4p/sdk/rust" }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
Get an API Key
Visit Developer Console
Go to console.sw4p.io
Create API Key
Open API Keys and create a new key
Store It Securely
Copy the sk_555_live_... value immediately
TypeScript Example
typescript
import { Sw4pClient } from "@sw4p/sdk";
const client = new Sw4pClient({ apiKey: "sk_..." });
const estimate = await client.estimate({
from: "BASE",
to: "SOLANA",
amount: "100.00",
});
const result = await client.transfer({
from: "BASE",
to: "SOLANA",
amount: "100.00",
recipient: "RecipientSolanaAddress...",
permit: signedPermit, // produced by your wallet flow
});
const status = await client.status(result.intent_id);
console.log(status.status);
Rust Example
rust
use sw4p_sdk::{Chain, EstimateParams, Sw4pClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Sw4pClient::new("sk_...");
let estimate = client
.estimate(&EstimateParams {
from: Chain::Base,
to: Chain::Solana,
amount: "100.00".to_string(),
speed: None,
})
.await?;
println!("fee: {}", estimate.fee.total);
Ok(())
}
Status Model
The shared helper status phases are:
| Phase | Meaning |
|---|---|
pending | request accepted |
processing | route executing |
complete | settlement finished |
failed | settlement failed |