What is the Message object in solidity
?
msg
/ The message object is a global variable that holds data which will be important for access to the blockchain.
Quick Summary
#msg.data (bytes)
#msg.sender (address)
#msg.sig (bytes4)
#msg.value (uint)
msg.sender
is most commonly used. It is the address
of the original sender .
msg.value
this usually holds Ether ( Wei (ether / 1e18) ) that is sent along with the message.
msg.sig
will return a hash of the current function signature. So essentially,
function boom( address _addr) return (bytes4 _sig) {
return msg.sig
}
If you call the function boom(addr)
it will return a hash that would look like33DB172D
which would represent the hash of boom(address)
msg.data
will return a payload in bytes. It holds the calldata
as it is referred to in EVM terminology or the parameters that are passed to the function. If you pass in complex data structures into a function, the resulting msg.data
will be structured in a complex way. It organizes the incoming params in bytes and delimits them with a 32 byte integer.