9

Is it possible to reliably monitor an account and receive information about a transaction of that account before the transaction is InBlock and then front-run that transaction by issuing a sufficiently larger tip? If so, how would one do this using polkadot-js?

Expanding this, the interesting problem is how to obtain the information about transactions considered for inclusion in a block. When this information is available, the transaction can be front-run by making sure that your transaction has higher priority using a sufficiently large tip (see this question). Can this information be obtained using polkadot-js?

Note: This is a problem on EVM-style networks due to the way that transactions are handled there.

1 Answer 1

7

The answer in general is yes, Substrate and Polkadot use a transaction queue just like most other blockchains, and because of this it is possible to increase the transaction fees included with some transaction to give it a higher priority in the queue than another transaction.

The order of transaction in the transaction queue is managed by a transaction's "priority", and each chain may have some custom logic which is used to calculate that priority.

In Polkadot, the easiest way to manipulate the transaction priority is to include a block author tip: https://wiki.polkadot.network/docs/learn-transaction-fees

Your second question "If so, how would one do this using polkadot-js?"...

Well probably I would not be making such a bot in Polkadot JS, since you would be unlikely to actually front-run any transactions with such a program. Instead, you probably need to build this logic into a custom Substrate / Polkadot client which itself is a block producer, and manipulates the transactions you are including in a block.

However, if you want to learn how to increase the priority of your transaction using a tip in Polkadot JS, here is a snippet:

const hash = await extrinsic.signAndSend(alice, { tip: amount });
2
  • "Instead, you probably need to build this logic into a custom Substrate / Polkadot client which itself is a block producer, and manipulates the transactions you are including in a block." - This is because only the block producers receive the info of which transactions are candidates for inclusion in a block? This info cannot be obtained using polkadot-js?
    – mkl
    Commented Feb 10, 2022 at 21:22
  • 3
    The main reason here I think it is that block producer has access to the transaction pool. Commented Feb 11, 2022 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.