Builders - IBX Token Billing Mechanism

This page explains how the IBX token billing system works for Builders who sponsor their users' onchain transactions.

Overview

Within a given Builder's rpId (dApp domain name - e.g. app.ibexwallet.org), end-user onchain transactions are sponsored by the Builder's wallet using IBX tokens. This sponsorship covers gas and execution fees for permitted operations, ensuring a smooth user experience without requiring users to hold native gas tokens.

The Builder funds and manages the IBX balance that backs these sponsored operations. Each operation type has a configurable price in EUR, which is automatically converted to IBX tokens and charged to the Builder's billing wallet.

Billing Flow

The billing process is triggered automatically after a Safe operation is successfully executed:

  1. Operation Execution : User's Safe operation is executed on-chain via the bundler
  2. Billing Trigger : After successful execution, the billing service is automatically triggered
  3. Price Lookup : System looks up the EUR price for the operation type
  4. IBX Conversion : EUR price is converted to IBX using the current IBX/EUR exchange rate
  5. Transaction Creation : A billing transaction is created with status PENDING
  6. Token Transfer : IBX tokens are transferred from Builder's billing wallet to the billing destination
  7. Status Updates : Transaction status is updated to SENT, then CONFIRMED after blockchain confirmation

Configuration Requirements

1. Billing Wallet

Each Builder must configure a billing wallet address. This wallet will be charged IBX tokens for sponsored operations.

⚠️ Note : If no billing wallet is configured, billing transactions will be created with status PENDING but no token transfer will occur. The operation will still succeed, but billing will be skipped.

2. IBX Price (EUR per IBX)

The IBX/EUR exchange rate is configured globally via the BILLING_IBX_PRICE environment variable. This rate is used to convert EUR prices to IBX amounts.

Formula: ibxAmount = priceEur / eurPerIbx

3. Operation Pricing

Each operation type can have a custom price in EUR, configured per Builder:

If no pricing is configured for an operation type, the billing amount defaults to 0 (free operation).

Billing Transaction Status

Each billing transaction progresses through the following statuses:

Status Description
PENDING Billing transaction created, awaiting token transfer. This occurs when:
  • No billing wallet is configured
  • Billing amount is 0 (free operation)
  • Before the token transfer is initiated
SENT Token transfer transaction has been submitted to the blockchain, awaiting confirmation
CONFIRMED Token transfer transaction has been confirmed on the blockchain. Billing is complete.
FAILED Billing transaction failed. Common reasons:
  • Insufficient IBX balance in billing wallet
  • Insufficient allowance (billing wallet must approve the billing executor to spend IBX tokens)
  • IBX price not configured
  • Transaction reverted on-chain

Token Transfer Mechanism

The billing system uses ERC20 transferFrom to move IBX tokens:

⚠️ Important : The Builder's billing wallet must approve the billing executor address to spend IBX tokens. The required allowance must be at least equal to the total amount of IBX to be charged for operations.

Operation Types and Pricing

Common operation types that can be billed include:

Each Builder can configure custom prices for each operation type, allowing for flexible pricing models.

Error Handling

If billing fails, the following diagnostics are performed:

Failed billing transactions do not prevent the user's operation from succeeding. The operation is executed on-chain, but billing is marked as FAILED for later resolution.

Best Practices

Technical Implementation

The billing mechanism is implemented in src/services/billingService.ts:

Billing is triggered automatically in src/routes/v1/safesOperations.ts after a Safe operation is successfully executed via the bundler.

← Back to API Documentation