MCPcopy Create free account
hub / github.com/codeaashu/claude-code / toChecksumAddress

Function toChecksumAddress

src/services/x402/config.ts:22–32  ·  view source on GitHub ↗

* EIP-55 mixed-case checksum address encoding. * Computes the checksum in-place using keccak256 of the lowercase hex address.

(address: string)

Source from the content-addressed store, hash-verified

20 * Computes the checksum in-place using keccak256 of the lowercase hex address.
21 */
22function toChecksumAddress(address: string): string {
23 const { createHash } = require('crypto') as typeof import('crypto')
24 const addr = address.toLowerCase().replace('0x', '')
25 const hash = createHash('sha3-256').update(addr).digest('hex')
26 let checksummed = '0x'
27 for (let i = 0; i < addr.length; i++) {
28 checksummed +=
29 parseInt(hash[i], 16) >= 8 ? addr[i].toUpperCase() : addr[i]
30 }
31 return checksummed
32}
33
34/**
35 * Derives an Ethereum address from a private key using secp256k1.

Callers 1

deriveAddressFunction · 0.85

Calls 1

updateMethod · 0.65

Tested by

no test coverage detected