搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.0-beta.15

flutterchain

用於與區塊鏈系統通訊的多鏈庫。基於 WalletCore。

AndroidiOSWeb
近 30 天下載
192
喜歡數
23
Pub 分數
110

安裝套件

flutter pub add flutterchain

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Flutterchain 是一個多鏈庫,可讓 Flutter 應用程式與區塊鏈系統實現無縫通訊。基於 WalletCore 建構,支援跨多個區塊鏈的互操作性,為開發者提供統一介面,用於錢包管理、交易簽署及區塊鏈互動。此庫針對 Android、iOS 和 Web 平台進行優化,非常適合跨平台 Web3 應用。具備強大的安全功能與對區塊鏈協議的底層存取,Flutterchain 簡化了將加密功能整合至行動與 Web 應用的過程。

適用情境

  • 建構跨平台加密錢包
  • 在Flutter應用中啟用區塊鏈交易
  • 整合多鏈支援
  • 開發去中心化金融(DeFi)應用
  • 創建NFT市場
  • 透過QR或連結實現錢包連接

主要特色

  • 多鏈相容性
  • 基於 WalletCore 的架構
  • 支援 Android、iOS 與 Web
  • 安全交易簽名
  • 底層區塊鏈協定存取
  • 跨平台一致性

適合對象

  • Web3 應用開發者
  • 加密錢包創建者
  • DeFi 平台建構者
  • NFT 應用團隊
  • 區塊鏈整合商

使用建議

  • 需要了解區塊鏈基礎知識
  • 依賴於 WalletCore 的穩定性
  • 可能需要為自定鏈進行額外設定
  • 除了基本用法之外,文件內容有限
  • 不適合非Web3專案

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

About FlutterChain

FlutterChain is a library that provides developers with a simple API to communicate with different blockchains. It allows developers to easily integrate popular cryptocurrencies into their web 3.0 projects without needing to have an in-depth understanding of the underlying blockchain technology. With FlutterChain, developers can easily interact with smart contracts, send transfers, and perform various transaction types. It's an easy-to-use and flexible solution for developers looking to build blockchain-based applications.

Installing

  1. Add This code to the index.html For Web project
<head>
  <!-- other head elements -->
  <script type="application/javascript" src="flutter.js" defer></script>
  <script type="application/javascript" src="/assets/packages/flutter_inappwebview_web/assets/web/web_support.js" defer></script>
  <script type="module" src="/assets/packages/flutterchain/assets/crypto-lib/dist/bundle.js"></script>
  <script type="application/javascript" src="/assets/packages/flutterchain/assets/crypto-lib/dist/dop_bundle.js"></script>
  <link rel="modulepreload" crossorigin href="/assets/packages/flutterchain/assets/crypto-lib/dist/bundle2.js">


</head>

<body>
  <script>
    window.addEventListener("load", async function (ev) {
      {{flutter_js}}
      {{flutter_build_config}}
      
      _flutter.loader.load({
        serviceWorkerSettings: {
          serviceWorkerVersion: {{flutter_service_worker_version}},
        },
      });
    });
  </script>
</body>
  1. Set Android: minSdkVersion >= 19, compileSdk >= 34, AGP version >= 7.3.0 in the android/app/build.gradle file and add to the AndroidManifest.xml usesCleartextTraffic param and Internet permission:
  <manifest> ...
    <application> ...
      android:usesCleartextTraffic="true"
    </application>
    <uses-permission android:name="android.permission.INTERNET"/>
  </manifest>
  1. Initialize the flutterchain library after WidgetsFlutterBinding.ensureInitialized() in the main function.
void main() {
  WidgetsFlutterBinding.ensureInitialized();
  initFlutterChainLib();
  ...
  runApp(MyApp());
}

How to use

This library provides interfaces to interact with various blockchains. You can achieve this by using an implementation of BlockChainService or BlockchainServiceWithSmartContractCallSupport for your selected blockchain. For example:

  final service = NearBlockChainService.defaultInstance(); // NearBlockChainService implements BlockchainServiceWithSmartContractCallSupport
  final amount = await service
      .getWalletBalance(NearAccountInfoRequest(accountId: "test.near"));

The library also includes its own wallet controller (FlutterChainLibrary), allowing you to create wallets for different blockchains simultaneously, securely store them and manage, and execute standardized operations like transferring coins or interacting with smart contracts (where supported by the blockchain). It also provides access to the blockchain specific methods interface. For example:

  final flutterChainLibrary = FlutterChainLibrary.defaultInstance();

  final wallet = await flutterChainLibrary.createWalletWithGeneratedMnemonic(
      walletName: "my wallet");

  final derivationPathData =
      wallet.blockchainsData?[BlockChains.near]?.first.derivationPath;

  // call from FlutterChainLibrary

  final response = await flutterChainLibrary.sendTransferNativeCoin(
    blockchainType: BlockChains.near,
    derivationPathData: derivationPathData!,
    walletId: wallet.id,
    toAddress: "someAddress",
    transferAmount: "1000",
  );

  //call from blockchainService interface

  final NearBlockChainService nearBlockChainService = flutterChainLibrary
      .blockchainService
      .blockchainServices[BlockChains.near] as NearBlockChainService;

  // final NearBlockChainData blockChainData = wallet.blockchainsData![BlockChains.near]?.first as NearBlockChainData;
  final NearBlockChainData blockChainData = await nearBlockChainService
      .getBlockChainData(mnemonic: wallet.mnemonic) as NearBlockChainData;

  final response2 = await nearBlockChainService.sendTransferNativeCoin(
    NearTransferRequest(
      publicKey: blockChainData.publicKey,
      privateKey: blockChainData.privateKey,
      toAddress: "someAddress",
      transferAmount: "1000",
    ),
  );

  await flutterChainLibrary.deleteAllWallets();

Important Notes and Tips

FlutterChainLibrary and BlockchainServiceWithSmartContractCallSupport/BlockchainService implementations aren't singletons. Each time a new instance is created, a jsVMService (a service that handles blockchain operations behind the scenes) is also instantiated. For optimal performance, it is recommended to reuse the same instance of the blockchain service throughout your app. This can be easily managed by using dependency injection libraries like flutter_modular or get_it.

For more detailed information, refer to the documentation and tests. You'll find guidance on how to use FlutterChainLibrary or various BlockchainServices. Additionally, you can explore different use cases through the examples provided:

You can see the architecture in the draw.io file flutterchain_arch.drawio inside the library.

Running Examples

Instructions for running the included examples.

  1. Navigate to the example directory: cd example
  2. Run flutter run to launch the example app on your preferred device.
  3. Explore the example app to see how to use the library in your own project.

Contributing

Instructions for contributing to this library:

  1. Fork this repository
  2. Create a new branch: git checkout -b my-new-branch
  3. Make changes and commit them: git commit -m "My message"
  4. Push to the remote branch: git push origin my-new-branch
  5. Create a pull request

List any dependencies or prerequisites needed before getting started with editing this library:

  • Node JS
  • Flutter
  • Installed Android Studio and Android SDK (For Android dev)
  • Installed Xcode (For IOS, Mac OS dev)

Instructions for building the library from source code:

  1. Clone this repository: git clone https://github.com/vlmoon99/flutterchain
  2. Navigate to the project root directory: cd flutterchain
  3. Run bash build.sh for building flutterchain lib

所屬分類

依賴

依賴清單 10 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。