Address & Address Payable
In Solidity, address
and address payable
are special data types used to represent Ethereum addresses.
The address
data type has the following attributes:
balance
: returns the balance of the address in weicode
:code at the Address (can be empty)codehash
: the codehash of the Addresscall
: allows sending a message to another address with a specified amount of wei and optional data
The address payable
data type has all the attributes of the address
data type, plus additional attributes:
transfer
: same as thetransfer
attribute of theaddress
data type, but marked aspayable
so that it can receive ethersend
: same as thesend
attribute of theaddress
data type, but marked aspayable
so that it can receive ether. Note thatsend
is not recommended to be used withaddress payable
, as it can result in lost ether if the recipient address has a fallback function that consumes too much gas.
Overall, these attributes allow for interacting with Ethereum addresses and sending/receiving ether between them.
Last updated