TestSuite

WalletKit-Dart

WalletKit-Dart provides features for interacting with Bitcoin/Ethereum/Tron/ZENIQ/ZENIQ Smartchain/Polygon/Binance Smartchain/Litecoin/Bitcoin Cash/Eurocoin as well as several layer 2 chains. If needed, it is easy to expand WalletKit-Dart with other chains.

See the Uniswap WebOn or the Unit-tests for a practical example how to use WalletKit-Dart.

See the api-docs for a list of individual functions.

Features

  • Sending transactions, including legacy/SegWit/P2SH/EVM
  • Fetching transactions and balances, including xPub/zPub/ERC20
  • Advanced parsing for making smart contract calls readable for humans (EVM)
  • Deriving addresses from mnemonics (HD-Wallet)
  • Performance by default: Immutable data will be cached in-memory
  • A large suite of Unit-tests

Why WalletKit-Dart?

WalletKit-Dart has been inspired by the WalletKit-C from blockset-corp and by bitcoin_flutter from the dart-bitcoin-project.

The WalletKit-C was one of the first WalletKits that combined UTXO-chains and EVM-chains under a unified class hierarchy. However, the WalletKit-C was plagued by race conditions and memory corruptions. Also, the WalletKit-C had an "object oriented architecture" that was poorly supported by the C-language.

bitcoin_flutter worked well, but bitcoin_flutter did not support modern null-safe Dart and it was difficult to expand for multiple chains.

WalletKit-Dart has been developed to solve all those problems. WalletKit-Dart works with modern Dart-versions and is easy to expand for multiple chains.

How to integrate

First, add this package as a Git-submodule by using Git-commands:

git submodule add https://github.com/nomo-app/walletkit-dart.git packages/walletkit-dart

Next, expand your pubspec.yaml accordingly:

dependencies:
    walletkit_dart:
        path: packages/walletkit-dart

Afterwards, clone submodules with:

git submodule update --init --recursive

The --recursive is important because WalletKit-Dart depends on other grandchild-submodules.

Architecture

WalletKit-Dart is built for both UTXO-chains and EVM-chains. WalletKit-Dart provides a class hierarchy where both UTXOTransaction and EVMTransaction inherit from a GenericTransaction base class.

Here is a quick summary if you do not yet understand the difference between UTXO and EVM:

UTXO-based chains and EVM-based chains are two different architectures for blockchain systems.
UTXO (Unspent Transaction Output) is a concept used in Bitcoin and some other cryptocurrencies.
In this architecture, each transaction spends one or more previously unspent outputs and creates new outputs.
The sum of the inputs must be equal to or greater than the sum of the outputs.
EVM (Ethereum Virtual Machine) is used in Ethereum and some other blockchain platforms that support smart contracts.
In this architecture, each transaction is executed in the EVM as a smart contract, which can modify the state of the blockchain and create new contracts.
The state is stored in a database, rather than as a set of unspent outputs.
In summary, UTXO-based chains focus on tracking ownership of tokens, while EVM-based chains focus on executing arbitrary code in the form of smart contracts.

API Philosophy

WalletKit-Dart provides a stateless API. Neither does it store seed phrases, nor does it store transactions. It is the users responsibility to store any needed data.

By design, WalletKit-Dart does not have any persistent databases. Instead, WalletKit-Dart only has a few in-memory-caches to improve performance of repeated calls. This design helps to simplify the API.

Moreover, WalletKit-Dart provides different APIs for UTXO-chains and EVM-chains. Although every transaction inherits from a generic base transaction, we want to provide APIs that are specifically targeted for the architecture of a chain. In that sense, we deviate from a traditional object oriented approach.

In other words, while we aim to reuse code between chains, we do not want to create broken abstraction layers by abstracting too much complexity away.

Backend APIs

Depending on the chain, WalletKit-Dart depends on multiple backend APIs. For UTXO-chains, WalletKit-Dart depends on the ElectrumX Protocol.

