eth_url_parser 0.1.0 copy "eth_url_parser: ^0.1.0" to clipboard
eth_url_parser: ^0.1.0 copied to clipboard

A Dart library for parsing and building Ethereum URLs according to ERC-681 and ERC-831. Supports ERC-20 transfers, ENS names, and chain IDs.

example/eth_url_parser_example.dart

import 'package:eth_url_parser/eth_url_parser.dart';

void main() {
  // Parse a simple Ethereum URL
  final request = EthUrlParser.parse(
    'ethereum:0x1234DEADBEEF5678ABCD1234DEADBEEF5678ABCD',
  );
  print('Target address: ${request.targetAddress}');
  // Target address: 0x1234DEADBEEF5678ABCD1234DEADBEEF5678ABCD

  // Parse a URL with parameters
  final transferRequest = EthUrlParser.parse(
    'ethereum:0x1234DEADBEEF5678ABCD1234DEADBEEF5678ABCD/transfer?address=0xABCD&uint256=1',
  );
  print('Function: ${transferRequest.functionName}');
  // Function: transfer
  print('Parameters: ${transferRequest.parameters}');
  // Parameters: {address: 0xABCD, uint256: 1}

  // Build an Ethereum URL from a TransactionRequest
  final uri = EthUrlParser.build(
    TransactionRequest(
      targetAddress: '0x1234DEADBEEF5678ABCD1234DEADBEEF5678ABCD',
      functionName: 'transfer',
      chainId: 1,
      parameters: {
        'address': '0xABCD',
        'uint256': '1',
      },
    ),
  );
  print('Built URI: $uri');
  // Built URI: ethereum:0x1234DEADBEEF5678ABCD1234DEADBEEF5678ABCD@1/transfer?address=0xABCD&uint256=1
}
2
likes
160
points
131
downloads

Documentation

API reference

Publisher

verified publisherfuse.io

Weekly Downloads

A Dart library for parsing and building Ethereum URLs according to ERC-681 and ERC-831. Supports ERC-20 transfers, ENS names, and chain IDs.

Homepage
Repository (GitHub)
View/report issues

Topics

#ethereum #blockchain #erc-681 #erc-831 #url-parser

License

MIT (license)

More

Packages that depend on eth_url_parser