Addresses
Address
Working with Cardano addresses using Core.Address
Address
The Evolution SDK provides Core.Address for working with modern Cardano addresses. This module handles parsing, validation, inspection, and conversion between formats.
Modern Address Types
Cardano primarily uses two address types today:
- Base Address - Payment + staking credentials (most common)
- Enterprise Address - Payment credential only (no staking rewards)
Legacy formats (Byron, Pointer) exist for historical compatibility but are no longer used in practice.
Basic Operations
Parsing Addresses
import { } from "@evolution-sdk/evolution";
// Parse from Bech32 (most common format)
const = ..(
"addr1qx2kd28nq8ac5prwg32hhvudlwggpgfp8utlyqxu6wqgz62f79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sy0f4qd"
);
// Parse from hex
const = ..(
"01195a6a8c607b8a0237109aab5e31b7c8828509fb17e4019cd381021a4f8a081b7bd1b0d35972c0e8eaba8e5c923c99d66a3bbe78ff23c5855"
);Converting Formats
import { } from "@evolution-sdk/evolution";
const = ..(
"addr1qx2kd28nq8ac5prwg32hhvudlwggpgfp8utlyqxu6wqgz62f79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sy0f4qd"
);
// Convert to different formats
const = ..(); // "addr1qx2k..."
const = ..(); // "01195a6a..."
const = ..(); // Uint8ArrayValidating User Input
import { } from "@evolution-sdk/evolution";
function (: string): .. | null {
try {
const = ..();
// Check network (0 = testnet, 1 = mainnet)
if (. !== 1) {
.("Not a mainnet address");
}
return ;
} catch () {
.("Invalid address:", );
return null;
}
}Address Inspection
Type Checking
import { } from "@evolution-sdk/evolution";
const = ..(
"addr1qx2kd28nq8ac5prwg32hhvudlwggpgfp8utlyqxu6wqgz62f79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sy0f4qd"
);
// Check address type
const = ..(..());
const = ..(); // false
const = ..(); // true
if (?. === "Base") {
.("Base address with staking capability");
} else if () {
.("Enterprise address - no staking rewards");
}Address Details
For comprehensive information about an address:
import { } from "@evolution-sdk/evolution";
const = ..(
"addr1qx2kd28nq8ac5prwg32hhvudlwggpgfp8utlyqxu6wqgz62f79qsdmm5dsknt9ecr5w468r9ey0fxwkdrwh08ly3tu9sy0f4qd"
);
if () {
.("Type:", .); // "Base"
.("Network:", .); // 1 (mainnet)
.("Bech32:", ..); // Original Bech32 string
.("Hex:", ..); // Hex representation
}Address Construction
For advanced use cases, you can construct addresses from credentials:
import { } from "@evolution-sdk/evolution";
// Create payment credential from key hash
const = new ..({
: new (28) // 28-byte key hash
});
// Create staking credential
const = new ..({
: new (28) // 28-byte key hash
});
// Construct base address directly
const = new ..({
: 1, // mainnet
: ,
:
});
const = ..();Legacy Address Types
For historical compatibility, Evolution SDK supports legacy address formats via Core.AddressEras:
- Byron addresses - Legacy Byron-era format (no longer used)
- Pointer addresses - Reference stake credentials via on-chain pointers (deprecated)
These are automatically handled when parsing existing UTXOs but should not be used for new addresses.
Summary
| Function | Purpose |
|---|---|
fromBech32() | Parse Bech32 address string |
fromHex() | Parse hex address string |
toBech32() | Convert to Bech32 string |
toHex() | Convert to hex string |
isEnterprise() | Check if enterprise address (no staking) |
hasStakingCredential() | Check if address has staking capability |
getAddressDetails() | Get comprehensive address information |
Best Practices
- Use Base addresses for most applications (enables staking rewards)
- Validate network ID to prevent testnet/mainnet mixups
- Parse once, reuse - avoid re-parsing the same address strings
- Handle errors gracefully when parsing user input
Next Steps
- Address Validation - Error handling and validation patterns
- Address Conversion - Transform between formats
- Address Construction - Build addresses from credentials