#assets #native #pallet #payment #fee #transaction #converting

no-std pallet-asset-conversion-tx-payment

Pallet to manage transaction payments in assets by converting them to native assets. (polkadot v1.10.0)

17 releases (11 major breaking)

new 14.0.0 Apr 9, 2024
13.0.0 Mar 18, 2024
12.0.0 Feb 26, 2024
11.0.0 Feb 13, 2024
0.1.0-dev.2 Jul 27, 2023

#2175 in Magic Beans

Download history 144/week @ 2023-12-18 19/week @ 2023-12-25 487/week @ 2024-01-01 434/week @ 2024-01-08 169/week @ 2024-01-15 327/week @ 2024-01-22 288/week @ 2024-01-29 244/week @ 2024-02-05 459/week @ 2024-02-12 864/week @ 2024-02-19 1032/week @ 2024-02-26 528/week @ 2024-03-04 268/week @ 2024-03-11 721/week @ 2024-03-18 788/week @ 2024-03-25 608/week @ 2024-04-01

2,407 downloads per month
Used in 4 crates (3 directly)

Apache-2.0

2MB
41K SLoC

pallet-asset-conversion-tx-payment

Asset Conversion Transaction Payment Pallet

This pallet allows runtimes that include it to pay for transactions in assets other than the native token of the chain.

Overview

It does this by extending transactions to include an optional AssetId that specifies the asset to be used for payment (defaulting to the native token on None). It expects an OnChargeAssetTransaction implementation analogously to pallet-transaction-payment. The included AssetConversionAdapter (implementing OnChargeAssetTransaction) determines the fee amount by converting the fee calculated by pallet-transaction-payment into the desired asset.

Integration

This pallet wraps FRAME's transaction payment pallet and functions as a replacement. This means you should include both pallets in your construct_runtime macro, but only include this pallet's SignedExtension (ChargeAssetTxPayment).

License: Apache-2.0


lib.rs:

Asset Conversion Transaction Payment Pallet

This pallet allows runtimes that include it to pay for transactions in assets other than the chain's native asset.

Overview

This pallet provides a SignedExtension with an optional AssetId that specifies the asset to be used for payment (defaulting to the native token on None). It expects an OnChargeAssetTransaction implementation analogous to pallet-transaction-payment. The included AssetConversionAdapter (implementing OnChargeAssetTransaction) determines the fee amount by converting the fee calculated by pallet-transaction-payment in the native asset into the amount required of the specified asset.

Pallet API

This pallet does not have any dispatchable calls or storage. It wraps FRAME's Transaction Payment pallet and functions as a replacement. This means you should include both pallets in your construct_runtime macro, but only include this pallet's SignedExtension (ChargeAssetTxPayment).

Terminology

  • Native Asset or Native Currency: The asset that a chain considers native, as in its default for transaction fee payment, deposits, inflation, etc.
  • Other assets: Other assets that may exist on chain, for example under the Assets pallet.

Dependencies

~18–31MB
~518K SLoC