### Example: Initiate KYC Flow via useIbex Hook
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/kyc-service.md
Shows the integration of KYC initiation using the startKyc hook provided by useIbex. This is a convenient way to start the verification process when the user's KYC status is not 'verified'.
```typescript
const { startKyc, user } = useIbex();
if (user?.kyc.status !== 'verified') {
const url = await startKyc('en');
window.location.href = url;
}
```
--------------------------------
### Example: Initiate KYC Flow via SDK
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/kyc-service.md
Demonstrates how to use the KycService to start a KYC verification process for a user whose status is not yet 'verified'. It generates a KYC URL and redirects the user. Requires the useIbex hook to access the SDK and user data.
```typescript
const { sdk, user } = useIbex();
if (user && user.kyc.status !== 'verified') {
const kycUrl = await sdk.kyc.start('en', 'https://myapp.com/kyc-callback');
window.location.href = kycUrl;
}
```
--------------------------------
### Complete KYC Flow Example with UI Components
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/kyc-service.md
A comprehensive example demonstrating a full KYC flow within a React component. It includes UI elements to display KYC status, a button to start verification, and logic to handle redirection and status updates. It also includes a callback component to handle the post-verification redirect.
```typescript
import { useIbex } from '@absconse/ibex-sdk';
function KycFlow() {
const { user, sdk } = useIbex();
const [loading, setLoading] = React.useState(false);
if (!user) {
return
);
}
```
--------------------------------
### Complete Ibex SDK Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
A comprehensive example demonstrating the integration of IbexProvider, useIbexConfig, and useIbex.
```typescript
import React from 'react'
import { IbexProvider, useIbex, useIbexConfig } from '@absconse/ibex-sdk'
// Component that uses config
function AppStatus() {
const { config } = useIbexConfig()
const { isConnected } = useIbex()
return (
Connected to: {config.baseURL}
WebSocket: {isConnected ? '✓' : '✗'}
)
}
// Main app component
function App() {
return (
)
}
export default App
```
--------------------------------
### IbexProvider Usage Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Example of how to wrap your application with IbexProvider and provide the configuration.
```typescript
import { IbexProvider } from '@absconse/ibex-sdk'
function App() {
return (
)
}
```
--------------------------------
### Install IBEX SDK with npm, yarn, or pnpm
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/README.md
Use your preferred package manager to install the IBEX SDK.
```bash
npm install @absconse/ibex-sdk
```
```bash
yarn add @absconse/ibex-sdk
```
```bash
pnpm add @absconse/ibex-sdk
```
--------------------------------
### Complete Bitcoin Transaction Lifecycle Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/bitcoin-service.md
Demonstrates the full process of creating, signing, and broadcasting a Bitcoin transaction. This example covers fetching fee rates, network info, UTXOs, preparing the transaction, and outlines steps for PSBT building and signing.
```typescript
import { useIbex } from '@absconse/ibex-sdk';
async function BitcoinTransaction() {
const { sdk } = useIbex();
const senderAddress = 'bc1q...';
const recipientAddress = 'bc1q...';
const amountSat = 100000; // 0.001 BTC
try {
// Step 1: Get fee rates
const fees = await sdk.bitcoin.getFeeRates('mainnet');
console.log(`Current standard fee: ${fees.standard} sat/vB`);
// Step 2: Get network info
const info = await sdk.bitcoin.getNetworkInfo('mainnet');
console.log(`Block height: ${info.blocks}`);
// Step 3: Get sender's UTXOs
const utxos = await sdk.bitcoin.getUtxos(senderAddress, 'mainnet');
console.log(`Available UTXOs: ${utxos.unspents.length}`);
// Step 4: Prepare transaction
const prepared = await sdk.bitcoin.prepareSend({
from: senderAddress,
to: recipientAddress,
amountSat,
feeProfile: 'standard',
network: 'mainnet'
});
console.log(`Transaction fee: ${prepared.fee} sat`);
console.log(`Selected inputs: ${prepared.selectedUtxos.length}`);
console.log(`Outputs: ${prepared.outputs.length}`);
// Step 5: Build PSBT (using client-side library like bitcoinjs-lib)
// const psbt = buildPsbt(prepared.selectedUtxos, prepared.outputs);
// Step 6: Sign PSBT (client-side with wallet/key)
// const signedPsbt = signPsbt(psbt, privateKey);
// Step 7: Extract and broadcast
// const signedTx = psbt.extractTransaction().toHex();
// const result = await sdk.bitcoin.broadcast({
// rawtx: signedTx,
// network: 'mainnet'
// });
// console.log('Broadcasted:', result.txid);
} catch (error) {
console.error('Bitcoin transaction failed:', error);
}
}
```
--------------------------------
### IbexConfig baseURL Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Example of setting the baseURL in the IbexConfig.
```typescript
config={{
baseURL: 'https://api.ibex.com'
}}
```
--------------------------------
### Development Configuration Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/configuration.md
An example configuration object suitable for local development environments. It specifies a local baseURL, domain, and default chain ID.
```typescript
{
baseURL: 'http://localhost:8080',
domain: 'localhost',
defaultChainId: 100,
timeout: 30000,
retries: 3
}
```
--------------------------------
### IbexConfig timeout Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Example of setting the request timeout in milliseconds.
```typescript
config={{
timeout: 30000
}}
```
--------------------------------
### Staging Configuration Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/configuration.md
An example configuration object for a staging environment. It uses a staging API URL, a specific staging domain, and a testnet chain ID.
```typescript
{
baseURL: 'https://staging-api.ibex.com',
domain: 'staging.myapp.com',
defaultChainId: 421614,
timeout: 30000,
retries: 3
}
```
--------------------------------
### Production Configuration Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/configuration.md
An example configuration object for a production environment. It specifies the live API URL, the production domain, and the mainnet chain ID.
```typescript
{
baseURL: 'https://api.ibex.com',
domain: 'myapp.com',
defaultChainId: 100,
timeout: 30000,
retries: 3
}
```
--------------------------------
### IbexConfig domain Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Example of setting the domain in the IbexConfig, used for WebAuthn.
```typescript
config={{
domain: 'myapp.com'
}}
```
--------------------------------
### Environment Variables for Configuration
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Example of using environment variables to manage IBEX SDK configuration.
```env
```
--------------------------------
### Example Usage of createIframe
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/auth-service.md
Demonstrates how to call `createIframe` and use the returned URL to embed the KYC process in an iframe.
```typescript
const { sdk } = useIbex();
const iframe = await sdk.auth.createIframe('en');
// Use in iframe:
//
```
--------------------------------
### Complete Authentication Flow Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/auth-service.md
Demonstrates a full authentication flow within a React component, including sign-up, sign-in, and logout using the Ibex SDK.
```typescript
import { useIbex } from '@absconse/ibex-sdk';
function AuthComponent() {
const { sdk, user, isLoading, error } = useIbex();
const [showSignUp, setShowSignUp] = React.useState(false);
const handleSignUp = async () => {
try {
const auth = await sdk.auth.signUp({
keyName: 'My Device',
keyDisplayName: 'iPhone 15'
});
console.log('Sign up successful!');
setShowSignUp(false);
} catch (err) {
console.error('Sign up failed:', err.message);
}
};
const handleSignIn = async () => {
try {
const auth = await sdk.auth.signIn({
includeBalance: true,
includeTransactions: true
});
console.log('Sign in successful!');
console.log('Initial balance:', auth.balance);
} catch (err) {
console.error('Sign in failed:', err.message);
}
};
const handleLogout = async () => {
await sdk.auth.logout();
console.log('Logged out');
};
if (user) {
return (
Logged in as: {user.email || 'User'}
);
}
return (
{showSignUp ? (
) : (
)}
{error &&
{error}
}
);
}
```
--------------------------------
### IbexConfig defaultChainId Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Example of setting the defaultChainId for Safe operations.
```typescript
config={{
defaultChainId: 100 // Gnosis Chain
}}
```
--------------------------------
### useIbexConfig Usage Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Example of using the useIbexConfig hook to access the SDK configuration within a component.
```typescript
import { useIbexConfig } from '@absconse/ibex-sdk'
function MyComponent() {
const { config } = useIbexConfig()
return (
API: {config.baseURL}
Domain: {config.domain}
Chain: {config.defaultChainId}
)
}
```
--------------------------------
### Full Usage Example of useIbex Hook
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/use-ibex-hook.md
A comprehensive example demonstrating the integration of the useIbex hook in a React component. It covers user authentication, displaying balance and connection status, handling errors, initiating KYC, sending funds, and accessing advanced SDK features.
```typescript
import { useIbex } from '@absconse/ibex-sdk';
function Dashboard() {
const {
user,
wallet,
balance,
isLoading,
error,
isConnected,
signIn,
signUp,
send,
startKyc,
sdk,
} = useIbex();
if (isLoading) return
);
}
```
--------------------------------
### IbexConfig retries Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Example of setting the number of retry attempts for failed requests.
```typescript
config={{
retries: 3
}}
```
--------------------------------
### Example Usage of createKycRedirectUrl
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/auth-service.md
Shows how to generate a KYC redirect URL with a specified language and return URL.
```typescript
const { sdk } = useIbex();
const kycUrl = await sdk.auth.createKycRedirectUrl('en', 'https://myapp.com/kyc-callback');
// window.location.href = kycUrl;
```
--------------------------------
### IbexConfig rpId Example
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Example of explicitly setting the rpId in the IbexConfig to override the default domain.
```typescript
config={{
domain: 'myapp.com',
rpId: 'myapp.com' // Usually same as domain
}}
```
--------------------------------
### Basic IBEX SDK Setup with IbexProvider and useIbex Hook
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/README.md
Set up the IbexProvider with configuration and use the useIbex hook in your React components to access SDK functionalities like user authentication, balance display, and sending transactions.
```typescript
import { IbexProvider, useIbex } from '@absconse/ibex-sdk'
function App() {
return (
)
}
function Dashboard() {
const { user, wallet, balance, signIn, send, sdk } = useIbex()
if (!user) {
return
}
return (
Balance: {balance} EURe
)
}
```
--------------------------------
### Next.js Environment-Based Configuration
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/configuration.md
Configures the IBEX SDK using environment variables in a Next.js application. Includes a .env.local file example.
```typescript
// lib/ibexConfig.ts
import { IbexConfig } from '@absconse/ibex-sdk'
export const ibexConfig: IbexConfig = {
baseURL: process.env.NEXT_PUBLIC_IBEX_API || 'https://api.ibex.com',
domain: process.env.NEXT_PUBLIC_DOMAIN || 'localhost',
defaultChainId: parseInt(process.env.NEXT_PUBLIC_CHAIN_ID || '100'),
timeout: 30000,
retries: 3,
}
```
```env
NEXT_PUBLIC_IBEX_API=https://api.ibex.com
NEXT_PUBLIC_DOMAIN=myapp.com
NEXT_PUBLIC_CHAIN_ID=100
```
--------------------------------
### Fetch Portfolio Data
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/blockchain-service.md
This example demonstrates how to fetch a user's token balances, pool balances, and recent transactions using the Ibex SDK. It requires a connected wallet and utilizes Promise.all for efficient data fetching. Use this when building a dashboard to display a user's complete financial overview on the blockchain.
```typescript
import { useIbex } from '@absconse/ibex-sdk';
async function PortfolioDashboard() {
const { sdk, wallet } = useIbex();
if (!wallet) return
);
}
```
--------------------------------
### React Environment-Based Configuration
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/configuration.md
Configures the IBEX SDK using environment variables in a React application. Includes a .env file example.
```typescript
const config: IbexConfig = {
baseURL: process.env.REACT_APP_IBEX_API || 'https://api.ibex.com',
domain: process.env.REACT_APP_DOMAIN || 'localhost',
defaultChainId: parseInt(process.env.REACT_APP_CHAIN_ID || '100'),
timeout: parseInt(process.env.REACT_APP_TIMEOUT || '30000'),
retries: parseInt(process.env.REACT_APP_RETRIES || '3'),
}
function App() {
return (
{/* App content */}
)
}
```
```env
REACT_APP_IBEX_API=https://api.ibex.com
REACT_APP_DOMAIN=myapp.com
REACT_APP_CHAIN_ID=100
REACT_APP_TIMEOUT=30000
REACT_APP_RETRIES=3
```
--------------------------------
### Handle SDK Errors
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/README.md
Illustrates how to implement error handling for SDK methods using a try-catch block. This example shows how to differentiate between authentication failures, timeouts, and other general errors based on the error message.
```typescript
const { sdk } = useIbex()
try {
await sdk.safe.transferToken({
safeAddress: wallet.address,
tokenAddress: '0xEURe...',
to: '0x...',
amount: '100'
})
} catch (err) {
if (err.message.includes('401')) {
// Authentication failed
} else if (err.message.includes('timeout')) {
// Request timeout
} else {
// Other error
console.error(err.message)
}
}
```
--------------------------------
### Avoid Mixed Environment Configurations (Bad Practice)
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/docs/configuration.md
Illustrates an anti-pattern where production and development configurations are mixed, potentially leading to security vulnerabilities or incorrect behavior. This example shows a common mistake of using a development domain in a production-like configuration.
```typescript
const badConfig = {
baseURL: 'https://api.ibexwallet.org',
domain: 'localhost', // Mélange production/développement
debug: true,
}
```
--------------------------------
### Build PSBT Client-Side with bitcoinjs-lib
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/bitcoin-service.md
Use this function to construct a PSBT on the client-side. It requires transaction inputs and outputs as arguments. Ensure you have the bitcoinjs-lib installed.
```typescript
import * as bitcoin from 'bitcoinjs-lib';
function buildPsbt(inputs, outputs) {
const psbt = new bitcoin.Psbt({ network: bitcoin.networks.bitcoin });
inputs.forEach(input => {
psbt.addInput({
hash: input.txid,
index: input.vout,
nonWitnessUtxo: Buffer.from(/* transaction hex */, 'hex')
});
});
outputs.forEach(output => {
psbt.addOutput({
address: output.address,
value: output.value
});
});
return psbt;
}
```
--------------------------------
### Start KYC Verification with useIbex Hook
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/use-ibex-hook.md
Initiate the KYC verification process. You can specify the interface language. The function returns a redirect URL for the KYC flow. Check user's KYC status before initiating.
```javascript
const { startKyc, user } = useIbex();
if (user?.kyc.status !== 'verified') {
const kycUrl = await startKyc('en');
window.location.href = kycUrl;
}
```
--------------------------------
### Initiate KYC and Perform Safe Operations
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/kyc-service.md
Check if the user's KYC is verified before allowing them to perform Safe operations. If not verified, a button is provided to start the KYC process. Requires `useIbex` hook for user, sdk, and wallet access.
```typescript
const { user, sdk, wallet } = useIbex();
if (user?.kyc.status !== 'verified') {
return (
Complete KYC verification to perform transactions
);
}
// User can now perform Safe operations
await sdk.safe.transferToken({
safeAddress: wallet!.address,
tokenAddress: '0xEURe...',
to: '0x...',
amount: '100'
});
```
--------------------------------
### Environment Variables for Ibex SDK
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/README.md
Provides examples of environment variables required for configuring the Ibex SDK in different environments (Production, Staging, Development). These variables control API endpoints, domains, and chain IDs.
```env
# Production
REACT_APP_IBEX_API=https://api.ibex.com
REACT_APP_DOMAIN=myapp.com
REACT_APP_CHAIN_ID=100
# Staging
REACT_APP_IBEX_API=https://staging-api.ibex.com
REACT_APP_DOMAIN=staging.myapp.com
REACT_APP_CHAIN_ID=100
# Development
REACT_APP_IBEX_API=http://localhost:8080
REACT_APP_DOMAIN=localhost
REACT_APP_CHAIN_ID=100
```
--------------------------------
### Avoid Configuration Without Error Handling (Bad Practice)
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/docs/configuration.md
Shows a scenario where configuration is applied without any error handling. If the configuration is invalid, this can lead to application crashes or unexpected behavior, as the potential errors during provider setup are not caught.
```typescript
```
--------------------------------
### IbexProvider with Environment Variables
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Configure the IbexProvider by directly referencing environment variables for API base URL, domain, and chain ID. This is suitable for simple setups where environment variables are pre-defined.
```dotenv
REACT_APP_IBEX_API=https://api.ibex.com
REACT_APP_DOMAIN=myapp.com
REACT_APP_CHAIN_ID=100
```
```typescript
{/* ... */}
```
--------------------------------
### Query Blockchain Data
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/README.md
Examples for fetching user balances, transaction history, and swap quotes from the blockchain using the SDK's blockchain module. Specify the address and relevant parameters for each query.
```typescript
const { sdk } = useIbex()
// Get balances
const balances = await sdk.blockchain.getBalances({
address: '0x...',
blockchainId: 100
})
// Get transactions
const txs = await sdk.blockchain.getTransactions({
address: '0x...',
startDate: '2025-01-01',
limit: 50
})
// Get swap quote
const quote = await sdk.blockchain.getSwapQuote({
sellTokenAddress: '0xEURe...',
buyTokenAddress: '0xUSDC...',
amount: '100'
})
```
--------------------------------
### Start KYC Verification and Generate Redirect URL
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/kyc-service.md
Initiates the KYC verification flow and returns a redirect URL. Specify the interface language and an optional return URL for post-verification redirection. Defaults to 'fr' for language and the current origin for returnUrl.
```typescript
async start(language: string = 'fr', returnUrl?: string): Promise
```
--------------------------------
### Separate Environment Configurations (Good Practice)
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/docs/configuration.md
Demonstrates the recommended approach for managing configurations by separating development and production settings into distinct objects. This prevents accidental mixing of environment-specific parameters.
```typescript
const config = {
development: {
baseURL: 'https://api-testnet.ibexwallet.org',
domain: 'localhost',
debug: true,
},
production: {
baseURL: 'https://api.ibexwallet.org',
domain: 'votre-domaine.com',
debug: false,
},
}
```
--------------------------------
### Implement Proper Error Handling for Configuration (Good Practice)
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/docs/configuration.md
Demonstrates a robust way to handle configuration errors using a try-catch block. It attempts to create the configuration, and if an error occurs during creation, it renders a ConfigError component to inform the user.
```typescript
try {
const config = createConfig(process.env)
;
} catch (error) {
return
}
```
--------------------------------
### KycService.start
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/kyc-service.md
Initiates the KYC verification flow and generates a redirect URL for the user. This method allows specifying the interface language and a return URL after completion.
```APIDOC
## KycService.start
### Description
Starts the KYC verification flow and generates a redirect URL. You can specify the interface language and a URL to return to after the KYC process is completed.
### Method
`async start(language: string = 'fr', returnUrl?: string): Promise`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Parameters
- **language** (string) - Optional - The interface language for the KYC process (e.g., 'fr', 'en'). Defaults to 'fr'.
- **returnUrl** (string) - Optional - The URL to redirect the user to after the KYC process is completed. Defaults to `window.location.origin`.
### Returns
- **Promise** - A promise that resolves to the complete KYC redirect URL.
### Example
```typescript
const { sdk, user } = useIbex();
if (user && user.kyc.status !== 'verified') {
const kycUrl = await sdk.kyc.start('en', 'https://myapp.com/kyc-callback');
window.location.href = kycUrl;
}
```
```
--------------------------------
### Get Batch Operation Status
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/ARCHITECTURE.md
Retrieves the status of a previously submitted batch operation.
```APIDOC
## GET /v1/safes/operations/batch/{batchId}/status
### Description
Fetches the current status of a batch operation.
### Method
GET
### Endpoint
/v1/safes/operations/batch/{batchId}/status
### Parameters
#### Path Parameters
- **batchId** (string) - Required - The ID of the batch operation to query.
```
--------------------------------
### signUp
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/auth-service.md
Registers a new user using WebAuthn/Passkey. It can accept a passkey name string or a SignUpOptions object for more detailed configuration.
```APIDOC
## POST /auth/signup
### Description
Registers a new user with WebAuthn/Passkey.
### Method
POST
### Endpoint
/auth/signup
### Parameters
#### Request Body
- **options** (string | SignUpOptions) - Required - Either a string (passkey name, for backward compatibility) or `SignUpOptions` object.
- **keyName** (string) - Optional - Passkey display name (e.g., "My iPhone").
- **keyDisplayName** (string) - Optional - Decorative label for the passkey.
- **chainIds** (number[]) - Optional - List of chain IDs for multi-chain deployment.
### Response
#### Success Response (200)
- **access_token** (string) - The access token for the authenticated user.
- **refresh_token** (string) - The refresh token for obtaining new access tokens.
- **safeAddress** (object) - An object mapping chain IDs to Safe addresses.
### Request Example
```json
{
"keyName": "My iPhone",
"keyDisplayName": "iPhone 15 Pro",
"chainIds": [100, 421614, 11155111]
}
```
### Response Example
```json
{
"access_token": "eyJhbGci...",
"refresh_token": "def456...",
"safeAddress": {
"100": "0x...",
"421614": "0x..."
}
}
```
```
--------------------------------
### prepareSend
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/bitcoin-service.md
Prepare a simple send transaction by selecting UTXOs, calculating fees, and determining change. This is a preparatory step before building and signing a transaction.
```APIDOC
## prepareSend
### Description
Prepare a simple send transaction (select UTXOs, calculate fees, change).
### Method
`prepareSend(params: BitcoinSendPrepareParams): Promise`
### Parameters
#### Request Body
- **from** (string) - Required - Sender address
- **to** (string) - Required - Recipient address
- **amountSat** (number) - Required - Amount to send in satoshis
- **feeProfile** (BitcoinFeeProfile) - Required - 'slow' | 'standard' | 'fast'
- **network** (BitcoinNetwork) - Optional - The Bitcoin network ('mainnet' or 'testnet')
### Response
#### Success Response (200)
- **selectedUtxos** (Array) - List of UTXOs selected for the transaction.
- **outputs** (Array<{ address: string, value: number }>) - Transaction output details.
- **fee** (number) - Estimated total fee in satoshis.
- **change** (number) - Optional - Change amount in satoshis (if any).
- **changeOutput** ({ address: string, value: number }) - Optional - Details of the change output.
### Request Example
```typescript
const { sdk } = useIbex();
const prepared = await sdk.bitcoin.prepareSend({
from: 'bc1q...',
to: 'bc1q...',
amountSat: 100000,
feeProfile: 'standard',
network: 'mainnet'
});
console.log('Selected UTXOs:', prepared.selectedUtxos.length);
console.log('Total fee:', prepared.fee, 'sat');
if (prepared.changeOutput) {
console.log('Change:', prepared.changeOutput.value, 'sat');
}
```
```
--------------------------------
### Sign Up with IBEX SDK
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/docs/authentication.md
Handles the user sign-up process using a custom passkey name. Errors are automatically displayed by the SDK.
```typescript
const handleSignUp = async () => {
try {
await signUp('Mon Passkey IBEX') // Nom personnalisé
// ✅ Compte créé et utilisateur connecté
} catch (error) {
// ❌ Erreur affichée automatiquement
}
}
```
--------------------------------
### Get Wallet Addresses
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/users-service.md
Retrieves all wallet addresses associated with the user. This data is cached for 5 minutes.
```typescript
async getWalletAddresses(): Promise
```
```typescript
const { sdk } = useIbex();
const addresses = await sdk.users.getWalletAddresses();
console.log(`You have ${addresses.wallets.length} wallet(s)`);
addresses.wallets.forEach(wallet => {
console.log(`${wallet.address} on chain ${wallet.chainId}`);
});
```
--------------------------------
### IbexProvider with Multi-Environment Configuration Function
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Set up the IbexProvider using a configuration function that dynamically determines settings based on the NODE_ENV. This approach is useful for managing different configurations for production, staging, and development environments.
```typescript
const getConfig = (): IbexConfig => {
const env = process.env.NODE_ENV
if (env === 'production') {
return {
baseURL: 'https://api.ibex.com',
domain: 'ibex.com',
defaultChainId: 100,
}
}
if (env === 'staging') {
return {
baseURL: 'https://staging-api.ibex.com',
domain: 'staging.ibex.com',
defaultChainId: 100,
}
}
// development
return {
baseURL: 'http://localhost:8080',
domain: 'localhost',
defaultChainId: 100,
}
}
function App() {
return (
{/* ... */}
)
}
```
--------------------------------
### Get AAVE Pools
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/blockchain-service.md
Retrieves AAVE pools available on a specified blockchain. This method is cached for 5 minutes.
```typescript
async getPools(blockchainId: number): Promise
```
```typescript
interface PoolsResponse {
pools: WatchedPool[]
}
interface WatchedPool {
provider: string // e.g., "AAVE"
supplyToken: {
symbol: string
address: string
decimals: number
chainId: number
}
supplyApy: string
borrowApy: string
totalSupplied: string
totalBorrowed: string
utilizationRate: string
}
```
```typescript
const { sdk } = useIbex();
const pools = await sdk.blockchain.getPools(100); // Gnosis Chain
pools.pools.forEach(pool => {
console.log(`${pool.provider} - ${pool.supplyToken.symbol}`);
console.log(` Supply APY: ${pool.supplyApy}%`);
console.log(` Borrow APY: ${pool.borrowApy}%`);
});
```
--------------------------------
### Get User Data
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/privacy-service.md
Fetches private user data for a specified user. The data is cached for 5 minutes.
```typescript
async getUserData(externalUserId: string): Promise
```
```typescript
const { sdk } = useIbex();
const userData = await sdk.privacy.getUserData('user-123');
console.log('Saved data:', userData.data);
console.log('Last updated:', userData.updatedAt);
```
--------------------------------
### SignUpOptions Interface
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/types.md
Options for customizing the sign-up process, including key names and associated chain IDs. Use this to configure user registration.
```typescript
interface SignUpOptions {
keyName?: string
keyDisplayName?: string
chainIds?: number[]
}
```
--------------------------------
### Get Token Balances
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/blockchain-service.md
Fetches token balances for a given address on a specific blockchain. This method is cached for 10 seconds.
```typescript
async getBalances(params?: BalancesParams): Promise
```
```typescript
interface BalancesParams {
address?: string // Wallet address (defaults to current user)
blockchainId?: number // Blockchain ID (defaults to config.defaultChainId)
}
```
```typescript
interface BalancesResponse {
timestamp: string
balances: TokenBalance[]
}
interface TokenBalance {
address: string // Token contract address
balance: string // Token amount as string
symbol: string // Token symbol (e.g., "EURe")
name: string // Token name
decimals: number
usdValue?: string // USD equivalent value
chainId?: number
}
```
```typescript
const { sdk, wallet } = useIbex();
if (wallet) {
const balances = await sdk.blockchain.getBalances({
address: wallet.address,
blockchainId: wallet.chainId
});
balances.balances.forEach(token => {
console.log(`${token.symbol}: ${token.balance}`);
});
}
```
--------------------------------
### Sign In with IBEX SDK (Basic)
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/docs/authentication.md
Performs a simple user sign-in. Error handling is managed by the SDK.
```typescript
// Connexion simple
const handleSignIn = async () => {
try {
await signIn()
// ✅ Connexion réussie
} catch (error) {
// ❌ Gestion d'erreur
}
}
```
--------------------------------
### Get Batch Status
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/safe-service.md
Retrieves the current status of a batch operation, whether it is prepared or currently executing. Requires the batch ID.
```typescript
async getBatchStatus(batchId: string): Promise
```
```typescript
const { sdk } = useIbex();
const status = await sdk.safe.getBatchStatus('batch-123');
console.log('Status:', status);
}
```
--------------------------------
### Implement Strict Configuration Validation (Good Practice)
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/docs/configuration.md
Shows how to create a configuration function that enforces validation before returning a valid IbexConfig object. This ensures that essential parameters like baseURL and domain are present and sets default values for optional parameters.
```typescript
function createConfig(config: any): IbexConfig {
if (!config.baseURL || !config.domain) {
throw new Error('Configuration IBEX invalide')
}
return {
baseURL: config.baseURL,
domain: config.domain,
timeout: config.timeout || 30000,
retries: config.retries || 3,
debug: config.debug || false,
}
}
```
--------------------------------
### Get Supported Chain IDs
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/users-service.md
Retrieves the configured blockchain IDs for the user's wallets. This data is cached for 5 minutes.
```typescript
async getSupportedChainIds(): Promise
```
```typescript
const { sdk } = useIbex();
const chains = await sdk.users.getSupportedChainIds();
console.log('Default chain:', chains.defaultChainId);
console.log('Available chains:', chains.chainIds.join(', '));
```
--------------------------------
### Get Transaction History
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/blockchain-service.md
Retrieves transaction history with support for filtering by date, pagination, and limits. This method is cached for 30 seconds.
```typescript
async getTransactions(params?: TransactionsParams): Promise
```
```typescript
interface TransactionsParams {
address?: string // Wallet address
blockchainId?: number
startDate?: string // Format: YYYY-MM-DD or ISO 8601
endDate?: string
limit?: number // Max 100, default 50
page?: number // 1-indexed pagination
offset?: number // Alternative to page-based pagination
}
```
```typescript
interface TransactionsResponse {
total: number
page: number
limit: number
totalPages: number
data: BCReaderTransaction[]
}
interface BCReaderTransaction {
transactionHash: string
from: string
to: string
watchedAddress: string
direction: 'IN' | 'OUT'
tokenAddress: string
tokenType: string // e.g., "ERC20"
tokenSymbol: string
tokenName: string
tokenDecimals: number
valueFormatted: string // Human-readable amount
value?: string // Raw amount
timestamp: string
}
```
```typescript
const { sdk, wallet } = useIbex();
if (wallet) {
const txs = await sdk.blockchain.getTransactions({
address: wallet.address,
blockchainId: wallet.chainId,
startDate: '2025-01-01',
endDate: '2025-05-29',
limit: 50,
page: 1
});
console.log(`Total: ${txs.total}, Pages: ${txs.totalPages}`);
txs.data.forEach(tx => {
console.log(
`${tx.direction} ${tx.valueFormatted} ${tx.tokenSymbol} on ${tx.timestamp}`
);
});
}
```
--------------------------------
### Save User Data
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/privacy-service.md
Saves private data for a user. Keys prefixed with 'private.' are not returned in GET requests. The cache is invalidated after saving.
```typescript
async saveUserData(
externalUserId: string,
data: Record
): Promise
```
```typescript
const { sdk } = useIbex();
const result = await sdk.privacy.saveUserData('user-123', {
firstName: 'John',
lastName: 'Doe',
'private.ssn': '123-45-6789', // Won't be returned in GET
preferences: {
newsletter: true,
notifications: false
}
});
console.log('Data saved:', result.success);
```
--------------------------------
### Sign In with IBEX SDK (with Options)
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/docs/authentication.md
Enables sign-in with additional data options, such as including balance, transactions, and user data in the response.
```typescript
// Connexion avec options v1.1
const handleSignInWithData = async () => {
try {
await signIn({
includeBalance: true, // Inclure les balances dans la réponse
includeTransactions: true, // Inclure les transactions dans la réponse
includeUserdata: true, // Inclure les données utilisateur
})
// ✅ Connexion réussie avec données supplémentaires
} catch (error) {
// ❌ Gestion d'erreur
}
}
```
--------------------------------
### IbexProvider Imports
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/ibex-provider.md
Import IbexProvider and useIbexConfig from the IBEX SDK.
```typescript
import { IbexProvider, useIbexConfig } from '@absconse/ibex-sdk'
```
--------------------------------
### Get Operation Status
Source: https://github.com/absconseofficiel/ibex-sdk/blob/main/_autodocs/api-reference/safe-service.md
Retrieve the current status of a safe operation using its user operation hash. This is useful for monitoring the progress of asynchronous operations.
```typescript
async getOperationStatus(userOpHash: string): Promise
```
```typescript
interface OperationStatusResponse {
status: 'PENDING' | 'CONFIRMED' | 'FAILED'
userOpHash: string
transactionHash?: string
blockNumber?: number
gasUsed?: string
failure?: string // Error message if FAILED
}
```
```typescript
const { sdk } = useIbex();
const status = await sdk.safe.getOperationStatus('0xabc123...');
if (status.status === 'CONFIRMED') {
console.log('Transaction hash:', status.transactionHash);
} else if (status.status === 'FAILED') {
console.log('Operation failed:', status.failure);
}
```