SDK & Code Examples
Example integrations for agents or backend services. These snippets show how to deposit and withdraw using the SnowMind API.
TypeScript / JavaScript
Basic Client
import axios from "axios";
const SNOWMIND_API = "https://api.snowmind.xyz/api/v1";
export class SnowMindClient {
constructor(private authToken: string) {}
private headers() {
return {
Authorization: `Bearer ${this.authToken}`,
"Content-Type": "application/json",
};
}
async deposit(address: string, payload: {
allowedProtocols: string[];
fundingTxHash: string;
fundingAmountUsdc: string;
allocationCaps?: Record<string, number>;
triggerRebalance?: boolean;
}) {
return axios.post(
`${SNOWMIND_API}/accounts/${address}/deposit`,
{
...payload,
triggerRebalance: payload.triggerRebalance !== false,
},
{ headers: this.headers() }
).then((res) => res.data);
}
async previewWithdrawal(address: string, payload: {
smartAccountAddress: string;
withdrawAmount: string;
isFullWithdrawal: boolean;
}) {
return axios.post(
`${SNOWMIND_API}/withdrawals/preview`,
payload,
{ headers: this.headers() }
).then((res) => res.data);
}
async executeWithdrawal(payload: {
smartAccountAddress: string;
withdrawAmount: string;
isFullWithdrawal: boolean;
ownerSignature: string;
signatureMessage: string;
signatureTimestamp: number;
}) {
return axios.post(
`${SNOWMIND_API}/withdrawals/execute`,
payload,
{ headers: this.headers() }
).then((res) => res.data);
}
}Withdrawal Signature Flow
The owner wallet must sign the authorization message each time. The agent can request a signature from the user wallet and then call the execute endpoint.
Signatures Are Required
A withdrawal cannot be executed without an owner signature. Agents need access to wallet signing (WalletConnect, extension, or user approval).
Python
Basic Client
import requests
class SnowMindClient:
def __init__(self, token: str):
self.base = "https://api.snowmind.xyz/api/v1"
self.headers = {"Authorization": f"Bearer {token}"}
def deposit(self, address, payload):
url = f"{self.base}/accounts/{address}/deposit"
res = requests.post(url, json=payload, headers=self.headers)
res.raise_for_status()
return res.json()
def preview_withdrawal(self, payload):
url = f"{self.base}/withdrawals/preview"
res = requests.post(url, json=payload, headers=self.headers)
res.raise_for_status()
return res.json()
def execute_withdrawal(self, payload):
url = f"{self.base}/withdrawals/execute"
res = requests.post(url, json=payload, headers=self.headers)
res.raise_for_status()
return res.json()Getting the Privy Token
The agent needs a valid Privy session token for the user. You can obtain it after login from your app backend or from the browser session.
Security Tip
Never store tokens or wallet keys in plaintext. Use secure storage and rotate tokens regularly.