Crates.io | pallet-feeless |
lib.rs | pallet-feeless |
version | 0.0.2 |
created_at | 2025-04-11 12:25:49.479935+00 |
updated_at | 2025-04-14 08:04:24.156275+00 |
description | A pallet to implement a feeless Substrate blockchain node. |
homepage | https://github.com/bgallois/substrate-feeless-solochain-template |
repository | https://github.com/bgallois/substrate-feeless-solochain-template |
max_upload_size | |
id | 1629783 |
size | 41,228 |
Welcome to pallet-feeless โ a plug-and-play solution to enable fully feeless transactions in any Substrate-based blockchain! โจ
Instead of charging transaction fees, this pallet uses a rate-limiting system to ensure fair usage and network security. It's perfect for applications where user experience, accessibility, and cost-efficiency are top priorities.
Most blockchains rely on transaction fees to prevent spam and incentivize validators. While effective, this system can create friction, especially for:
This pallet removes transaction fees altogetherโeven during congestionโby using a rate-limiting extrinsic extension. This makes your blockchain:
Instead of fees, each account is subject to a rate limit:
This is enforced via a custom extrinsic extension (CheckRate
) that plugs into Substrateโs transaction validation pipeline alongside checks like:
CheckNonce
CheckWeight
CheckEra
All validation and accounting are performed before and after dispatch, with minimal storage access to preserve performance and security.
AccountData
in frame_system
type AccountData = pallet_feeless::AccountData<Balance, BlockNumber>;
This custom account type stores balance, last block, and rate data per account.
AccountStore
in pallet_balances
type AccountStore = Account;
Required to track the accountโs storage location and enable rate tracking.
pallet_feeless
Add your custom settings in the runtime:
impl pallet_feeless::Config for Runtime {
type MaxTxByPeriod = ConstU32<128>; // Max transactions per period
type MaxSizeByPeriod = ConstU32<1>; // Max size in bytes per period
type Period = ConstU32<5>; // Length of the rate-limiting window (in blocks)
type RuntimeEvent = RuntimeEvent;
type WeightInfo = (); // Do not forget to generate and reference the weight after benchmarking
}
Extend the runtime transaction validation to include CheckRate
:
pub type TxExtension = (
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckEra<Runtime>,
frame_system::CheckNonce<Runtime>,
pallet_feeless::CheckRate<Runtime>, // ๐ Rate limit extension
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);
In benchmarking.rs
or similar:
let tx_ext: runtime::TxExtension = (
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
frame_system::CheckGenesis::<runtime::Runtime>::new(),
frame_system::CheckEra::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
period,
best_block.saturated_into(),
)),
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
pallet_feeless::CheckRate::<runtime::Runtime>::new(), // ๐ Add this
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(false),
);
let raw_payload = runtime::SignedPayload::from_raw(
call.clone(),
tx_ext.clone(),
(
(),
runtime::VERSION.spec_version,
runtime::VERSION.transaction_version,
genesis_hash,
best_hash,
(),
(), // ๐ Add this
(),
(),
None,
),
);
๐ซ No Transaction Fees
Users never worry about price fluctuations.
โ๏ธ Built-in Fairness
Every account gets a rate limit, ensuring equal access.
๐ ๏ธ Developer Friendly
Build dApps without forcing users to hold or buy tokens.
๐ Accessible UX
Lower onboarding friction and support for micro-use cases.
While this system improves user experience, keep in mind:
Just include this pallet in your Substrate runtime and configure the limits to your needs. No additional infrastructure or fee logic is required!
MIT โ open-source and ready to use in your blockchain projects.