For Dfns setup, service accounts, and wallet configuration, see the Dfns Developer Docs.
How It Works
to, data, value) as a JSON object. For Solana, you pass the serialized unsigned transaction as a hex-encoded string.
Prerequisites
- A Dfns account with a service account configured
- An Ed25519 key pair for the service account (generated during setup)
- A Dfns wallet on the target network (e.g.,
Ethereum,Solana,Polygon) - The wallet address registered with RebelFi
@dfns/sdkand@dfns/sdk-keysignerinstalled:npm install @dfns/sdk @dfns/sdk-keysigner
Setting Up the Dfns Client
Create a Dfns API client using your service account credentials:Registering a Wallet
Fetch your Dfns wallet address and register it with RebelFi:The Dfns Signer
The core of the integration is a function that takes a RebelFi unsigned transaction and broadcasts it through Dfns. It handles both EVM and Solana transactions:Dfns handles gas estimation and broadcasting automatically. For EVM transactions, you only need to provide
to, data, and value. For Solana, you pass the complete serialized transaction and Dfns adds the signature.Supply Example
Supply operations may produce multiple transactions (e.g., EVM token approval + deposit, or a single Solana transaction). Sign and submit them sequentially through Dfns:What Happens Step by Step
Plan the supply
Call
operations.supply() with your wallet, strategy, amount, and token address. RebelFi returns an operation with status AWAITING_SIGNATURE.Fetch unsigned transactions
Call
operations.getUnsignedTransactions() to get the transactions to sign. For EVM, you’ll typically get two (approval + deposit). For Solana, you’ll get one.Broadcast via Dfns
For each unsigned transaction, call
broadcastTransaction on the Dfns wallet. For EVM, pass the to, data, and value fields. For Solana, pass the hex-encoded serialized transaction. Dfns signs with MPC and broadcasts on-chain.Submit hash to RebelFi
Once Dfns confirms the transaction, take the
txHash and submit it to RebelFi via transactions.submitHash(). Include the transactionId to identify which transaction in the operation you’re submitting.Unwind Example
Unwinding (withdrawing from a yield strategy) follows the same pattern:EVM vs Solana
ThesignAndBroadcast function handles both chains transparently. The key difference is how the transaction is passed to Dfns:
| EVM | Solana | |
|---|---|---|
| Transaction format | JSON object (to, data, value) | Hex-encoded serialized transaction |
| Source field | tx.evmTransaction | tx.unsignedTransaction.serialized |
| Typical tx count | 2 (approve + deposit) | 1 |
| Gas handling | Dfns estimates automatically | Included in serialized tx |
The
tx.blockchain field on each unsigned transaction tells you which chain it targets. Use this to route to the correct broadcast format.Troubleshooting
Transaction is not hex encoded
Transaction is not hex encoded
Cause: A Solana transaction was sent as a JSON object (EVM format) instead of a hex string, or the hex encoding is missing the
0x prefix.Solution: Ensure Solana transactions are converted from base64 to hex with a 0x prefix: '0x' + Buffer.from(serialized, 'base64').toString('hex').Transaction Failed or Rejected
Transaction Failed or Rejected
Cause: Dfns policy engine rejected the transaction, or the transaction failed on-chain.Solution: Check the
reason field on the Dfns transaction response. Common causes: insufficient gas funds in the wallet, policy rules blocking the transaction, or a smart contract revert.Transaction timed out
Transaction timed out
Cause: Dfns transaction took too long to reach a terminal status.Solution: Check the transaction status in the Dfns dashboard. It may be pending policy approval. Increase
MAX_POLL_ATTEMPTS if your approval flow takes longer.Wrong blockchain detected
Wrong blockchain detected
Cause: The Dfns wallet network doesn’t match the RebelFi strategy’s blockchain.Solution: Ensure your
WALLET_ID and STRATEGY_ID in RebelFi correspond to the same blockchain as your Dfns wallet. A Solana Dfns wallet needs a Solana-registered RebelFi wallet and a Solana strategy.