Skip to main content
Build a two-signature flow where a fee payer account covers gas costs on behalf of a transaction sender.

What you’ll learn

By the end of this tutorial, you’ll be able to:
  • Build and sign a fee-delegated transaction (type 0x16) with ethers.js
  • Add the fee payer’s signature to a partially signed transaction
  • Broadcast the completed transaction and verify gas was charged to the fee payer

How fee delegation works

StableNet’s fee delegation separates transaction signing from gas payment using transaction type 0x16. Both signatures are required. The node validates both before accepting the transaction into the mempool. After execution, unused gas is refunded to the fee payer — not the sender.
Fee delegation requires the Applepie fork to be active. Transactions of type 0x16 submitted before the fork activate are rejected immediately.

Prerequisites

  • Node.js ≥ 18 and npm install ethers (v6)
  • Two funded testnet accounts: one sender wallet, one fee payer wallet
  • Get testnet WKRC for both accounts at the Faucet

Build and sign the transaction

The sender builds the transaction, sets feePayer to the fee payer’s address, and signs it.

Add the fee payer’s signature

The fee payer receives the partially signed transaction, reviews the contents, and adds their signature.
The fee payer should verify to, value, data, and gas before signing to avoid paying for unintended operations.

Broadcast the completed transaction

Verify gas was charged to the fee payer

Check the fee payer’s balance before and after to confirm gas was deducted from their account, not the sender’s.
On the Explorer, search the transaction hash at explorer.stablenet.network. The feePayer field in the transaction details confirms which account paid gas.

Key invariants

  • tx.origin is always the sender. Existing contracts that check msg.sender or tx.origin work without modification.
  • The fee payer’s balance cannot be used for value transfer — only gas is at risk.
  • Unused gas is refunded to the fee payer automatically.
  • The fee payer’s address is not exposed inside EVM execution — smart contracts cannot detect that fee delegation was used.

Next steps

Fee Delegation Use Case

Build a gasless dApp flow with fee delegation.

RPC API Reference

personal_signRawFeeDelegateTransaction and related methods.

Deploy with Foundry

Deploy the contract your fee payer will interact with.

Listen to Events

Subscribe to events emitted by fee-delegated transactions.