Developer Fundamentals
-- Fee Delegation
Learn how to offload gas fees using VeChain’s fee delegation system. This lesson covers delegated transaction setup, sponsor wallets, and backend service integration using VIP-201.
What is Fee Delegation?
Gas fees are usually paid by the address that signs the transaction. VeChain's fee delegation allows you to pass on this payment to another wallet, which can either reside as a private key in your realm or be shielded by a web service.
Fee delegation is particularly interesting for developers who want to make their apps more user-friendly, as it eliminates the friction of transaction fees for end-users.
This functionality is part of VeChain's broader strategy to make blockchain adoption easier, particularly for businesses and users unfamiliar with cryptocurrency.
How to use Fee Delegation
To use fee delegation, you need to:
Enable it while building the transaction object
Provide information about the Gas-Payer during transaction signing
To enable fee delegation as a feature, you need to set isDelegated to true while building the transaction body:
To get the gas-payer involved, you'll pass either gasPayerPrivateKey or gasPayerServiceUrl to the signing wallet:
To shield your private key for paying gas fees into a backend service, you can set up a web service that receives a raw transaction and co-signs it to confirm gas payment (based on VIP-201).
The process requires you to rebuild a transaction object from a hex-encoded version:
Try It Yourself
The snippet below brings it all together, illustrating how you can build a transaction, estimate the cost, sign it to execute the transaction onchain, and delegate the required gas fees to a sponsor.
Join our Telegram