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

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

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

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

await owney.activateAgent(8453);

return owney.deposit({
amount: "100000000", // 100 USDC (6 decimals)
asset: "USDC",
});
}

Gasless WETH deposit

WETH deposits use the same gasless flow, but the first deposit on a chain needs a one-time (user-paid) Permit2 approval. The SDK triggers it automatically; you can also pre-approve it. See Gasless deposits.

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

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

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

await owney.activateAgent(8453);

// Optional: front-load the one-time Permit2 approval (user pays gas).
await owney.approvePermit2("WETH");

return owney.deposit({
amount: "1000000000000000", // 0.001 WETH (18 decimals)
asset: "WETH",
});
}