Skip to main content
Actions SDK is still under construction and not ready for production use! This guide is meant for early testing purposes only.
The Actions SDK is an open source Typescript development toolkit that simplifies the act of integrating DeFi into your application.

How it works

Here’s a breakdown of what’s under the hood:
  • Modular Providers: Actions is built with a set of core adapters called “Providers”. Providers let you to pick an choose the right services and protocols for your use-case.
  • Embedded Wallets: Actions supports popular embedded wallet providers, allowing your users to access DeFi with email authentication flows alone.
  • Configure Actions: Extend your embedded wallet with DeFi actions like Lend, Borrow, Swap, and Pay. Set multiple providers for each Action to choose the best markets across DeFi.
  • Customize assets & chains: Allow and block assets, markets, chains, and protocols from your application from a single config.

Installation

Install the Actions SDK in your project:
npm install @eth-optimism/actions-sdk

Choose a Wallet Provider

Actions works with both frontend and backend wallets depending on your needs:
  • Frontend
  • Backend
Select a wallet provider:
  • Privy
  • Turnkey
  • Dynamic
Install and setup Privy.Configure Wallet ProviderGive your embedded wallets the ability to take Action:
import { actions } from './config'
import { useWallets } from '@privy-io/react-auth'

// PRIVY: Fetch wallet
const { wallets } = useWallets()
const embeddedWallet = wallets.find(
  (wallet) => wallet.walletClientType === 'privy',
)

// ACTIONS: Let wallet make onchain Actions
const wallet = await actions.wallet.toActionsWallet({
  connectedWallet: embeddedWallet,
})
Configure Smart WalletsOptionally, create signers for smart wallets you control:
import { actions } from './config'
import { useWallets } from '@privy-io/react-auth'

// PRIVY: Fetch wallet
const { wallets } = useWallets()
const embeddedWallet = wallets.find(
  (wallet) => wallet.walletClientType === 'privy',
)

// ACTIONS: Create signer from hosted wallet
const signer = await actions.wallet.createSigner({
  connectedWallet: embeddedWallet,
})

// ACTIONS: Create smart wallet
const { wallet } = await actions.wallet.createSmartWallet({
  signer: signer
})

Create your ActionsConfig

Follow the Configuring Actions guide to define which protocols, chains, and assets to support.

Take Action

Once configured, you can use Actions to perform DeFi operations:
import { USDC, ETH, USDT } from "@eth-optimism/actions-sdk/assets";
import { ExampleMarket } from "@/actions/markets";

// Enable asset lending in DeFi
const lendReceipt = await wallet.lend.openPosition({
  amount: 1,
  asset: USDC,
  ...ExampleMarket,
});

// Manage user market positions
const lendPosition = await wallet.lend.getPosition(market);

// Fetch wallet balance
const balance = await wallet.getBalance();

// ⚠️ COMING SOON
const borrowReceipt = await wallet.borrow.openPosition({
  amount: 1,
  asset: USDT,
  ...market,
});

// ⚠️ COMING SOON
const swapReceipt = await wallet.swap.execute({
  amountIn: 1,
  assetIn: USDC,
  assetOut: ETH,
});

// ⚠️ COMING SOON
const sendReceipt = await wallet.send({
  amount: 1,
  asset: USDC,
  to: "vitalik.eth",
});

Next Steps