Skip to content

SmartAgentKitClient

The main SDK client class for creating and managing policy-governed smart wallets.

Constructor

typescript
new SmartAgentKitClient(config: SmartAgentKitConfig)
ParameterTypeRequiredDescription
config.chainChainYesviem Chain object (e.g. baseSepolia)
config.rpcUrlstringYesJSON-RPC endpoint URL
config.bundlerUrlstringYesERC-4337 bundler URL (Pimlico)
config.paymasterUrlstringNoPaymaster URL for gas sponsorship
config.moduleAddressesModuleAddressesNoCustom module addresses (auto-resolved for Base Sepolia and Sepolia)
typescript
import { SmartAgentKitClient } from "@smartagentkit/sdk";
import { baseSepolia } from "viem/chains";

const client = new SmartAgentKitClient({
  chain: baseSepolia,
  rpcUrl: "https://base-sepolia.g.alchemy.com/v2/...",
  bundlerUrl: "https://api.pimlico.io/v2/base-sepolia/rpc?apikey=...",
});

Methods

createWallet

typescript
createWallet(params: CreateWalletParams): Promise<AgentWallet>

Deploy a new policy-governed smart wallet.

ParameterTypeRequiredDescription
params.ownerAddressYesOwner address
params.ownerPrivateKeyHexNoOwner private key
params.ownerMnemonicstringNoOwner mnemonic phrase
params.addressIndexnumberNoHD derivation index (default: 0)
params.policiesPolicyConfig[]NoArray of policy configurations
params.presetPresetNameNoNamed preset (defi-trader, etc.)
params.presetParamsRecord<string, unknown>NoOverride preset defaults
params.saltbigintNoCREATE2 salt for deterministic addresses

Returns: AgentWallet with address, owner, chain, isDeployed, policies, sessions.

Throws: WalletCreationError

typescript
const wallet = await client.createWallet({
  owner: "0x...",
  ownerPrivateKey: "0x...",
  preset: "defi-trader",
});

connectWallet

typescript
connectWallet(walletAddress: Address, ownerKey: SignerKey): Promise<void>

Reconnect to an existing deployed wallet.

ParameterTypeRequiredDescription
walletAddressAddressYesAddress of the deployed wallet
ownerKeySignerKeyYesOwner private key or mnemonic credential

Throws: WalletCreationError

execute

typescript
execute(wallet: AgentWallet, params: ExecuteParams): Promise<Hex>

Execute a single transaction through the smart wallet.

ParameterTypeRequiredDescription
walletAgentWalletYesWallet instance from createWallet
params.targetAddressYesTarget contract address
params.valuebigintNoETH value to send (default: 0)
params.dataHexNoCalldata
params.sessionKeyHexNoSession key private key

Returns: Transaction hash (Hex).

Throws: ExecutionError, SpendingLimitExceededError, WalletPausedError

typescript
const txHash = await client.execute(wallet, {
  target: "0xRecipient...",
  value: parseEther("0.1"),
});

executeBatch

typescript
executeBatch(wallet: AgentWallet, params: ExecuteBatchParams): Promise<Hex>

Execute multiple transactions atomically. All calls succeed or all revert.

ParameterTypeRequiredDescription
walletAgentWalletYesWallet instance
params.callsExecuteParams[]YesArray of calls
params.sessionKeyHexNoSession key private key

Returns: Transaction hash (Hex).

Throws: ExecutionError, SpendingLimitExceededError, WalletPausedError

typescript
const txHash = await client.executeBatch(wallet, {
  calls: [
    { target: "0xA...", value: parseEther("0.05") },
    { target: "0xB...", data: "0x..." },
  ],
});

getRemainingAllowance

typescript
getRemainingAllowance(walletAddress: Address, token: Address): Promise<bigint>

Check remaining spending allowance for a token in the current window.

Use NATIVE_TOKEN (0x0000000000000000000000000000000000000000) for ETH.

typescript
import { NATIVE_TOKEN } from "@smartagentkit/sdk";

const remaining = await client.getRemainingAllowance(wallet.address, NATIVE_TOKEN);

isPaused

typescript
isPaused(walletAddress: Address): Promise<boolean>

Check if a wallet is currently paused.

getBalances

typescript
getBalances(walletAddress: Address): Promise<{
  eth: bigint;
  tokens: Array<{ address: Address; balance: bigint }>;
}>

Get ETH and tracked token balances for a wallet.

pause

typescript
pause(walletAddress: Address, guardianKey: SignerKey): Promise<Hex>

Emergency pause -- freezes all wallet activity. This is a direct contract call (not a UserOp).

Throws: ExecutionError

unpause

typescript
unpause(walletAddress: Address, guardianKey: SignerKey): Promise<Hex>

Unpause the wallet. This is a direct contract call.

Throws: ExecutionError

createSession

typescript
createSession(
  wallet: AgentWallet,
  params: CreateSessionParams,
  ownerKey: SignerKey
): Promise<{ sessionKey: Address; privateKey: Hex; permissionId: Hex }>

Create a scoped session key for an agent.

ParameterTypeRequiredDescription
walletAgentWalletYesWallet instance
params.actionsSessionAction[]YesAllowed target/selector pairs
params.expiresAtnumberYesUnix timestamp in seconds
params.spendingLimitsTokenLimit[]NoSession-specific spending limits
ownerKeySignerKeyYesOwner key for signing enable data

Returns: Object with sessionKey address, privateKey, and permissionId.

Throws: SessionError

typescript
const session = await client.createSession(
  wallet,
  {
    actions: [{ target: "0xDex...", selector: "0xa9059cbb" }],
    expiresAt: Math.floor(Date.now() / 1000) + 3600,
  },
  ownerPrivateKey
);

revokeSession

typescript
revokeSession(wallet: AgentWallet, permissionId: Hex, ownerKey: SignerKey): Promise<void>

Revoke a session key on-chain.

Throws: SessionError

getActiveSessions

typescript
getActiveSessions(walletAddress: Address): ActiveSession[]

Get active (non-expired) sessions.

WARNING

Sessions are stored in-memory only and do not persist across process restarts.

Released under the MIT License.