Fee Bump

The @colibri/plugin-fee-bump package allows a separate account to cover network fees for Soroban transactions.

Installation

deno add jsr:@colibri/plugin-fee-bump

Overview

Fee bumping allows a different account (the fee bump source) to pay transaction fees on behalf of the user. This is useful for:

  • User Onboarding — New users can interact without holding XLM for fees

  • Covered Network Fees — dApps can subsidize user transactions

  • Enterprise Workflows — Centralized fee payment for organization transactions

Quick Start

import { PIPE_InvokeContract, LocalSigner, NetworkConfig } from "@colibri/core";
import { PLG_FeeBump } from "@colibri/plugin-fee-bump";
import { Operation } from "stellar-sdk";

// User's signer (the one making the contract call)
const userSigner = LocalSigner.fromSecret("USER_SECRET...");

// Fee bump source's signer (covers the fees)
const feeSourceSigner = LocalSigner.fromSecret("FEE_SOURCE_SECRET...");

const network = NetworkConfig.TestNet();

// Create the pipeline
const pipeline = PIPE_InvokeContract.create({ networkConfig: network });

// Create and add fee bump plugin
const feeBumpPlugin = PLG_FeeBump.create({
  networkConfig: network,
  feeBumpConfig: {
    source: feeSourceSigner.publicKey(),
    fee: "1000000", // 0.1 XLM in stroops
    signers: [feeSourceSigner],
  },
});
pipeline.addPlugin(feeBumpPlugin, PLG_FeeBump.target);

// Run the pipeline
const result = await pipeline.run({
  operations: [
    Operation.invokeContractFunction({
      contract: "CABC...",
      function: "transfer",
      args: [...],
    }),
  ],
  config: {
    source: userSigner.publicKey(),
    fee: "100000",
    signers: [userSigner],
  },
});

PLG_FeeBump

Factory object for creating fee bump plugin instances.

Creating a Plugin

Configuration

Property
Type
Description

networkConfig

NetworkConfig

Network configuration

feeBumpConfig.source

Ed25519PublicKey

Account covering the fee

feeBumpConfig.fee

string

Fee in stroops

feeBumpConfig.signers

Signer[]

Signers for the fee bump transaction

Fee Calculation

The fee bump fee must be greater than the inner transaction's fee:

How It Works

  1. User transaction is built and signed normally

  2. Plugin wraps the transaction in a fee bump envelope

  3. Fee bump source signs the fee bump transaction

  4. Combined transaction is submitted — fee bump source pays fees

Error Handling

Error Codes

Code
Class
Description

PLG_FBP_000

UNEXPECTED_ERROR

An unexpected error occurred

PLG_FBP_001

MISSING_ARG

Required argument not provided

PLG_FBP_002

NOT_A_TRANSACTION

Input is not a valid Transaction

Handling Errors

Usage Patterns

Covered Fees for User Onboarding

Enterprise Fee Management

Dynamic Fee Calculation

Security Considerations

1. Validate Transactions

Before covering fees, validate the transaction content:

2. Rate Limiting

Implement rate limiting for covered transactions:

3. Fee Limits

Set reasonable fee limits:

Next Steps

Last updated