-
Notifications
You must be signed in to change notification settings - Fork 36
Add VIP: Generic Delegator standard #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
victhorbi
wants to merge
3
commits into
vechain:master
Choose a base branch
from
victhorbi:vip-194-generic-delegator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| --- | ||
| VIP: 194 | ||
| Title: Generic Delegator Standard | ||
| Description: Standard API and mechanism to allow users to pay transaction fees in supported tokens while the service pays VTHO to the network. | ||
| Author: Victor Bibiano (@victhorbi), Vanja Tomic (@vanja-vechain), Giulia Argiolas (@giuliamorg92), Luca Bandini (@vombato) | ||
| Discussions: Concept introduced with VIP-191 | ||
|
victhorbi marked this conversation as resolved.
Outdated
victhorbi marked this conversation as resolved.
Outdated
|
||
| Category: Application | ||
| Status: Draft | ||
| CreatedAt: 2026-01-23 | ||
| --- | ||
|
|
||
| ## Overview | ||
|
|
||
| This VIP defines a standard for a generic delegator service on VeChainThor, enabling users to pay transaction fees in alternative tokens (e.g., VET, B3TR) while the service itself pays VTHO to the network. The standard specifies APIs and validation rules to ensure the user pays at least the VTHO-equivalent (plus service fee) in their chosen token, with the service enforcing correct transfer clauses and amounts. | ||
|
|
||
| ## Motivation | ||
|
|
||
| The current user experience for fee payment can be a barrier to onboarding and adoption. By allowing users to pay fees in tokens they already hold, this standard: | ||
| - Improves onboarding and UX. | ||
| - Enables dApps and wallets to offer seamless fee sponsorship and multi-token support. | ||
| - Fosters interoperability and composability in the VeChain ecosystem. | ||
|
|
||
| ## Rationale | ||
|
|
||
| The generic delegator pattern abstracts fee payment, allowing service providers to sponsor transactions in VTHO while receiving other tokens from users. This approach leverages real-time exchange rates and enforces minimum payment requirements, ensuring economic fairness and service sustainability. The design supports extensibility for future tokens and transaction models. | ||
|
|
||
| ## Specification | ||
|
|
||
| The following specification follows a reference implementation, which is already integrated in the 2 main wallets available for VeChainThor (VeWorld and VeChain Kit). | ||
|
|
||
| [A swagger is available here](https://mainnet.delegator.vechain.org/api). | ||
|
|
||
| ### API Endpoints | ||
|
|
||
| All endpoints support filtering by type, speed (as query parameters), and token (as path parameter). | ||
|
|
||
| #### 1. Fee Estimation | ||
|
|
||
| Estimation can be obtained either by using clauses or the raw transaction. | ||
|
|
||
| ##### 1.1 Estimate Clauses | ||
|
|
||
| **Endpoint:** | ||
| `POST /estimate/clauses/:token` | ||
|
|
||
| **Request:** | ||
| ```json | ||
| { | ||
| "signer": "0xOriginatorAddress", | ||
| "clauses": [ | ||
| { "to": "0xAddress", "value": "0x...", "data": "0x..." } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ##### 1.2 Estimate Transaction | ||
|
|
||
| **Endpoint:** | ||
| `POST /estimate/transaction/:token` | ||
|
|
||
| **Request:** | ||
| ```json | ||
| { | ||
| "origin": "0xOriginatorAddress", | ||
| "raw": "0xRawTransactionData" | ||
| } | ||
| ``` | ||
|
|
||
| **Response (for both):** | ||
| ```json | ||
| { | ||
| "vthoPerGasAtSpeed": { "regular": 0.00001046, "medium": 0.000012, "high": 0.000014, "legacy": 0.00001 }, | ||
| "estimatedGas": { "usingVtho": 56507, "usingVet": 76507, "usingB3tr": 78000, "usingSmartAccount": 57507 }, | ||
| "rate": { "usingVtho": 1, "usingVet": 0.1, "usingB3tr": 0.0346 }, | ||
| "transactionCost": { | ||
| "regular": { "usingVtho": 0.59, "usingVet": 0.07, "usingB3tr": 0.025, "usingSmartAccount": 0.028 }, | ||
| "medium": { /* ... */ }, | ||
| "high": { /* ... */ } | ||
| }, | ||
| "serviceFee": 0.1 | ||
| } | ||
| ``` | ||
|
|
||
| #### 2. Supported Coins | ||
|
|
||
| **Endpoint:** | ||
| `GET /deposit/tokens` | ||
|
|
||
| **Response:** | ||
| ```json | ||
| ["vet", "b3tr", "vtho"] | ||
| ``` | ||
|
|
||
| #### 3. Get Deposit Account | ||
|
|
||
| **Endpoint:** | ||
| `GET /deposit/account/:token` | ||
|
|
||
| **Response:** | ||
| ```json | ||
| { | ||
| "depositAccount": "0xDepositAccountAddress" | ||
| } | ||
| ``` | ||
|
|
||
| #### 4. Request Signature | ||
|
|
||
| ##### 4.1 Request a Gas Payer signature for normal transactions | ||
| The service will add a transfer clause sending the VTHO-equivalent (plus service fee) in the selected token to the deposit account. | ||
|
|
||
| **Endpoint:** | ||
| `POST /sign/transaction/:token` | ||
|
|
||
| **Request:** | ||
| ```json | ||
| { | ||
| "raw": "0xRawTransactionData", | ||
| "origin": "0xOriginatorAddress" | ||
| } | ||
| ``` | ||
|
|
||
| **Response:** | ||
| ```json | ||
| { | ||
| "signature": "0xSignature", | ||
| "address": "0xGasPayerAddress", | ||
| "raw": "0xSignedTransactionData", | ||
| "origin": "0xOriginatorAddress" | ||
| } | ||
| ``` | ||
|
|
||
| ##### 4.1 Request a Gas Payer signature for Smart Accounts | ||
|
|
||
| For smart account wallets, the transaction must already include the extra transfer clause and the service will sign it. | ||
| Everything else is the same as above. | ||
|
|
||
| **Endpoint:** | ||
| `POST /sign/transaction/authorized/:token` | ||
|
|
||
| ### Requirements | ||
|
|
||
| - The transaction must include a transfer clause sending at least the VTHO-equivalent (plus service fee) in the selected token to the delegator's deposit account. | ||
| - The service validates the clause and amount before sponsoring the transaction. | ||
| - If requirements are not met (missing clause or insufficient amount), the service rejects the delegation. | ||
|
|
||
| ## Standard Error Codes and Messages | ||
|
|
||
| To ensure interoperability and predictable client behavior, the following standard HTTP error codes and messages MUST be used in API responses: | ||
|
|
||
| | HTTP Status | Message | Description | | ||
| |-------------|--------------------------------|------------------------------------------------------------------| | ||
| | 400 | Invalid request | The request is malformed or missing required fields. | | ||
| | 400 | Unsupported token | The specified token is not supported for fee delegation. | | ||
| | 422 | Insufficient balance | The user does not have enough balance to cover the required fee. | | ||
| | 422 | Insufficient transfer amount | The transfer clause does not cover the VTHO-equivalent + fee. | | ||
| | 400 | Missing transfer clause | The transaction is missing the required transfer clause. | | ||
| | 403 | Unauthorized | The request is not authorized or signature is invalid. | | ||
| | 409 | Replay attack detected | The transaction or signature has already been used. | | ||
| | 500 | Internal server error | An unexpected error occurred on the server. | | ||
|
|
||
|
|
||
| ## Security Considerations | ||
|
|
||
| - It is strongly recommended for service operators to keep their signers' keys in secure enclaves. | ||
| - Validate all requests and transfer clauses for correctness and authorization. | ||
| - Prevent replay attacks and ensure unique signatures. | ||
| - Limit sponsorship to supported tokens and transaction types. | ||
| - Monitor and rate-limit API usage. | ||
| - Ensure correct fee transfer to deposit accounts. | ||
| - Validate ERC20 transfer amounts for fee payment clauses. | ||
|
|
||
| ## Copyright | ||
|
|
||
| Copyright and related rights waived via CC0. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.