Files
hash-wallet/cw_evm
David AdegokeandGitHub 308de0389d CW-1368: Add Binance Smart Chain (#2836)
* feat: Add Binance Smart Chain support to wallet types and EVM chain registry

* feat: Add BSC node list and support in wallet type and chain ID mappings

* feat: Add BSC default tokens and update evm utility functions

* feat: Integrate BSC support in node settings and management

* feat: Add BSC support to config scripts and wallet type generation

* feat: Add BSC support to EVM chain ID and switcher

* feat: Extend BSC support in wallet utilities and chain type checks

* feat: Add BSC support to different wallet functions

* feat: Add BSCURI class and implement for uri handling

* feat: Update Android and iOS configurations to support BSC URL schemes

* feat: Add BSC support to different functionalities and settings

* refactor: Update wallet type name from'Binance Smart Chain' to BNB Smart Chain

* feat: Add switcher icon and updates token utils

* Review fixes

* More changes to BSC name, wallet listing and images

* Add more default tokens
2026-02-05 13:48:26 +01:00
..
2024-01-30 20:01:48 +02:00
2024-01-30 20:01:48 +02:00
2024-01-30 20:01:48 +02:00

cw_evm

Shared EVM-chain wallet foundation for Cake Wallet. Provides common client/wallet abstractions used by cw_ethereum, cw_polygon, and other EVM chains.

What it provides

  • EVMChainClient (Web3 + HTTP):
    • Connect to RPC (supports NowNodes short hosts with API key).
    • Read balance, gas price/base fee, estimate gas, send raw tx, watch tx.
    • Sign native and ERC‑20 transactions; build approval calldata.
    • Fetch ERC‑20 metadata (via Moralis) and balances.
  • EVMChainWallet:
    • Derive keys from BIP‑39 or use private key / Ledger (EvmLedgerCredentials).
    • EIP‑1559 fee calculation with priority presets; Polygon-specific tuning.
    • ERC‑20 token box per wallet; add/remove tokens and maintain balances.
    • Transaction history assembly (external/internal + token transfers).
    • Message sign/verify helpers.
  • EVMChainWalletService: common create/open/restore/rename lifecycle.

Secrets

Create cw_evm/lib/.secrets.g.dart (do not commit):

const String nowNodesApiKey = '...';      // used for eth.nownodes.io / matic.nownodes.io
const String etherScanApiKey = '...';     // Etherscan v2 API key (incl. Polygon)
const String moralisApiKey = '...';       // optional, ERC-20 metadata lookup

Extending to a new EVM chain

Create a client and wallet subclass:

class MyChainClient extends EVMChainClient {
  @override
  int get chainId => 8453; // example
  @override
  Uint8List prepareSignedTransactionForSending(Uint8List tx) => tx;
  @override
  Future<List<EVMChainTransactionModel>> fetchTransactions(String address, {String? contractAddress}) async { /* ... */ }
  @override
  Future<List<EVMChainTransactionModel>> fetchInternalTransactions(String address) async { /* ... */ }
}

Then wire into a WalletService similar to EthereumWalletService/PolygonWalletService.

Additional information

  • Uses web3dart under the hood and integrates with Cake Wallet’s cw_core types.
  • See lib/ for the reference implementation details.