Skip to main content

Examples

Simple examples for common wallet providers.

import { OwneySDK } from "@owney/sdk";

const owney = new OwneySDK({
apiKey: "your-api-key",
});

async function activateWithMetaMask() {
const provider = window.ethereum;
await owney.connect(provider);
await owney.activateAgent(8453); // Base chain ID
}

Deposit with callback

Use a depositCallback when you want to transfer the asset to the smart wallet yourself. The callback must return the transaction hash.

import { OwneySDK } from "@owney/sdk";

const owney = new OwneySDK({
apiKey: "your-api-key",
});

async function sendUsdcToSmartWallet(params: {
to: string;
chainId: number;
amount: string;
}): Promise<`0x${string}`> {
// Replace this function with your transfer logic (ethers/viem, etc.).
throw new Error("Implement token transfer here");
}

async function depositWithCallback(provider: any) {
if (!owney.isConnected()) {
await owney.connect(provider);
}

// Select the chain once before running fund operations.
await owney.activateAgent(8453);

return owney.deposit({
amount: "100000000", // 100 USDC (6 decimals)
asset: "USDC",
depositCallback: async (smartWalletAddress, chainId, amount) => {
return sendUsdcToSmartWallet({
to: smartWalletAddress,
chainId,
amount,
});
},
});
}