Cashmere Agent SDK
The official TypeScript SDK for programmatic and AI-agent-driven USDC transfers:
npm install @cashmerelabs/cashmere-agent-sdk
import { CashmereCCTP } from '@cashmerelabs/cashmere-agent-sdk';
const cctp = new CashmereCCTP({
evm: { privateKey: process.env.EVM_PRIVATE_KEY },
});
// Simulate first
const sim = await cctp.simulate({ from: 'ethereum', to: 'arbitrum', amount: '100' });
// Then execute
const result = await cctp.transfer({
from: 'ethereum',
to: 'arbitrum',
amount: '100',
recipient: '0xDestinationAddress',
});
The SDK supports all 16 chains, CCTP V1/V2, and includes built-in tool schemas for OpenAI Assistants, LangChain, and crewAI.
See the Agent Integration guide for AI framework-specific setup (LangChain, OpenAI function calling, crewAI).
Direct Integration (No SDK)
You can also integrate without the SDK:
- Call the Gas API to fetch fees and signatures.
- Interact directly with the
CashmereCCTP contracts.
- Use the Monitoring API for analytics and monitoring.
This approach keeps client code transparent and portable across frameworks.
Helper Snippets
TypeScript Utility
/**
* Fetches a signed fee quote for Cashmere transferV2 transactions.
*/
export async function getTransferV2Quote({
localDomain,
destinationDomain,
isNative,
}: {
localDomain: number;
destinationDomain: number;
isNative: boolean;
}) {
const res = await fetch(
'https://gas.cashmere.exchange/getEcdsaSig_native?' +
new URLSearchParams({
localDomain: String(localDomain),
destinationDomain: String(destinationDomain),
isV2: 'true',
isNative: String(isNative),
})
);
if (!res.ok) throw new Error('Gas API error');
return (await res.json()) as {
fee: string;
deadline: string;
signature: string;
isNative: boolean;
cctpVersion: number;
};
}
Go Utility
package cashmere
import (
"encoding/json"
"fmt"
"net/http"
)
type EcdsaQuote struct {
Fee string `json:"fee"`
Deadline string `json:"deadline"`
Signature string `json:"signature"`
IsNative bool `json:"isNative"`
CctpVersion int `json:"cctpVersion"`
}
func GetECDSAQuote(local, dest int, isNative bool) (*EcdsaQuote, error) {
url := fmt.Sprintf("https://gas.cashmere.exchange/getEcdsaSig_native?localDomain=%d&destinationDomain=%d&isV2=true&isNative=%t", local, dest, isNative)
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Gas API returned status %s", resp.Status)
}
var quote EcdsaQuote
if err := json.NewDecoder(resp.Body).Decode("e); err != nil {
return nil, err
}
return "e, nil
}
Rust (Solana Client)
use anyhow::{bail, Result};
use reqwest;
pub async fn get_ed25519_quote(local: u32, dest: u32, is_native: bool) -> Result<Ed25519Quote> {
let url = format!(
"https://gas.cashmere.exchange/getEd25519Sig_native?localDomain={}&destinationDomain={}&isNative={}&version=2",
local, dest, is_native
);
let resp = reqwest::get(&url).await?;
if !resp.status().is_success() {
bail!("gas api error: {}", resp.status());
}
Ok(resp.json::<Ed25519Quote>().await?)
}
Ed25519Quote should mirror the Gas API response fields (signature, message, publicKey, fee, deadline, isNative, version).
Resources