This value type holds a 20-byte value, which is the size of an Ethereum address (40 hex characters or 160 bits). Take a look at this:
address a = 0xe2793a1b9a149253341cA268057a9EFA42965F83
This type has several members that can be used to interact with the contract. These members are as follows:
- balance
- transfer
- send
- call
- callcode
- delegatecall
balance returns the balance of the address in units of wei, for example:
address a = 0xe2793a1b9a149253341cA268057a9EFA42965F83;
uint bal = a.balance;
transfer is used to transfer from one address to another address, for example:
address a = 0xe2793a1b9a149253341cA268057a9EFA42965F83;
address b = 0x126B3adF2556C7e8B4C3197035D0E4cbec1dBa83;
if (a.balance > b.balance) b.transfer(6);
Almost the same amount of gas is spent when we use transfer, or send members. transfer was introduced from Solidity 0.4.13, as send does not send any gas and also does not propagate exceptions. Transfer is considered a safe way to send ether from one address to another address, as it throws an error and allows someone to propagate the error.
The call, callcode, and delegatecall are used to interact with functions that do not have Application Binary Interface (ABI). call returns a Boolean to indicate whether the function ran successfully or got terminated in the EVM.
When a does call on b, the code runs in the context of b, and the storage of b is used. On the other hand, when a does callcode on b, the code runs in the context of a, and the storage of a is used, but the code of and storage of a is used.
The delegatecall function is used to delegate one contract to use another contract's storage as required.