erc20
2.0.0, released 2 years ago by an unverified publisher
Interface for interacting with ERC20 tokens on Ethereum.
WASM-readyUnverified publisher
What it does
Provides methods to query token metadata, balances, allowances, and to send transfer and approval transactions. It also exposes streams for approval and transfer events.
AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to read or modify ERC20 token balances in a Flutter or Dart app.
- You want to listen to token transfer or approval events in real time.
- You are building a wallet or dApp that interacts with standard ERC20 contracts.
Skip it when
- You need support for non‑ERC20 token standards or advanced features like gas estimation or batch calls.
- You require a full wallet implementation with key management and signing.
- You are targeting a platform that does not support the web3dart dependency.
Strengths
- Simple, well‑documented API matching the EIP‑20 spec.
- No code generation required, easy to use in any Dart project.
- Supports event streams for real‑time updates.
Weaknesses
- Relies on web3dart, which may have its own limitations.
- No built‑in caching or retry logic for network calls.
- Limited to ERC20; no support for ERC721 or other token types.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
Add `erc20: any` to pubspec, import `package:erc20/erc20.dart`, and provide a Web3Client instance.
```dart
import 'package:erc20/erc20.dart';
final client = Web3Client('https://mainnet.infura.io/v3/<YOUR_INFURA_ID>', Client());
final token = ERC20(
address: EthereumAddress.fromHex('0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce'),
client: client,
);
final balance = await token.balanceOf(myAddress);
print('Balance: $balance');
```Works with
Packages commonly used together with erc20: ones it builds on, ones built on it, and its own family.