Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/rhinestonewtf/warp-router/llms.txt

Use this file to discover all available pages before exploring further.

Overview

RouterUtils is a utility contract that provides pure helper functions for router operations. It contains common checks and validations that can be used across the router system.

Functions

isContractDeployed

Checks whether a contract is deployed at the specified address.
function isContractDeployed(address addr) external view returns (bool)
addr
address
The address to check for contract deployment.
Returns:
  • bool: True if a contract is deployed at the address, false otherwise
Uses the EXTCODESIZE opcode via .code.length to determine if bytecode exists at the given address. Returns true for contracts, false for EOAs (Externally Owned Accounts) or undeployed addresses.
This check will return false for addresses in the middle of construction, as constructor code is not yet stored at the address during deployment.
Example:
bool isContract = RouterUtils.isContractDeployed(0x1234...);
if (isContract) {
    // Address has contract code
}

getContractCode

Returns the contract code for a given address.
function getContractCode(address addr) external view returns (bytes memory)
addr
address
The address to retrieve contract code from.
Returns:
  • bytes: The bytecode of the contract at the address, or empty bytes if none
Retrieves the bytecode stored at the specified address. Returns an empty bytes array if no contract is deployed there. Example:
bytes memory code = RouterUtils.getContractCode(0x1234...);
if (code.length > 0) {
    // Process contract bytecode
}

Use Cases

Contract Verification

Use isContractDeployed to verify that an address contains contract code before attempting to interact with it:
require(
    RouterUtils.isContractDeployed(adapterAddress),
    "Adapter not deployed"
);

Bytecode Analysis

Use getContractCode to retrieve and analyze contract bytecode for validation or verification purposes:
bytes memory adapterCode = RouterUtils.getContractCode(adapterAddress);
// Perform bytecode analysis or verification

Build docs developers (and LLMs) love