Fee Delegation

To make a transaction on the blockchain, you must pay a fee. However, users who use the service must have Meta to pay the fee, and there are cases where the platform that operates the service must pay the fee according to the service policy.

Fee delegation allows users to pay fees on their behalf even if they do not pay them directly. It makes it possible to pay fees by receiving a transaction signed by the user, adding FeePayer's signature, and sending it.

Because fee delegation is carried out based on the fees generated by the Sender, the FeePayer needs to undergo a verification process to ensure that the fees in the fee delegation transaction are appropriate. Conversely, if the FeePayer does not sign and transmit the fee delegation transaction generated by the Sender, only the Sender is liable to pay the fees. Therefore, caution is necessary in such cases.

Metadium supports only DynamicFeeTxType among Fee delegation Transactions.

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

Refer to Fee delegation Transaction implementation source

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(),
    })
}

Last updated