Skip to main content

Overview

Dynamic provides multi-chain wallet authentication and embedded wallets. This guide explains how to use Dynamic for user authentication and then interact with the Deframe API on behalf of authenticated users.

Official Dynamic + Deframe Guide

Complete setup instructions on Dynamic’s documentation

Integration Pattern

1. Authenticate the User with Dynamic

Use Dynamic’s SDK to authenticate the user and obtain their wallet address:
import { useDynamicContext } from '@dynamic-labs/sdk-react-core'

const { primaryWallet, user } = useDynamicContext()
const walletAddress = primaryWallet?.address

2. Query Yield Strategies

With the wallet address, query the Deframe API for available strategies and the user’s current positions:
// List available strategies
const { data: strategies } = await axios.get('https://api.deframe.io/strategies', {
  headers: { 'x-api-key': process.env.DEFRAME_API_KEY }
})

// Check user positions
const { data: positions } = await axios.get(`https://api.deframe.io/wallets/${walletAddress}`, {
  headers: { 'x-api-key': process.env.DEFRAME_API_KEY }
})

3. Execute Strategy Transactions

Fetch the bytecode and sign it using the Dynamic wallet signer:
// Get deposit bytecode
const { data } = await axios.get(`https://api.deframe.io/strategies/${strategyId}/bytecode`, {
  params: { action: 'lend', amount: '10000000', wallet: walletAddress },
  headers: { 'x-api-key': process.env.DEFRAME_API_KEY }
})

// Sign and send each transaction using Dynamic's wallet connector
const signer = await primaryWallet.connector.getSigner()

for (const tx of data.bytecode) {
  const txResponse = await signer.sendTransaction({
    to: tx.to,
    data: tx.data,
    value: tx.value ?? '0'
  })
  await txResponse.wait()
}
The Deframe API never takes custody of funds. All transactions are signed and submitted by the user’s wallet through Dynamic.

Next Steps

Privy Integration

Embedded wallet solution with social login

Fireblocks Integration

Enterprise-grade custody integration