A Colibri plugin that wraps a Stellar Transaction in a Fee Bump Transaction so a designated account pays the fees.
It targets the SendTransaction step from @colibri/core. You can attach it to
any convee pipe that includes steps.SEND_TRANSACTION_STEP_ID (for example,
one created by createInvokeContractPipeline).
Choose the integration style you need.
Minimal usage — create the plugin with its configuration and add it to a
pipeline that targets the SendTransaction step:
import { createFeeBumpPlugin } from "@colibri/plugin-fee-bump";
import { createInvokeContractPipeline, NetworkConfig } from "@colibri/core";
const networkConfig = NetworkConfig.TestNet();
const plugin = createFeeBumpPlugin({
networkConfig,
feeBumpConfig: {
source: "G...FEEPAYER", // fee payer address
fee: "10000000", // fee in stroops (1 XLM)
signers: [
/* signer objects */
],
},
});
const pipeline = createInvokeContractPipeline({ networkConfig });
pipeline.use(plugin);See the tests for full examples.
The plugin runs on the input of the SendTransaction step. It inspects the
incoming payload, wraps and authorizes the transaction with a
FeeBumpTransaction signed by the configured signers, and returns the modified
input for the rest of the pipeline.
createFeeBumpPlugin(options)— create plugin instanceFEE_BUMP_PLUGIN_ID— plugin idFEE_BUMP_PLUGIN_TARGET— pipeline step where it should be added (SendTransaction)CodeandERROR_PLG_FBP— stable error codes and constructorsFeeBumpPluginConfig,FeeBumpPluginNetworkConfig, andFeeBumpPluginArgs— plugin configuration typesFeeBumpPluginSigner— union of the supported outer-envelope signer capabilitiesFeeBumpEnvelopeSigner— signer that adds a decorated envelope signatureFeeBumpPreAuthorizedTransactionSigner— signer that validates an exact pre-authorized outer transaction hashFeeBumpPluginSignerIdentityandFeeBumpSignableTransaction— interfaces for custom fee-bump signer implementations
The package also re-exports Core's branded SignerKey, Ed25519PublicKey,
ContractId, PreAuthTx, Sha256Hash, and SignedPayload types for custom
signer implementations.
For concrete examples, refer to the unit and integration tests in src/.
createFeeBumpPlugin accepts an options object with the following fields:
-
networkConfig(required) — Colibri network configuration (for example,NetworkConfig.TestNet()). The plugin uses this configuration when building transactions. -
feeBumpConfig(required) — Configuration for the fee bump behavior:source(string, required) — The Stellar account address that will pay the fee (fee source).fee(string, required) — Fee amount in stroops to set on the FeeBumpTransaction as base fee* (e.g."10000000"equals 1 XLM).signers(array, required) — Envelope or pre-authorized transaction signer objects used to authorize the fee-bump source. This includesLocalSigner,HashXSigner,Ed25519SignedPayloadSigner, andPreAuthorizedTransactionSigner.
*Since this value defines a base fee, the total amount set as max network fee will be this value multiplied by the number of operations in the inner envelope plus one(the fee bump wrap). So, for contract invocations for example this will be 2 times the value set as it only contains one operation plus the wrapper.
Example:
createFeeBumpPlugin({
networkConfig: NetworkConfig.TestNet(),
feeBumpConfig: {
source: feePayer.address(),
fee: "10000000",
signers: [feePayer.signer()],
},
});