Skip to main content
9 votes
Accepted

What are the Steps for Encoding an Extrinsic in Substrate?

More generally, if you were to SCALE encode a signed transaction, you'd follow these steps: Combine the call, extra and additional data and SCALE encode it: call data: the pallet index, call index ...
Sacha Lansky's user avatar
  • 2,640
5 votes

How to create custom origin that executes abritrary code on transactions

If you wish to execute custom logic on all transactions in your system, then a SignedExtension is the way to go. It can be used to introduce both new data into your chain's transactions, as well as ...
Gav's user avatar
  • 2,681
5 votes
Accepted

Pre-dispatch Error

The transaction is not really put back if verification fails with InvalidTransaction::ExhaustsResources, it is just kept in the transaction pool. You can find some notes about it here: https://github....
NachoPal's user avatar
  • 514
4 votes
Accepted

How can I check origin in a SignedExtension?

You could check the 'who' parameter in the 'fn validate()' function. An example from the chech_non_zero_sender extension: https://github.com/paritytech/substrate/blob/...
Daan van der Plas's user avatar
4 votes
Accepted

Why signature diverse with same additon signed of SignedExtension?

In sr25519 the signatures are non-deterministic. That means for the same input it will generate different signatures each time it is called. This is different from ed25519 and secp256k1 where the same ...
Jaco's user avatar
  • 5,865
4 votes
Accepted

How to enable free execution for specific extrinsics using the SkipCheckIfFeeless

This is a great question! SkipCheckIfFeeless was indeed designed as a mechanism to trigger transactions without requiring the existence of the sender's account. So, this error should be fixed at the ...
gupnik's user avatar
  • 66
3 votes

Difference between SignedExtension default behavior vs. actual behavior (expand_outer_validate_unsigned)

The lifecycle of a extrinsic validation is the following: The transaction pool call the Runtime API validate_transaction method There, validate_transaction from the Executive pallet is called. uxt is ...
NachoPal's user avatar
  • 514
3 votes

feeless transactions unsigned vs signed extension

It depends on the situation so one is not better than the other. Unsigned extrinsics can be used by validators, very similar to inherents (adding information to a block). Maybe when the use case is ...
Daan van der Plas's user avatar
3 votes

Unsigned Transactions vs Signed Extensions

Have a look to Bruno's answer here. It covers both rationale and transaction lifecycle for unsigned extrinsics.
Iker's user avatar
  • 1,356
2 votes
Accepted

The era of Sign with no submission action is different than submit

