1

Have a look at this transaction for example:

https://etherscan.io/tx/0x11d96986d36240a5e5e7eab78879aa841631705370e707f15f1488a0b9d6704a

0 gas, 0 ether but plenty of tokens transferred. Obviously the gas limit is higher than the 21,000 since this is a contract but still the person who send this had spent total 0$ in fees, correct?

Now I am not planning to do this since I am a miner miself and know how absurdly hard mining is, so no need to leech on free resources but there are situations when you may need this (aka: you have token but no ether to cover fees -> you need to send token to keep sending for fees...etc).

So how do they do this? Is it roulette game where crazy node picks up this transaction despite earning nothing? I tried via myetherwallet and the transaction didn't get broadcast, maybe it appears after days?

1

...0 gas, 0 ether but plenty of tokens transferred

Just to be clear, the transaction required 47,435 gas. (gas is a measure of work done by the EVM - you can't have a 0 gas transaction.)

... but still the person who send this had spent total 0$ in fees, correct?

Correct. They just submitted a transaction with gas price set to 0, which is fine.

Now I am not planning to do this since I am a miner miself and know how absurdly hard mining is, so no need to leech on free resources but there are situations when you may need this (aka: you have token but no ether to cover fees -> you need to send token to keep sending for fees...etc).

There are various efforts underway to implement schemes that would allow this. See:

  • ERC-865 - Pay transfers in tokens instead of gas, in one transaction
  • "Meta-transactions" (e.g. ERC-1776 - Native Meta Transactions)

So how do they do this?

You submit the transaction with gas price set to 0.

Is it roulette game where crazy node picks up this transaction despite earning nothing?

There could be various reasons for a miner picking up these transactions. (I've detailed two, but there are probably more.)

Miners don't sit there manually adding transactions to candidate blocks. Their mining software does it for them. In cases where the number of pending transactions in the transaction pool is low, and in the absence of any higher-priced transactions, 0-priced transactions will be added to the block automatically. (See What is the default ordering of transactions during mining, in e.g. geth?)

There are cases where a miner might want to create a block that is as full as possible. (e.g. If they strategically want the propagation or verification time of that block to be particularly high.) If there are no transactions of a size that would lead to a full-as-possible block, he may pick a 0-priced transaction because it's of just the right size to fill the block. (Again, this is probably more likely to happen when the pending transaction count is very low.)

But yes, there's a gamble by the user sending the transaction that it will get into a block in a timely manner. If a user isn't in a rush, but is happy to accept that the transaction will be included at some time in the future, then such a wait might not be a problem.

I tried via myetherwallet and the transaction didn't get broadcast, maybe it appears after days?

Hmm. Maybe certain wallets have disabled 0-priced transactions on the assumption that the user has made an error. You might have to do this manually (e.g. via Web3).

(and I am NOT planning to this but how)

There are no rules against this. You're just entering the gas price market at the bottom, so set your expectations accordingly.

  • From your own answer you linked to, github.com/ethereum/go-ethereum/blob/… seems to skip transactions below some minimum gas price. I'm not sure what the threshold is, but I assume 0 is typically below it. In any case, the spirit of the answer is right: nothing in the protocol disallows 0 as a gas price. But in practice, I'm not sure which miners are including such transactions. – smarx Aug 20 at 0:46
  • A related story which I stumbled upon when answering a similar question: reddit.com/r/ethereum/comments/7lx1do/… – Lauri Peltonen Aug 20 at 5:48
  • Was just about to propose that you might be the right person to answer it, following a comment that you made the day before on a different question, suggesting how one could theoretically execute a transaction with no funds (using zero gas-price). – goodvibration Aug 20 at 6:55
  • Hi @smarx. Good point. Digging in the code a bit more, it looks like the minimum gasPrice is set when the worker thread is started, using setGasPrice(). I think this is exposed to Web3's Miner API, so presumably this can just be set to 0, e.g. web3.geth.miner.setGasPrice(0). – Richard Horrocks Aug 20 at 21:56
  • (That possibly answers the "how" but doesn't add anything to the "why".) – Richard Horrocks Aug 20 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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