Constants.ADDRESS_ZERO

A string representing the zero address 0x0000000000000000000000000000000000000000.

Useful for passing the zero address to various functions.

Constants.NATIVE_TOKEN_ADDRESS

A string representing the native token address 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE.

Useful for passing the native token address to various functions.

GetChainMetadata

Fetches chain data for a specified chain ID using a Thirdweb client.

var chainData = await Utils.GetChainMetadata (client, chainId);

HexConcat

Concatenates the given hex strings into a single hex string.

var concatenatedHex = Utils.HexConcat("0x1234", "0x5678");

HashPrefixedMessage

Hashes the given message bytes with a prefixed message for Ethereum signing.

var hashedMessage = messageBytes.HashPrefixedMessage();

HashMessage

Hashes the given message using SHA3 Keccak hashing.

var hashedMessage = message.HashMessage();

BytesToHex

Converts a byte array to a hexadecimal string.

var hexString = byteArray.BytesToHex();

HexToBytes

Converts a hexadecimal string to a byte array.

var byteArray = hexString.HexToBytes();

StringToHex

Converts a regular string to a hexadecimal string.

var hexString = "Hello".StringToHex();

GetUnixTimeStampNow

Gets the current Unix timestamp in seconds.

var timestampNow = Utils.GetUnixTimeStampNow();

GetUnixTimeStampIn10Years

Gets the Unix timestamp for 10 years from now.

var timestampIn10Years = Utils.GetUnixTimeStampIn10Years();

ReplaceIPFS

Replaces an IPFS URI with a specified gateway.

var gatewayUri = ipfsUri.ReplaceIPFS("https://ipfs.io/ipfs/");

ToWei

Converts Ether values to Wei.

var weiValue = ethValue.ToWei();

ToEth

Converts Wei values to Ether.

var ethValue = weiValue.ToEth();

GenerateSIWE

Generates a Sign-In With Ethereum (SIWE) message.

var siweMessage = Utils.GenerateSIWE(loginPayloadData);

IsZkSync

Checks if a given chain ID corresponds to zkSync.

var isZkSync = Utils.IsZkSync(chainId);

ToChecksumAddress

Converts an Ethereum address to its checksum format.

var checksummedAddress = address.ToChecksumAddress();

AdjustDecimals

Adjusts the decimal places of a value.

var adjustedValue = value.AdjustDecimals(18, 6);

ToJsonExternalWalletFriendly

Converts typed data into a JSON string suitable for external wallet interaction.

var jsonString = Utils.ToJsonExternalWalletFriendly(typedData, message);