I am writing and testing a smart contract. Using web3, I could not send a transaction from a Zero Address (0x0). I was wondering if it is ever possible to sign and send a transaction using the zero address. In effect the msg.sender
in the function should be the zero address.
In other words, can this require statement any time return true
?
require(msg.sender == address(0))
From what I understand:
msg.sender
in contract B's function will always be contract A's sender.Is there something wrong with my understandings or something that I am missing ?
Thanks in advance for your help.
I was wondering if it is ever possible to sign and send a transaction using the zero address.
Only if you hold the private key controlling the zero address. Which is currently probably unknown, maybe even non-existing. As you can see, there are currently no sent transactions from this address.
require(msg.sender == address(0))
This statement has about the same value as checking require(block.timestamp == 0)
. Which, if the EVM works correctly, will never happen.
I can't speak for the author's intentions - maybe they confused msg.sender
with the fact that it's common practice to emit the Transfer()
event with the first argument having the 0x0
address (usually used for minting tokens, which looks like if they were sent from the 0x0
address).
Note: Until 2017, it was possible to send a specifically signed transaction (without the correct private key) that resulted in the msg.sender
having the null sender address 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF
. This was fixed in the EIP-86, you can find more details in this article.