2

I was discussing on twitter that mega NFT drops can self-regulate their affect on the network by setting an adjustable gas cap within the contract such as:

require(tx.gasPrice < gasCap, "Gas price too damn high!");

Another dev mentioned this would have been doable except that now with EIP-1559 in play, we need to be concerned about the priority fee, so this strategy may not work.

Is there any way to see what the priority fee is on a contract's tx?

1
  • no, the transaction don't keep this record. Commented Feb 24, 2022 at 1:43

1 Answer 1

4

The Priority Fee for a particular transaction is simply the difference between the gas price paid by the sender and the basefee for the particular block. Read more about that here

With this in mind, the priority fee (or miner's tip) can be computed in a contract as follows -

uint minersTip = tx.gasprice - block.basefee;

FYI here is my implementation of a gas-capped NFT drop from sometime back, which sounds pretty similar to what you're referring to. This implementation limits the miner tip by capping the percentage of gas fees that can be paid as the miner's tip.

0

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.