Socket
Book a DemoInstallSign in
Socket

@zerodev/cab-sdk

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zerodev/cab-sdk

Chain Abstraction SDK for ZeroDev, built on top of @zerodev/sdk.

0.0.1
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

@zerodev/cab-sdk

Chain Abstraction SDK for ZeroDev, built on top of @zerodev/sdk.

Installation

bun add @zerodev/cab-sdk

Usage

import { createCabClient } from '@zerodev/cab-sdk'
import { mainnet } from 'viem/chains'

const client = createCabClient({
  chain: mainnet,
  bundlerTransport: http(),
  // Optional transports
  intentTransport: http(),
  relayerTransport: http(),
})

// Flow 1: Direct send
const result1 = await client.sendUserIntent({
  calls: [{
    to: '0x...',
    value: 0n,
    data: '0x...'
  }],
  inputTokens: [{
    address: '0x...',
    chainId: 1
  }],
  outputTokens: [{
    address: '0x...',
    amount: 900000n,
    chainId: 10
  }]
})

// Flow 2: Prepare then send
// First prepare the intent
const intent = await client.prepareUserIntent({
  calls: [{
    to: '0x...',
    value: 0n,
    data: '0x...'
  }],
  inputTokens: [{
    address: '0x...',
    chainId: 1
  }],
  outputTokens: [{
    address: '0x...',
    amount: 900000n,
    chainId: 10
  }]
})

// Then send the prepared intent
const result2 = await client.sendUserIntent({
  intent
})

// Wait for the intent to be opened (works for both flows)
const openReceipt = await client.waitForUserIntentOpenReceipt({
  uiHash: result1.uiHash, // or result2.uiHash
});

// Wait for the intent to be executed (works for both flows)
const executionReceipt = await client.waitForUserIntentExecutionReceipt({
  uiHash: result1.uiHash, // or result2.uiHash
});

Features

  • Extends ZeroDev's KernelClient with chain abstraction capabilities
  • Cross-chain user intent preparation and execution
    • Direct send flow
    • Prepare-then-send flow
  • Intent status tracking
  • Type-safe API
  • Built with Bun and TypeScript

Development

# Install dependencies
bun install

# Build
bun run build

# Test
bun test

# Lint
bun run lint

# Format
bun run format

License

MIT

FAQs

Package last updated on 17 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.