REGEXVAULTv2.0
Finance/Crypto
Verified Safe

Ethereum Checksummed Address (EIP-55) Regex for Go

/^0x(?:[0-9A-F]{40}|[0-9a-f]{40}|(?:[0-9a-fA-F]{40}))$/

What this pattern does

This page provides a well-structured, multi-part regular expression for matching ethereum checksummed address (eip-55), ported and verified for Go. Financial data validation has zero tolerance for false negatives — a missed invalid entry can corrupt downstream calculations. The snippet below is ready to drop into your Go project — whether you're validating in a Gin handler, a gRPC service, or a command-line tool.

Go Implementation

Go
// Ethereum Checksummed Address (EIP-55)
// ReDoS-safe | RegexVault — Finance > Crypto

package validation

import "regexp"

var ethereumChecksummedAddressEip55Re = regexp.MustCompile(`^0x(?:[0-9A-F]{40}|[0-9a-f]{40}|(?:[0-9a-fA-F]{40}))$`)

func ValidateEthereumChecksummedAddressEip55(s string) bool {
    return ethereumChecksummedAddressEip55Re.MatchString(s)
}

// Example
// fmt.Println(ValidateEthereumChecksummedAddressEip55("0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2")) // true

Test Cases

Matches (Valid)
Rejects (Invalid)
0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb20x742d35Cc6634C0532925a3b844Bc454e4438f44g
0x0000000000000000000000000000000000000000742d35Cc6634C0532925a3b844Bc454e4438f44e
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0x742d35Cc6634C0532925a3b844Bc454e4438f44eX

When to use this pattern

This pattern is drawn from the Finance > Crypto category and carries a ReDoS-safe certification. That matters for Go developers because Go's RE2 engine is inherently safe from catastrophic backtracking, but this pattern has been additionally verified for correctness. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.

Common Pitfalls

An Ethereum address is technically valid with any casing — EIP-55 checksum is optional but strongly recommended. Many wallets will warn if you send to an unchecksummed address.

Technical Notes

EIP-55 checksum embeds a SHA3 hash of the lowercase address in the casing of the hex letters. A correctly checksummed address has mixed case. Regex alone cannot verify EIP-55 — use a library. This pattern just validates the format.

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.

Submit a Pattern