WEMIX3.0
WEMIX3.0 (ENG)
WEMIX3.0 (ENG)
  • Introduction
    • Blockchain Basics
      • What is Blockchain?
      • Consensus Algorithm
      • Transactions
      • Gas
      • Account
  • Design
    • Architecture
    • Consensus
    • Governance
    • Minting
    • EIP1559
    • Eco Fund
    • Fee Delegation
    • Roadmap
  • Quick Start
    • Start Node
      • Use Binary
        • Command-line Option
      • Use Public API Server(RPC)
    • Connect Node
    • Account
      • Use MetaMask
    • Testnet Faucet
  • Install & Operation
    • End Node
      • System Requirements
      • Firewall Setting
      • Install Guide
    • Block Producer Node
      • System Requirements
      • Firewall Setting
      • Install Guide
    • Download
    • Operation Guide
  • dApp Developer
    • Smart Contract
      • Solidity
      • Precompiled Contracts
      • Sample Contracts
    • JSON-RPC
    • API Reference
      • Account APIs
      • Block APIs
      • Contract APIs
      • Transaction APIs
      • Event logs APIs
      • Tokens APIs
  • Tutorial
    • Create a Wallet
    • Receive Test Coin
    • Create Smart Contract
      • Remix
      • Truffle
      • Hardhat
    • ERC-20 Token
      • Write ERC-20 Contract
      • Check ERC-20 Token
      • Send ERC-20 Token
      • Check ERC-20 Token API
      • Burn ERC-20 Token
    • ERC-721 Token
      • Write ERC-721 Contract
      • Minting ERC-721 Token
      • Check ERC-721 Token API
      • Burn ERC-721 Token
    • Use Fee Delegation
  • Manual
    • Explorer
    • Wallet
  • FAQ
Powered by GitBook
On this page
  1. Design

Fee Delegation

This chapter is about Fee Delegation applied to WEMIX3.0.

PreviousEco FundNextRoadmap

Last updated 10 months ago

Fee Delegation is a mechanism applied to Applepie HF in WEMIX3.0. This is a feature that FeePayer pays a fee for the transaction that Sender wants to execute instead of Sender.

Fee Delegation Transaction is accomplished by sending the existing Transaction signed by the Sender, including the FeePayer information, by adding the FeePayer signed signature information.

Fee Delegation Transaction

DynamicFeeTxType Transaction(with signature of Sender) + FeePayer address + signature of FeePayer

Fee Delegation Transaction only supports DynamicFeeTxType among existing Transaction and does not support LegacyTxType or AccessListTxType.

Important changes to implementation of Fee Delegation Transaction are as follows, and please refer to the open source for further information.

Fee Delegation Transaction Type (transaction.go)

const (
  LegacyTxType = iota
  AccessListTxType
  DynamicFeeTxType
  FeeDelegateDynamicFeeTxType = 22 //fee delegation
)

Fee Delegation Transaction Structure(transaction.go)

type FeeDelegateDynamicFeeTx struct {
  SenderTx DynamicFeeTx
  FeePayer *common.Address rlp:"nil"

  // Signature values
  FV *big.Int json:"fv" gencodec:"required" // feePayer V
  FR *big.Int json:"fr" gencodec:"required" // feePayer R
  FS *big.Int json:"fs" gencodec:"required" // feePayer S
}

Fee Delegation Transaction Hash Function for Signature(transaction_signing.go)

func (s feeDelegateSigner) Hash(tx *Transaction) common.Hash {
  senderV, senderR, senderS := tx.RawSignatureValues()
  return prefixedRlpHash(
    tx.Type(),
    []interface{}{
      []interface{}{
        s.chainId,
        tx.Nonce(),
        tx.GasTipCap(),
        tx.GasFeeCap(),
        tx.Gas(),
        tx.To(),
        tx.Value(),
        tx.Data(),
        tx.AccessList(),
        senderV,
        senderR,
        senderS,
      },
      tx.FeePayer(),
    })
}

Caution

Fee Delegation Transaction pays fees according to the fee settings (gas, maxFeePerGas, maxPriorityFeePerGas) of DynamicFeeTxType Transaction generated by the Sender. Therefore, FeePayer must have a procedure to verify that the transaction fee is appropriate.

Caution

It is important to note that the nonce of the transaction requested by the user is greater than the nonce of the transaction requested by the current sender, because Fee Delegation Transaction signed by FeePayer may not be used immediately, depending on the nonce of the sender.

Fee Delegation