Skip to content

Fees

Every transaction requires a fee. Fee instructions are separate from regular instructions — they run in a distinct execution context.

The most common approach: call pay_fee on a component (typically your account).

builder.feeTransactionPayFromComponent(accountAddress, 1000n);

Under the hood, this adds a fee instruction that calls the pay_fee method on the component:

// Equivalent to:
builder.addFeeInstruction({
CallMethod: {
call: { Address: accountAddress },
method: "pay_fee",
args: [{ Literal: "1000" }],
},
});

Use addFeeInstruction directly if the fee payment method has a different name.

For confidential transactions, use a withdraw proof instead of a plaintext amount:

builder.feeTransactionPayFromComponentConfidential(accountAddress, proof);

For complex fee instruction sequences, use withFeeInstructionsBuilder:

builder.withFeeInstructionsBuilder((feeBuilder) =>
feeBuilder
.callMethod(
{ componentAddress: accountA, methodName: "pay_fee" },
[{ Literal: "500" }],
)
.callMethod(
{ componentAddress: accountB, methodName: "pay_fee" },
[{ Literal: "500" }],
),
);