Skip to main content

Address

View Source: contracts/ext_libs/Address.sol

Address

Functions

isContract

Returns true if account is a contract.
[IMPORTANT]

It is unsafe to assume that an address for which this function returns
false is an externally-owned account (EOA) and not a contract.
Among others, isContract will return false for the following
types of addresses:
- an externally-owned account
- a contract in construction
- an address where a contract will be created
- an address where a contract lived, but was destroyed

[IMPORTANT]

You shouldn't rely on isContract to protect against flash loan attacks!
Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
constructor.

function isContract(address account) 
internal
view
returns(bool)

Arguments

NameTypeDescription
accountaddress

Returns

bool

functionCall

Performs a Solidity function call using a low level call. A
plain call is an unsafe replacement for a function call: use this
function instead.
If target reverts with a revert reason, it is bubbled up by this
function (like regular Solidity function calls).
Returns the raw returned data. To convert to the expected return value,
use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
Requirements:
- target must be a contract.
- calling target with data must not revert.
Available since v3.1.

function functionCall(address target,
bytes data)
internal

returns(bytes)

Arguments

NameTypeDescription
targetaddress
databytes

Returns

bytes

functionCall

Same as {xref-Address-functionCall-address-bytes-}[functionCall], but with
errorMessage as a fallback revert reason when target reverts.
Available since v3.1.

function functionCall(address target,
bytes data,
string errorMessage)
internal

returns(bytes)

Arguments

NameTypeDescription
targetaddress
databytes
errorMessagestring

Returns

bytes

functionCallWithValue

Same as {xref-Address-functionCall-address-bytes-}[functionCall],
but also transferring value wei to target.
Requirements:
- the calling contract must have an ETH balance of at least value.
- the called Solidity function must be payable.
Available since v3.1.

function functionCallWithValue(address target,
bytes data,
uint256 value)
internal

returns(bytes)

Arguments

NameTypeDescription
targetaddress
databytes
valueuint256

Returns

bytes

functionCallWithValue

Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[functionCallWithValue], but
with errorMessage as a fallback revert reason when target reverts.
Available since v3.1.

function functionCallWithValue(address target,
bytes data,
uint256 value,
string errorMessage)
internal

returns(bytes)

Arguments

NameTypeDescription
targetaddress
databytes
valueuint256
errorMessagestring

Returns

bytes

verifyCallResult

Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
revert reason using the provided one.
Available since v4.3.

function verifyCallResult(bool success,
bytes returndata,
string errorMessage)
internal
pure
returns(bytes)

Arguments

NameTypeDescription
successbool
returndatabytes
errorMessagestring

Returns

bytes