Miscellaneous contracts containing utility functions, often related to working with different data types.



Collection of functions related to the address type

isContract(address account) → bool internal

Returns true if account is a contract.

This test is non-exhaustive, and there may be false-negatives: during the execution of a contract’s constructor, its address will be reported as not containing a contract.

It is unsafe to assume that an address for which this function returns false is an externally-owned account (EOA) and not a contract.

toPayable(address account) → address payable internal

Converts an address into address payable. Note that this is simply a type cast: the actual underlying value is not changed.

Available since v2.4.0.

sendValue(address payable recipient, uint256 amount) internal

Replacement for Solidity’s transfer: sends amount wei to recipient, forwarding all available gas and reverting on errors.

EIP1884 increases the gas cost of certain opcodes, possibly making contracts go over the 2300 gas limit imposed by transfer, making them unable to receive funds via transfer. sendValue removes this limitation.

because control is transferred to recipient, care must be taken to not create reentrancy vulnerabilities. Consider using ReentrancyGuard or the checks-effects-interactions pattern.

Available since v2.4.0.


Collection of functions related to array types.

findUpperBound([.var-type]#uint256[# array, uint256 element) → uint256] internal

Searches a sorted array and returns the first index that contains a value greater or equal to element. If no such index exists (i.e. all values in the array are strictly less than element), the array length is returned. Time complexity O(log n).

array is expected to be sorted in ascending order, and to contain no repeated elements.


Contract module that helps prevent reentrant calls to a function.

Inheriting from ReentrancyGuard will make the nonReentrant modifier available, which can be applied to functions to make sure there are no nested (reentrant) calls to them.

Note that because there is a single nonReentrant guard, functions marked as nonReentrant may not call one another. This can be worked around by making those functions private, and then adding external nonReentrant entry points to them.

If you would like to learn more about reentrancy and alternative ways to protect against it, check out our blog post Reentrancy After Istanbul.

nonReentrant() modifier

Prevents a contract from calling itself, directly or indirectly. Calling a nonReentrant function from another nonReentrant function is not supported. It is possible to prevent this from happening by making the nonReentrant function external, and make it call a private function that does the actual work.

constructor() internal