web3dart
3.0.3, released 5 months ago by pwa.ir
A Dart library to connect to Ethereum clients and interact with smart contracts.
WASM-ready
What it does
Allows Flutter and Dart apps to connect to Ethereum and Celo nodes, send signed transactions, manage credentials, and interact with smart contracts. It also includes code generation based on smart contract ABIs.
AI-written summary of version 3.0.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to build a decentralized application (dApp) in Dart or Flutter.
- You want to sign transactions and interact with smart contract ABIs.
- You need Celo or Ethereum network integration.
Skip it when
- You are building a traditional centralized backend application without blockchain integration.
- You only require a simple wallet UI without direct node interactions.
Strengths
- Supports Celo fee currencies and Ethereum transactions.
- Provides smart contract ABI code generation using build_runner.
- Supports raw private keys, version 3 wallet files, and browser providers.
Weaknesses
- Relies on an external RPC client or node to send transactions.
- Not all advanced or rare Solidity types may be fully encoded.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 12
Connects to an RPC endpoint (like Infura or Geth). For smart contract code generation, add web3dart_builders and build_runner to dev_dependencies.
import 'package:http/http.dart';
import 'package:web3dart/web3dart.dart';
var apiUrl = "http://localhost:7545";
var httpClient = Client();
var ethClient = Web3Client(apiUrl, httpClient);
var credentials = EthPrivateKey.fromHex("0x...");
var address = credentials.address;
EtherAmount balance = await ethClient.getBalance(address);
print(balance.getValueInUnit(EtherUnit.ether));Alternatives
Packages that do the same job and could replace web3dart.
Works with
Packages commonly used together with web3dart: ones it builds on, ones built on it, and its own family.
- uuidweb3dart depends on itGenerates and parses RFC‑4122/9562 UUIDs (v1‑v8) for Dart.
- typed_dataweb3dart depends on itUtility functions and classes for easier work with dart:typed_data lists.
- convertweb3dart depends on itEncoders and decoders for converting between different data representations.
- stream_channelweb3dart depends on itAn abstraction for two-way communication channels based on the Dart Stream class.
- stream_transformweb3dart depends on itExtension methods adding common stream transform operators
- pointycastleweb3dart depends on itA Dart library providing a wide range of cryptographic algorithms and primitives.
- walletweb3dart depends on itCrypto wallet package for Bitcoin, Ethereum and Tron written in pure Dart.
- eip55web3dart depends on itUtility to convert Web3 and Ethereum addresses to checksum format (EIP55).