They are representing the same thing. The left image is merely a more tangible representation. Era is defined as: pub enum Era { /// The transaction is valid forever. The genesis hash must be ...
Gav's user avatar
  • 2,681
2 votes

What are the Steps for Encoding an Extrinsic in Substrate?

As most Substrate builders are Rust natives, the best examples of extrinsic formation and submission can be found in subxt. For your specific example, sp_runtime::traits::SignedExtension can be ...
Nuke's user avatar
  • 1,842
2 votes

How does the `TaggedTransactionQueue` runtime API know what parts of the encoded call to check?

Per my understanding, The transaction pool doesn't know much about the extrinsics, pretty much they are opaque for the pool. But the runtime comes to save the day. TaggedTransactionQueue runtime API ...
Alejandro Martínez's user avatar
2 votes

SignedExtension Transaction Pool Deduplication

What's your definition of the duplication. Here is an example. As you can see there's a matcher to analyze the call struct. Then you could do something like this: Some(Call::set_dummy { maybe_a_hash, ....
AurevoirXavier's user avatar
  • 10.6k
2 votes

feeless transactions unsigned vs signed extension

Having feeless signed transactions could make your chain vulnerable to the chain being spammed. A better approach could be, is to update DispatchResultWithPostInfo with Pays::No for special conditions ...
Ankan's user avatar
  • 335
2 votes
Accepted

How does one block specific accounts from calling extrinsics for a substrate pallet?

I think the best option you have here is using a SignExtension. There, you can filter by who (checking a whitelisted list in storage), for those signed call that match with pallet_democracy::Call::...
NachoPal's user avatar
  • 514
2 votes

How does one block specific accounts from calling extrinsics for a substrate pallet?

One easy way to do this without needing to change the pallet code too much, as you said, is using signed extensions. Here's one that does a similar thing: https://github.com/paritytech/substrate/pull/...
kianenigma's user avatar
  • 2,799
2 votes
Accepted

Transaction Prioritization

The default Substrate transaction queue uses the TaggedTransactionQueue Runtime API to query the runtime about the validity and priority of queued transactions. Under the hood, this is usually ...
rob's user avatar
  • 2,126
2 votes

CheckNonZeroSender

sr25519 and ed25519 the private key for the all-zeros-public-key is known. However, in ecdsa this isn't the case and people used the all-zeros-public-key as destination when they wanted to "burn&...
bkchr's user avatar
  • 11.5k
2 votes
Accepted

CheckNonZeroSender

I think this because the all-zero address is a 'well-known' key. It is dangerous, and people love to use the default value. Maybe get an account from Vec::default() in some corner cases. So we forbid ...
AurevoirXavier's user avatar
  • 10.6k
2 votes

how to pay transaction fee through custom token?

Since you are not providing a lot of information it is hard to help you, but let me give you the main configurations you have to make in your runtime/src/lib.rs: For paying fees with custom token you'...
Daan van der Plas's user avatar
2 votes

How to build the browser extension with substrate?

Yes, you can. You can take a look for inspiration of two of the most populars browser extensions PolkadotJS Extension and Talisman. To build it yourself and connect to Substrate-base chains in a ...
Alex Bean's user avatar
  • 5,747
2 votes

How do third party apps handle paying transaction fees for chains using `pallet-asset-tx-payment`

By looking at Transaction Construction and Signing you'll see that nothing changes for 3rd party apps. The logic that will include the signer to pay for the transaction with an asset all happens on ...
Daan van der Plas's user avatar
1 vote
Accepted

SignedExtension and nested calls

No, the SignedExtension::validate will not be called for nested calls. If you want to filter certain calls, you can use BaseCallFilter in your runtime. This filter is checked before each dispatch of a ...
bkchr's user avatar
  • 11.5k
1 vote
Accepted

Informing polkadot/api about additional signed extensions

extrinsic maps to the struct where the trait SignExtension is implemented. You can see it clearly comparing ChargeAssetTxPayment and its definition here You are right about payload mapping to ...
NachoPal's user avatar
  • 514
1 vote

Difference between SignedExtension default behavior vs. actual behavior (expand_outer_validate_unsigned)

I think @robert-la-ferla and I may have answered the question that I had originally. To recap, for an UnsignedExtension, looking at primitives/runtime/src/generic/checked_exstrinsic#validate, the ...
Shannon Wells's user avatar
1 vote

SignedExtension to mutate Origin

I have no access to it simply because it's a macro that gets expanded on compile time. You can actually replace the generated code with the edits as lib.rs and it should be possible to use it. Next ...
Purple_Turtle's user avatar
1 vote

SignedExtension to mutate Origin

Very interesting problem but I believe you cannot modify ensure_signed as per this answer. Is it possible to define a custom origin in my pallet?
Mrisho Lukamba's user avatar
1 vote
Accepted

why does pre-dispatch in SignedExtension require you to call validate?

The reason why you need the same logic for checking the validity in both is that a node is not required to call validate_transaction. This function (which is called here) is only an optimization for ...
Daan van der Plas's user avatar
1 vote

what happens if I leave out ensure_signed from extrinsic?

The problem with allowing unsigned extrinsics is that nobody pays for the consumed weight. So you are basically doing work for free - normally undesirable. The only use-case where it is a good idea ...
Oliver Tale-Yazdi's user avatar
1 vote

what happens if I leave out ensure_signed from extrinsic?

Have you tried submit_unsigned? I think people could submit unsigned transactions on your chain without paying any fee. Obviously, this will cause something like DDOS. Use a script to submit the ...
AurevoirXavier's user avatar
  • 10.6k

Only top scored, non community-wiki answers of a minimum length are eligible