Learn about the wrapper Ethers util methods provided by Alchemy SDK
Introduction
Alchemy provides a consolidated Utils
object that supports a number of the most commonly used utils from Ethers. These methods are used as a drop-in replacement for ethers.utils
methods.
Supported Methods
Methods that are currently supported by the Utils
object are:
Method | Description |
---|---|
arrayify | Converts a hexadecimal string, number, or a byte array into a byte array. |
concat | Concatenates multiple byte arrays into a single byte array. |
dnsEncode | Converts a string into a format suitable for use as a domain name, by replacing certain characters with escape sequences. |
formatEther | Formats an Ether value as a string with a unit and decimal places. |
formatUnits | Formats a value in wei as a string with a unit and decimal places. |
hashMessage | Hashes a message using Keccak256. |
hexConcat | Concatenates multiple hexadecimal strings into a single hexadecimal string. |
hexDataLength | Concatenates multiple hexadecimal strings into a single hexadecimal string. |
hexDataSlice | Extracts a slice of bytes from a hexadecimal string. |
hexStripZeros | Extracts a slice of bytes from a hexadecimal string. |
hexValue | Extracts a slice of bytes from a hexadecimal string. |
hexZeroPad | Adds leading zeros to a hexadecimal string to match a certain length. |
hexlify | Converts a number, string, or byte array into a hexadecimal string. |
id | Returns a unique identifier for an object. |
isBytes | Returns true if an object is a byte array. |
isBytesLike | Returns true if an object can be converted into a byte array. |
isHexString | Returns true if a string is a valid hexadecimal string. |
Interface | Generates a smart contract interface from a JSON ABI. |
isValidName | Returns true if a string is a valid domain name. |
joinSignature | Concatenates the components of a signature into a single-byte array. |
namehash | Calculates the name hash of a domain name. |
parseEther | Parses a string with a unit and decimal places into an Ether value in wei. |
parseUnits | Parses a string with a unit and decimal places into a value in wei. |
splitSignature | Splits a byte array representing a signature into its components. |
stripZeros | Removes leading zeros from a byte array. |
toUtf8Bytes | Converts a string into a byte array in UTF-8 format. |
toUtf8String | Converts a byte array in UTF-8 format into a string. |
zeroPad | Adds leading zeros to a byte array to match a certain length. |