Strings
Title: Strings
Author: Vendored minimal subset of OpenZeppelin Contracts v5.6.1
(https://github.com/OpenZeppelin/openzeppelin-contracts/blob/5fd1781b1454fd1ef8e722282f86f9293cacf256/contracts/utils/Strings.sol).
Upstream license: MIT. Only the address→hex helpers and the decimal toString are re-declared (the full
Strings lib pulls in Math/SignedMath/Bytes; toString is re-implemented Math-free). Vendored
subset — do not add an openzeppelin-contracts dependency.
Address-to-string and uint-to-decimal-string helpers, incl. EIP-55 checksummed hex (needed by
gateway adapters that address remote contracts or chains by string, e.g. Axelar names and
Hyperbridge EVM-<chainId> state machine ids).
Constants
HEX_DIGITS
bytes16 private constant HEX_DIGITS = "0123456789abcdef";ADDRESS_LENGTH
uint8 private constant ADDRESS_LENGTH = 20;Functions
toString
Converts a uint256 to its ASCII decimal string.
Math-free re-implementation (upstream sizes the buffer via Math.log10); two passes — count the
digits, then fill the buffer least-significant first.
function toString(uint256 value) internal pure returns (string memory);Parameters
| Name | Type | Description |
|---|---|---|
| value | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |
toHexString
Converts a uint256 to its ASCII hex string with fixed length (bytes), 0x-prefixed.
function toHexString(uint256 value, uint256 length) internal pure returns (string memory);Parameters
| Name | Type | Description |
|---|---|---|
| value | uint256 | |
| length | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |
toHexString
Converts an address to its (not checksummed) 20-byte ASCII hex string.
function toHexString(address addr) internal pure returns (string memory);Parameters
| Name | Type | Description |
|---|---|---|
| addr | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |
toChecksumHexString
Converts an address to its EIP-55 checksummed ASCII hex string.
function toChecksumHexString(address addr) internal pure returns (string memory);Parameters
| Name | Type | Description |
|---|---|---|
| addr | address |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | string |
Errors
StringsInsufficientHexLength
toHexString was given a length too short for value.
error StringsInsufficientHexLength(uint256 value, uint256 length);Parameters
| Name | Type | Description |
|---|---|---|
| value | uint256 | |
| length | uint256 |