AddressService.php 505 B

1234567891011121314151617181920
  1. <?php
  2. namespace App\Module\UrausSys\Services;
  3. class AddressService
  4. {
  5. /**
  6. * 生成符合BNB Chain规范的地址(模拟实现)
  7. * 规范说明:
  8. * - 以"0x"开头
  9. * - 后接40位小写十六进制字符(0-9, a-f)
  10. * - 总长度42字符
  11. *
  12. * @return string 符合规范的BNB Chain地址
  13. */
  14. public static function generateBnbAddress(): string
  15. {
  16. return '0x' . bin2hex(random_bytes(20)); // 20字节随机数生成40位十六进制
  17. }
  18. }