How to Setup Fee Delegation for Vechain

favo
vechain.energy
Published in
4 min readJul 10, 2023

--

Fee Delegation is a simple process that creates a magical user experience using blockchains without losing decentralized benefits.

What is Fee Delegation?

The user submitting a transaction sends requests with the second signature from a gas payer.

When the transaction is processed, the gas costs are taken from the gas payers balance instead of the user submitting the transaction.

It creates a feeless and trustless solution for instant blockchain access.

You can read more about it here:
https://app.vechain.energy/docs/fee-delegation

What are the use-cases?

Fee Delegation is improves mainly end-user-experience, removing the need to purchase/collect gas tokens and remove the need to pay for the applications activities.

Other use-cases are instant interactions with blockchains from different backends or processes without introducing account management for gas tokens.

How does it work?

Setup Fee Delegation Service

Create a project on https://app.vechain.energy:

The creation might take a few seconds, due a NFT been minted on the chain. The NFT is an on-chain-representation of the project and managed in the background.

This process is a good example for Fee Delegation, it does handle the configuration on the blockchain but as user the interaction is hidden to make it feel like a regular web application.

Deposit Gas Token: VTHO

On the TestNet claim VTHO for free on https://faucet.vecha.in

In Fee Delegation / Deposits send VTHO to your Delegation Services wallet:

It is possible to:

  • Auto Deposit when the balance is below a configured threshold. A suggested configuration to ensure the service will always have enough VTHO in production.
  • Configuration Notifications to receive an email if the balance is below a configured threshold, to get reminders to deposit more VTHO.

Configuration of Payment-Rules

To pay for specific transactions the Delegation-Service requires a configuration.

  • Whitelist provides lists of wallets or contracts whose interaction is paid for.
  • Smart Contract is a blockchain integrated solution where contract information can be used on every decision.

Example

Allowing all users to interact with the Vechain generic “VTHO Contract” requires to add a Whitelist-Entry with its address as recipient:

  1. Add Address
  2. 0x0000000000000000000000000000456e65726779 as address
  3. recipient as type

The statistics in the table are based on the network wide usage of that address.

To better identify addresses, a human readable name can be entered by clicking on the address. Adding a name creates an Address Book Entry which can be configured with tags.

Tags are shown the configuration and can be clicked to filter connected addresses.

Configure Fee Delegation

The Delegation-URL can be found in the Fee Delegation Overview:

To test the delegation a sample project is available on CodeSandbox.io:

https://f57jz7.csb.app/

Example Snippets for Fee Delegation are available at “Code Snippets”. They are fully working transaction examples that can be copied into different frameworks.

Configure Transaction-Decoding

All delegation requests are logged by default. The setting can be changed in Project /Settings.

The transaction data contains all details of the interaction, ready for decoding into a human readable format.

An ABI containing the decoding information is required. It can either be uploaded at Generic ABI or in the Address Book. Both ABI will be used to decode transactions details and display a human friendly version of the transactions.

Get more Insight

Analytics provide a Spreadsheet-Experience for transaction analytics. Details about the involved addresses, transaction costs and what functions are called can be valuable insights.

Logs are a filterable debugging instrument that provide an insight into all kinds of transactions. For example rejected Delegation-Requests can point to bad configurations or penetration tests.

Leveraging ABI information and insights into failed transactions can also support detecting potential application issues.

--

--