|
1 | | -<!-- |
2 | | -This README describes the package. If you publish this package to pub.dev, |
3 | | -this README's contents appear on the landing page for your package. |
| 1 | +## cw_ethereum |
4 | 2 |
|
5 | | -For information about how to write a good package README, see the guide for |
6 | | -[writing package pages](https://dart.dev/guides/libraries/writing-package-pages). |
| 3 | +Ethereum wallet module built on `cw_evm`. Supports native ETH and ERC‑20 tokens, with history fetched via Etherscan. |
7 | 4 |
|
8 | | -For general information about developing packages, see the Dart guide for |
9 | | -[creating packages](https://dart.dev/guides/libraries/create-library-packages) |
10 | | -and the Flutter guide for |
11 | | -[developing packages and plugins](https://flutter.dev/developing-packages). |
12 | | ---> |
| 5 | +### Features |
13 | 6 |
|
14 | | -TODO: Put a short description of the package here that helps potential users |
15 | | -know whether this package might be useful for them. |
| 7 | +- EVM client specialized for Ethereum mainnet (chainId 1). |
| 8 | +- Default ERC‑20 token list and wallet‑scoped token storage/migration. |
| 9 | +- History via Etherscan v2 API (external, internal, and token transfers). |
| 10 | +- EIP‑1559 fee support; gas estimation per transaction intent. |
| 11 | +- Create/sign native and ERC‑20 transfers; approvals; broadcast. |
| 12 | +- Manage ERC‑20 tokens and balances; metadata lookup when needed. |
| 13 | +- Message signing and verification. |
| 14 | +- Node health checks for native and USDC token balance. |
16 | 15 |
|
17 | | -## Features |
| 16 | +### Getting started |
18 | 17 |
|
19 | | -TODO: List what your package can do. Maybe include images, gifs, or videos. |
| 18 | +Add shared EVM secrets (see `cw_evm` README): |
20 | 19 |
|
21 | | -## Getting started |
| 20 | +```dart |
| 21 | +// cw_evm/lib/.secrets.g.dart (DO NOT COMMIT) |
| 22 | +const String etherScanApiKey = 'YOUR_ETHERSCAN_KEY'; |
| 23 | +const String nowNodesApiKey = 'YOUR_NOWNODES_KEY'; // if using eth.nownodes.io |
| 24 | +const String moralisApiKey = 'YOUR_MORALIS_KEY'; // optional |
| 25 | +``` |
| 26 | + |
| 27 | +Connect and sync: |
22 | 28 |
|
23 | | -TODO: List prerequisites and provide or point to information on how to |
24 | | -start using the package. |
| 29 | +```dart |
| 30 | +final service = EthereumWalletService(walletInfoBox, true, client: EthereumClient()); |
| 31 | +final wallet = await service.create(EVMChainNewWalletCredentials(name: 'My ETH', password: 'secret')); |
| 32 | +await wallet.connectToNode(node: Node(uriRaw: 'eth.llamarpc.com', isSSL: true)); |
| 33 | +await wallet.startSync(); |
| 34 | +``` |
25 | 35 |
|
26 | | -## Usage |
| 36 | +### Usage |
| 37 | + |
| 38 | +Send ETH: |
| 39 | + |
| 40 | +```dart |
| 41 | +final pending = await wallet.createTransaction( |
| 42 | + EVMChainTransactionCredentials.single( |
| 43 | + address: '0x...', |
| 44 | + cryptoAmount: '0.05', |
| 45 | + currency: CryptoCurrency.eth, |
| 46 | + priority: EVMChainTransactionPriority.medium, |
| 47 | + ), |
| 48 | +); |
| 49 | +final hash = await pending.commit(); |
| 50 | +``` |
27 | 51 |
|
28 | | -TODO: Include short and useful examples for package users. Add longer examples |
29 | | -to `/example` folder. |
| 52 | +Add an ERC‑20 token and refresh balance: |
30 | 53 |
|
31 | 54 | ```dart |
32 | | -const like = 'sample'; |
| 55 | +final token = await wallet.getErc20Token('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', 'eth'); // USDC |
| 56 | +if (token != null) { |
| 57 | + await wallet.addErc20Token(token); |
| 58 | +} |
33 | 59 | ``` |
34 | 60 |
|
35 | | -## Additional information |
| 61 | +### Additional information |
36 | 62 |
|
37 | | -TODO: Tell users more about the package: where to find more information, how to |
38 | | -contribute to the package, how to file issues, what response they can expect |
39 | | -from the package authors, and more. |
| 63 | +- Toggle Etherscan usage via shared preferences key `use_etherscan`. |
| 64 | +- See `lib/` for APIs: `EthereumClient`, `EthereumWallet`, `EthereumWalletService`. |
0 commit comments