-1

I am trying to create a coin similar to Safemoon with an added type of reflection, but my friend claims that because I am adding another for loop that the gas fees will be too high.

Do high computationally taxing transactions result in more fees?

I know a little about Big O notation but I am not an expert. Can somebody elaborate on how Pancake / BSC determines how much to charge based on each transaction's computational needs?

Thanks

Will
  • 1
  • 3

1 Answers1

0

Do high computationally taxing transactions result in more fees?

Mostly yes. For loops produce a linear complexity.

Each storage write costs 5,000 gas, which is one of the most expensive smart contract instructions. So if your function is executable (not view or pure) and has a loop with 10 iterations, each containing one storage write, that's going to cost the user a total of 71,000 gas (21k base fee + 10 * 5k).

Can somebody elaborate on how Pancake / BSC determines how much to charge

The transaction fee is not calculated by the exchange. It's your wallet that calculates it based on the set of instructions (memory read, storage write, etc; determinable from the contract bytecode and your transaction data) and the gas price of each instruction (hardcoded in the network).

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100