---
# System prepended metadata

title: Fee-abstraction

---

## Ante Handler allow paying fee using SNIP-20 token

Fee abstraction modules enable users to pay fee use SNIP-20 token.

Whenever a user uses SNIP-20 to pay fees, Fee-abstracion(FA) module will collect all SNIP-20 from user by execute the contract that transfer the amount of SNIP-20 token from user to module account address. After that, FA will use the amount of native token that have same value with the amount of SNIP-20 collected from user for paying fee.


```
func CustomDeductFeeAnteHandler() {
    if feeIsNativeToken() {
        PayFee(fee, feePayer)
    } else {
        // Get contract address
        contractAddr := fee.Denom
        
        // Transfer SNIP20 token to module account address
        recipient := GetModuleAccountAddress()
        execMsg := SNIP20TokenTransferMsg(recipient, fee.Amount)
        err := ExecuteContract(contractAddr, feePayer, execMsg)
        if err != nil {
            return err
        }
        
        // Transfer success, FA module will use the amount of token that
        // have same value with the amount of SNIP-20 token collected from
        // user for paying fee
        exchangeRate := GetSNIP20TokenExchangeRate(fee.Denom)
        nativeTokenFeeAmount := exchangeRate * fee.Amount
        nativeTokenFee := Coins{Denom, nativeTokenFeeAmount}
        PayFee(nativeTokenFee, FeeAbsModuleAccount)
    }
}
```

User pays fee with SNIP20 token by declare the `-fees` flags while the `denom` field is the address of the specific contract of SNIP-20 token

`
secret tx bank send <sender> <receiver> <amount> --fees 1000secret1k0jntykt7e4g3y88ltc60czgjuqdy4c9e8fzek
`

