May 2, 2026

Solidity Tutorial : all about Addresses – Jean Cvllr

Solidity Tutorial : all about Addresses – Jean Cvllr

Solidity Tutorial : all about Addresses – Jean Cvllr

Solidity Tutorial : all about Addresses – Jean Cvllr

You define a variable as an address type by simply specifying the keyword address in front of the variable name.

address user = msg.sender

Here we use the Solidity built-in function msg.sender to retrieve the address of the account that interacted with the smart contract.

Address literals

Address literals are the hexadecimal representation of an Ethereum address (prefixed with 0x) that pass the checksum test. (Apparently their size range from 39 to 41 digits). You can declare address literals in Solidity as follow :

address owner = 0xc0ffee254729296a45a3885639AC7E10F9d54979

Address literals that do not pass the checksum test bring up a warning and are, additionally, treated a regular rational number intervals.

The mixed-case address checksum format is defined in EIP-55

Address literals (hexadecimal representation of an address) are by default set as address payable .

address vs address payable ?

The distinction between address and address payable was introduced with version 0.5.0 of Solidity.

Tdhe idea behind this distinction is that address payable is an address you can send Ether to, while a plain address cannot be sent Ether.

When assigning the keyword payable to an address variable in Solidity, the address (variable) can send and receive Ethers. As a result, all the other methods (transfer, send, call, delegatecall and staticcall) become available for this variable.

Type conversion between address andaddress payable

  • Implicit conversions from address payable to address are allowed

Give an example of user list.

  • Implicit conversions from address to address payable are not possible (except for address payable).

NB: the only way to convert from address to address payable is by using an intermediate conversion to uint160 (160 bits = 20 bytes, the size of an Ethereum address).

  • Explicit conversion from and to address are allowed for : integers, integer literals, bytes20 and contract type.
  • Explicit conversion in the form address payable(x) (where x = integers, integer literal, bytes or contract type).
  • The result of a conversion in the form address(x) has the type address payable, if x is of integer or fixed bytes type, a literal or a contract with a payable fallback function.

Contracts as address

Before version 0.5.0, contracts directly derived from the address type (since there was no distinction between address and address payable ).

Starting from version 0.5.0 of Solidity, contracts do not derive from the address type anymore. However, they can still be explicitly converted to and from address and address payable, if they have a payable fallback function.

Let’s assume the following code :

contract NotPayable contract Payable }
contract HelloWorld }

Let’s look at our Hello World contract to understand :

  • NotPayable is a contract without a payable fallback function. The the variable x which is assigned the value address(NotPayable) will be of type address.
  • Payable is a contract with a payable fallback function. The the variable y which is assigned the value address(Payable) will be of type address payable.

NB : The conversion is still performed using address(variable) and not using address payable(variable).

  • An external function signatures address is used for both the address and the address payable type.

address conversion using operators

The following operators are available with addresses : <=, <, ==, !=, >= and > .

Published at Thu, 01 Aug 2019 13:09:06 +0000

{flickr|100|campaign}

Previous Article

Announcement of competition by Bitcoin (BTC) Meister in direct cooperation with Green World Project

Next Article

Ethereum Market Bias Can Breakup with Bitcoin: Burniske

You might be interested in …

Share your Opinion with Ethx – Ethx.co

Share your Opinion with Ethx – Ethx.co This is a weekly series, where we collecting opinions from thoughts leader across Blockchain and Crypto community. Question of the week What’s your take on regulation? why government […]