Search by

amashukov / blockchain-address-php

Typed on-chain address value objects for EVM and TON with structural equality.

Maintainers

Package info

github.com/AndreyMashukov/blockchain-address-php

pkg:composer/amashukov/blockchain-address-php

Transparency log

Statistics

Installs: 217

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.2.0 2026-08-31 13:51 UTC

This package is auto-updated.

Last update: 2026-08-31 13:51:52 UTC


README

Typed on-chain address Value Objects for EVM and TON — parse once, compare structurally, never pass a raw string again.

CI PHPStan L9 Latest Version Downloads PHP License Stars

An address Value Object layer for multi-chain PHP applications. Every address is parsed and validated at construction, so an invalid one cannot exist as an instance, and comparison is structural rather than textual — which matters because the same address has several legitimate spellings on both TON and EVM.

Features

  • Parse-at-the-boundaryfromString() throws on anything malformed, tryFromString() returns null. A constructed instance is always a valid address.
  • Structural eq() — comparison is by identity, not spelling. A TON address is equal to itself across bounceable / non-bounceable / url-safe forms; an EVM address is equal across EIP-55 checksum casing. strtolower($a) === strtolower($b) is wrong on TON and this exists to stop you writing it.
  • Cross-chain safeeq() between two different chain types is false, never a coincidental match.
  • Composite addressesErc20Address (contract + token) and JettonAddress (contract + master + wallet) carry the several identifiers those standards actually need, instead of passing three loose strings alongside each other.

Why amashukov/blockchain-address-php

Raw address strings are the classic source of silent cross-chain bugs: a TON address compared case-insensitively matches the wrong account, an EIP-55 checksummed address fails a === against its lowercase form, and an ERC-20 transfer built from "the address" sends to the token contract instead of the recipient. Making the address a type moves all of that to construction time, where it fails loudly.

Installation

composer require amashukov/blockchain-address-php

Usage

use Amashukov\BlockchainAddress\EvmAddress;
use Amashukov\BlockchainAddress\TonAddress;

$evm = EvmAddress::fromString('0xDAC17F958D2ee523a2206206994597C13D831ec7');
$evm->eq(EvmAddress::fromString('0xdac17f958d2ee523a2206206994597c13d831ec7'));  // true — checksum casing

$ton = TonAddress::fromString('UQAht13a44YMjGClyRbYCFi9sEPaQbfP6RZJhy_2RGv4Wi1D');
$ton->eq($evm);                                                                  // false — different chains

Testing

composer install
composer test
composer stan

License

MIT — see LICENSE.