For EVM-chains, WalletKit-Dart depends on several JSON-RPC-providers as well as etherscan-styled APIs.

The following Unit-tests show how to use WalletKit-Dart

Get Token Info for a ERC20 Token

Fetch EVM Transaction from Explorer

Walletkit Json RPC Interface

Fetch Bitcoin Transactions

Get best health endpoints utxo

EPubKey Derivation

Fetch UTXO Transaction

Parse MessageHex into EVM Transaction

Decode datafield from EVM Transaction

Address Validation

Estimate Fee

Send EVM Transaction

Fetch Peers from ElectrumX

Broadcast UTXO Transaction

protoc -I. --dart_out=grpc:/home/thomas/src/walletkit-dart/lib/src/crypto/tron/rpc core/Tron.proto core/Discover.proto core/TronInventoryItems.proto core/contract/common.proto core/contract/account_contract.proto core/contract/asset_issue_contract.proto core/contract/balance_contract.proto core/contract/exchange_contract.proto core/contract/market_contract.proto core/contract/proposal_contract.proto core/contract/shield_contract.proto core/contract/smart_contract.proto core/contract/storage_contract.proto core/contract/witness_contract.proto api/api.proto

Libraries

src/common/json_rpc
src/common/types
src/crypto/evm/entities/abi/ens/ens_registry_contract
src/crypto/evm/entities/abi/ens/ens_resolver_contract
src/crypto/evm/entities/abi/erc20_contract
src/crypto/evm/entities/abi/erc721_contract
src/crypto/evm/entities/abi/uniswap_v2/uniswap_v2_factory
src/crypto/evm/entities/abi/uniswap_v2/uniswap_v2_pair
src/crypto/evm/entities/abi/uniswap_v2/uniswap_v2_router
src/crypto/evm/entities/contract/contract_abi
src/crypto/evm/entities/contract/contract_function
src/crypto/evm/entities/contract/contract_function_param
src/crypto/evm/entities/contract/internal_contract
src/crypto/evm/entities/contract/parameter_type/function_parameter_type
src/crypto/evm/entities/raw_transaction/raw_evm_transaction
src/crypto/evm/entities/raw_transaction/signature
src/crypto/evm/entities/raw_transaction/transaction_type
src/crypto/evm/entities/transactions/etherscan_transaction
src/crypto/evm/evm
src/crypto/evm/repositories/etherscan/etherscan_explorer
src/crypto/evm/repositories/rpc/evm_client
src/crypto/evm/repositories/rpc/evm_rpc_interface
src/crypto/evm/utils/rlp
src/crypto/evm/utils/signing
src/crypto/evm/utils/utils
src/crypto/network_type
src/crypto/tron/entities/tron_address
src/crypto/tron/entities/tron_transaction
src/crypto/tron/repositories/tron_http_repository
src/crypto/tron/repositories/tronscan_repository
src/crypto/tron/tron
src/crypto/utxo/entities/raw_transaction/raw_transaction
src/crypto/utxo/utils/derivation
src/crypto/utxo/utils/ecurve
src/crypto/utxo/utils/eurocoin_signing
src/crypto/utxo/utils/proof_of_payment
src/crypto/utxo/utils/send
src/crypto/utxo/utils/utxo_receive_addresses
src/crypto/utxo/utxo
src/crypto/utxo/utxo_analyzer
src/crypto/wallet_utils
src/domain/constants
src/domain/entities/address_type
src/domain/entities/amount
src/domain/entities/coin_entity
src/domain/entities/fee
src/domain/entities/generic_transaction
src/domain/entities/hd_wallet_type
src/domain/entities/node
src/domain/entities/token_info
src/domain/entities/transfer_intent
src/domain/entities/tx_gasFee_entity
src/domain/extensions
src/domain/predefined_assets
src/utils/address_validation
walletkit_dart