Evolution SDK
Addresses

Address Validation

Validate and verify Cardano addresses

Address Validation

Validating addresses is critical before using them in transactions. The SDK provides utilities to parse and validate addresses with error handling.

Basic Validation

Create a helper function for safe address validation:

import {  } from "@evolution-sdk/evolution";

function (: string) {
  try {
    const  = ..();
    return { : true,  } as ;
  } catch () {
    return { : false,  } as ;
  }
}

// Usage
const  = ("addr1qx2kd28nq8ac5prwg32hhvudlwggpgfp8utlyqxu6wqgz62f79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sy0f4qd");
if (.) {
  .("Valid address:", .);
} else {
  .("Invalid address:", .);
}

Network Validation

Verify an address belongs to the expected network:

import {  } from "@evolution-sdk/evolution";

function (
  : string,
  : "mainnet" | "testnet"
): boolean {
  try {
    const  = ..();
    const  =  === "mainnet" ? 1 : 0;
    
    if (. !== ) {
      .(
        `Wrong network: expected ${}, got ${. === 1 ? "mainnet" : "testnet"}`
      );
      return false;
    }
    
    return true;
  } catch () {
    .("Invalid address:", );
    return false;
  }
}

// Usage
const  = ("addr1qx2kd28nq8ac5prwg32hhvudlwggpgfp8utlyqxu6wqgz62f79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sy0f4qd", "mainnet"); // true
const  = ("addr_test1qz...", "mainnet"); // false

Address Type Checking

Check if an address has staking credentials:

import {  } from "@evolution-sdk/evolution";

function (: string): boolean {
  try {
    const  = ..();
    return ..();
  } catch {
    return false;
  }
}

function (: string): boolean {
  try {
    const  = ..();
    return ..();
  } catch {
    return false;
  }
}

// Usage
.(("addr1qx...")); // true for base addresses
.(("addr1vx...")); // true for enterprise addresses

Common Validation Scenarios

User Input Validation

import {  } from "@evolution-sdk/evolution";

function (: string): string | null {
  const  = .();
  
  try {
    ..();
    return ;
  } catch () {
    ("Invalid address format. Please check and try again.");
    return null;
  }
}

Bulk Validation

import {  } from "@evolution-sdk/evolution";

function (: string[]): {
  : string[];
  : { : string; : string }[];
} {
  const : string[] = [];
  const : { : string; : string }[] = [];
  
  for (const  of ) {
    try {
      ..();
      .();
    } catch () {
      .({ : , : () });
    }
  }
  
  return { ,  };
}

Next Steps