Create a wallet
Deploy a KryptWarden smart wallet and fund it with Testnet USDC.
Each owner gets their own wallet contract, deployed by the factory. The wallet holds the USDC your agents spend.
Before you start
You need a Stellar wallet extension (Freighter, xBull or Lobstr) on Testnet, with:
- Testnet XLM for your own fees, from Friendbot.
- A USDC trustline for issuer
GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5. - Testnet USDC from the Circle faucet.
In the dashboard
Open www.kryptwarden.xyz/dashboard and click Connect wallet.
Open Wallet & Kill Switch and click Deploy wallet · 1 signature. Your extension asks you to sign one deploy_wallet call to the factory. When it lands, the dashboard switches to your new wallet and shows its C… address.
Enter an amount and click Deposit. This signs a USDC transfer from your account to the wallet.
The dashboard remembers the wallet in the URL (/dashboard?wallet=C…), so you can bookmark it.
From code
The factory's deploy_wallet(owner, salt) takes your address and any 32 random bytes, and returns the new wallet's address. The owner must authorise the call.
import * as Stellar from "@stellar/stellar-sdk";
import { randomBytes } from "node:crypto";
const FACTORY = "CBZF662RUYLPS3UCSRQ2XJHMF6YMFZKHBUXHAIDRYNDAAUXWAGEV5XPR";
const rpc = new Stellar.rpc.Server("https://soroban-testnet.stellar.org");
const owner = Stellar.Keypair.fromSecret(process.env.OWNER_SECRET!);
const account = await rpc.getAccount(owner.publicKey());
const tx = new Stellar.TransactionBuilder(account, {
fee: "1000000",
networkPassphrase: Stellar.Networks.TESTNET,
})
.addOperation(
new Stellar.Contract(FACTORY).call(
"deploy_wallet",
Stellar.Address.fromString(owner.publicKey()).toScVal(),
Stellar.xdr.ScVal.scvBytes(randomBytes(32)),
),
)
.setTimeout(60)
.build();
const prepared = await rpc.prepareTransaction(tx);
prepared.sign(owner);
const sent = await rpc.sendTransaction(prepared);
const result = await rpc.pollTransaction(sent.hash);
if (result.status !== "SUCCESS") throw new Error(`deploy failed: ${result.status}`);
console.log("wallet:", Stellar.scValToNative(result.returnValue!));Then fund it with a normal USDC transfer to that address. List your wallets any time with the factory's get_wallets_by_owner(owner).
Taking money out
Only the owner can withdraw(to, amount), and only the unreserved balance: the balance minus every open hold. Asking for more fails with InsufficientUnreservedBalance (126). The dashboard's Withdraw form shows the unreserved amount.