# Fee Delegation

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.

<figure><img src="/files/ib0aOZJ1PBjC2oqNZUMl" alt=""><figcaption><p>Fee Delegation</p></figcaption></figure>

#### Fee Delegation Transaction

{% code overflow="wrap" %}

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

{% endcode %}

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

<figure><img src="/files/3vKdmhFiJRPaM5bu9XuU" alt=""><figcaption></figcaption></figure>

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)

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

#### Fee Delegation Transaction Structure(transaction.go)

```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)

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

{% hint style="danger" %}
**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.
{% endhint %}

{% hint style="danger" %}
**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.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wemix.com/en/design/fee-delegation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
