Fee Delegation

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

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.

Last updated