SDK Ethers Utils

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:

MethodDescription
arrayifyConverts a hexadecimal string, number, or a byte array into a byte array.
concatConcatenates multiple byte arrays into a single byte array.
dnsEncodeConverts a string into a format suitable for use as a domain name, by replacing certain characters with escape sequences.
formatEtherFormats an Ether value as a string with a unit and decimal places.
formatUnitsFormats a value in wei as a string with a unit and decimal places.
hashMessageHashes a message using Keccak256.
hexConcatConcatenates multiple hexadecimal strings into a single hexadecimal string.
hexDataLengthConcatenates multiple hexadecimal strings into a single hexadecimal string.
hexDataSliceExtracts a slice of bytes from a hexadecimal string.
hexStripZerosExtracts a slice of bytes from a hexadecimal string.
hexValueExtracts a slice of bytes from a hexadecimal string.
hexZeroPadAdds leading zeros to a hexadecimal string to match a certain length.
hexlifyConverts a number, string, or byte array into a hexadecimal string.
idReturns a unique identifier for an object.
isBytesReturns true if an object is a byte array.
isBytesLikeReturns true if an object can be converted into a byte array.
isHexStringReturns true if a string is a valid hexadecimal string.
InterfaceGenerates a smart contract interface from a JSON ABI.
isValidNameReturns true if a string is a valid domain name.
joinSignatureConcatenates the components of a signature into a single-byte array.
namehashCalculates the name hash of a domain name.
parseEtherParses a string with a unit and decimal places into an Ether value in wei.
parseUnitsParses a string with a unit and decimal places into a value in wei.
splitSignatureSplits a byte array representing a signature into its components.
stripZerosRemoves leading zeros from a byte array.
toUtf8BytesConverts a string into a byte array in UTF-8 format.
toUtf8StringConverts a byte array in UTF-8 format into a string.
zeroPadAdds leading zeros to a byte array to match a certain length.
ReadMe