# How to calculate fee for XCM transfer?

I know there is a plenty of XCM transfer cases:

• RelayChain to ParaChain
• ParaChain to RelayChain
• ParaChain to ParaChain (Non-native token) with xTokens pallet
• ParaChain to ParaChain (Non-native token) without xTokens pallet
• ParaChain to ParaChain (Native token) with xTokens pallet
• ParaChain to ParaChain (Native token) without xTokens pallet

I have searched for this information in Polkadot Docs, Substrate Docs, Kusama Docs and other Parachain Docs but I found nothing about calculating XCM fees.

I only found documentation about calculating XCM fees for Moonbeam chain, but it is actual only for Moonbeam chain, unfortunately.

How can I calculate XCM transfer fee for all cases and actual for all chains? Where can I read about it more?

In fact, it is almost impossible to have an algorithm to calculate the XCM fees for all chains. This is because the calculation of XCM fees is related to the following points, and each chain may have different configurations.

1. Weigher: Means of measuring the weight consumed by an XCM message locally.

It seems that most chains currently use `FixedWeightBounds`, but the `UnitWeightCost` used by each chain may be different.

Even on the same chain, different tokens may have different `Trader` because their values are different, they need different `WeightToFee`. For example, Acala does it this way.

However, I would like to write down the XCM fee calculation process at an abstract level here, so that we can do the calculation for different chains.

The calculation of XCM fees can be divided into two steps. The first step is to calculate the weight, and the second step is to calculate the fee with the weight.

1. For the weight, most chains that use `FixedWeightBounds`

(Note that instructions used in `SetErrorHandler` and `SetAppendix` also count towards the instruction count)

2. Use `WeightToFee`to calculate fee. There are two commonly used methods.

For @VitalyPeryatin's comment:

Where can I found what chains use FixedWeightBounds for the weight?

You could check the `impl xcm_executor::Config` code in the repo of the chain. For example, Darwinia config `type Weigher = FixedWeightBounds`.

What other types exists except FixedWeightBounds?

`WeightInfoBounds`, and Westend used it here. Note any struct which impl trait WeightBounds could be used here.

Where can I found Transact weight?

`Transact` is an instruction in XCM, if not used, the weight is 0, if used, it can be obtained from its parameters `require_weight_at_most`. (Just a reminder: This weight is not the actual weight required to execute the `call`, but an upper limit weight specified for `call` execution when sending XCM.)

• Where can I found what chains use `FixedWeightBounds` for the weight? What other types exists except `FixedWeightBounds`? Where can I found `Transact weight`? Feb 20, 2023 at 13:35
• @VitalyPeryatin It was too long to reply to your comment, so I updated the answer Feb 21, 2023 at 8:28