Files
openzeppelin-contracts/contracts/utils
Hadrien Croubois 93438eca0b Merge 3.4 master into solc-0.8 (#2499)
* 3.4.0-rc.0

* Allow manual dispatch of Test CI job

* Update lockfile (#2481)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* Add "available since" comments in documentation

* Add "available since" comments in documentation

(cherry picked from commit 63a0343dda)

* Remove SafeMathMock compilation warnings (#2497)

* Remove SafeMathMock compilation warnings (#2497)

(cherry picked from commit f4e57fd529)

* 3.4.0

* fix safemath test to use renamed function from the mock

Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2021-02-02 22:07:56 +01:00
..
2021-01-26 18:58:15 +01:00
2021-01-26 18:58:15 +01:00
2020-09-01 14:57:40 -03:00
2021-01-26 18:58:15 +01:00

= Utilities

[.readme-notice]
NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/utils

Miscellaneous contracts and libraries containing utility functions you can use to improve security, work with new data types, or safely use low-level primitives.

Security tools include:

 * {Pausable}: provides a simple way to halt activity in your contracts (often in response to an external threat).
 * {ReentrancyGuard}: protects you from https://blog.openzeppelin.com/reentrancy-after-istanbul/[reentrant calls].

The {Address}, {Arrays} and {Strings} libraries provide more operations related to these native data types, while {SafeCast} adds ways to safely convert between the different signed and unsigned numeric types.

For new data types:

 * {Counters}: a simple way to get a counter that can only be incremented or decremented. Very useful for ID generation, counting contract activity, among others.
 * {EnumerableMap}: like Solidity's https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] type, but with key-value _enumeration_: this will let you know how many entries a mapping has, and iterate over them (which is not possible with `mapping`).
 * {EnumerableSet}: like {EnumerableMap}, but for https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets]. Can be used to store privileged accounts, issued IDs, etc.

[NOTE]
====
Because Solidity does not support generic types, {EnumerableMap} and {EnumerableSet} are specialized to a limited number of key-value types.

As of v3.0, {EnumerableMap} supports `uint256 -> address` (`UintToAddressMap`), and {EnumerableSet} supports `address` and `uint256` (`AddressSet` and `UintSet`).
====

Finally, {Create2} contains all necessary utilities to safely use the https://blog.openzeppelin.com/getting-the-most-out-of-create2/[`CREATE2` EVM opcode], without having to deal with low-level assembly.

== Contracts

{{Pausable}}

{{ReentrancyGuard}}

== Libraries

{{Address}}

{{Arrays}}

{{Counters}}

{{Create2}}

{{EnumerableMap}}

{{EnumerableSet}}

{{SafeCast}}

{{Strings}}