#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.11.0)

18 releases (major breaking)

15.0.0 May 1, 2024
14.0.0 Apr 9, 2024
13.0.0 Mar 18, 2024
12.0.0 Feb 26, 2024
0.1.0-dev.2 Jul 27, 2023

#2125 in Magic Beans

Download history 291/week @ 2024-01-19 272/week @ 2024-01-26 258/week @ 2024-02-02 429/week @ 2024-02-09 792/week @ 2024-02-16 931/week @ 2024-02-23 673/week @ 2024-03-01 255/week @ 2024-03-08 669/week @ 2024-03-15 808/week @ 2024-03-22 514/week @ 2024-03-29 795/week @ 2024-04-05 530/week @ 2024-04-12 366/week @ 2024-04-19 345/week @ 2024-04-26 143/week @ 2024-05-03

1,436 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

~17–32MB
~543K SLoC