Overview
The address detection utilities help identify whether a wallet address belongs to an EVM-compatible chain (Ethereum, Polygon, etc.) or a Solana Virtual Machine (SVM) chain. These functions are essential for building adapters that support multiple blockchain ecosystems. All functions are exported fromutils/address.ts.
Functions
detectAddressType
Detects the type of blockchain address and returns the address type or null if invalid.address(string): The wallet address to check
"evm"- If the address is a valid EVM address"svm"- If the address is a valid Solana addressnull- If the address format is not recognized
runAdapter function (utils/adapter.ts:33) uses detectAddressType to validate addresses before running adapters:
requireAddressType
Same asdetectAddressType but throws an error instead of returning null for invalid addresses.
address(string): The wallet address to check
"evm"- If the address is a valid EVM address"svm"- If the address is a valid Solana address
Error- If the address format is not recognized with message:"Invalid address type, expected one of: ['evm', 'svm']"
requireAddressType to handle multi-chain support:
isEvmAddress
Checks if an address is a valid EVM (Ethereum Virtual Machine) address.address(string): The wallet address to check
true- If the address matches EVM formatfalse- Otherwise
- Start with
0xprefix - Followed by exactly 40 hexadecimal characters (0-9, a-f, A-F)
- Total length: 42 characters
isSvmAddress
Checks if an address is a valid SVM (Solana Virtual Machine) address.address(string): The wallet address to check
true- If the address matches SVM formatfalse- Otherwise
- Length between 32-44 characters (inclusive)
- Base58 encoded (valid characters:
1-9,A-H,J-N,P-Z,a-k,m-z) - Excludes confusing characters:
0,O,I,l
Type Definition
"evm"- Ethereum Virtual Machine compatible chains (Ethereum, Polygon, BSC, Arbitrum, etc.)"svm"- Solana Virtual Machine (Solana)
Implementation Details
The validation is performed using regular expressions and length checks:Error Handling
Using detectAddressType (null return)
Using requireAddressType (throws error)
Common Patterns
Multi-chain adapter support
Validating before expensive operations
See Also
- Creating an Adapter - Learn how to build adapters with address validation
- AdapterExport Type - The adapter interface that includes
supportedAddressTypes - runAdapter Function - Automatically validates addresses using these utilities