패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.3.8

fuse_wallet_sdk

Fuse Wallet SDK에 이제 Dart 구현이 제공되어 모바일 앱에 블록체인 기술을 통합하는 것이 더욱 쉬워졌습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
383
좋아요
9
Pub 점수
125

패키지 설치

flutter pub add fuse_wallet_sdk

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Fuse Wallet SDK는 모바일 및 데스크톱 애플리케이션에 블록체인 기능을 통합하기 위한 Dart 구현을 제공합니다. Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼에서 원활한 지갑 관리, 거래 처리 및 블록체인 상호작용을 가능하게 합니다. Web3 애플리케이션을 개발하는 개발자를 위해 설계되었으며, 안전하고 사용하기 쉬운 API를 통해 사용자가 블록체인 생태계에 쉽게 접근할 수 있도록 간소화합니다. SDK는 Fuse 네트워크와의 상호 운용성을 지원하며, 네이티브 블록체인 기능으로 앱의 기능을 강화합니다.

사용 사례

  • Flutter 앱에 블록체인 지갑 통합하기
  • Fuse 네트워크에서 사용자 계정 생성 활성화
  • 토큰 전송 및 거래를 촉진하는 것
  • 분산형 애플리케이션(dApp) 인증 지원
  • 크로스플랫폼 웹3 경험 구축

주요 기능

  • 크로스 플랫폼 호환성
  • 안전한 월렛 관리
  • 네이티브 Dart 통합
  • Fuse 네트워크 지원
  • Flutter Pub를 통한 간편한 설정

적합한 대상

  • Flutter 개발자가 dApps 구축 중
  • 웹3 스타트업
  • 블록체인 기반 모바일 애플리케이션
  • 암호화 지갑 통합
  • 다중 플랫폼 블록체인 프로젝트

고려 사항

  • 블록체인 기본 지식이 필요합니다
  • Fuse 네트워크 가용성에 따라 다릅니다
  • 추가 보안 감사가 필요할 수 있습니다
  • Fuse 생태계에만 제한됨
  • 비밀 키에 대한 적절한 처리가 필요합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

MIT License pub version

Introduction

The Fuse Wallet SDK is a set of tools for creating, managing, and engaging with Fuse Wallet SDK in client applications. Fuse Wallet SDK lets users create smart contract wallets(Based on ERC-4337) associated with each user's Externally Owned Account (EOA) that provide added security compared to traditional EOAs with a single private key. With Fuse Wallet SDK, users can deposit funds that no one else can control and withdraw at any time.

Benefits of using Fuse Wallet SDK

Using Fuse Wallet SDK provides several benefits, including:

  • Enhanced security: Fuse Wallet SDK are non-custodial accounts that allow users to deposit funds that no one else can control and withdraw at any time. Each Fuse Smart Wallet is a smart contract associated with the user's EOA and can only be controlled by that user.
  • Enhanced UX: Fuse Wallet SDK support gasless transactions, improving the user experience and making it more seamless to interact with the blockchain.
  • Better developer experience: The Fuse Wallet SDK abstracts away the complexities of web3 development, such as cryptography, wallet management, and smart contract interactions, making it easier for developers to build blockchain-based applications
Purpose of the SDK

The SDK is designed to make it easy for developers to create, manage, and engage with Fuse Wallet SDK in their applications. The SDK provides pre-built functions and utilities, allowing developers to interact with Fuse Wallet SDK securely and efficiently.

Migration guides

Instantiation

import 'package:fuse_wallet_sdk/fuse_wallet_sdk.dart';
final apiKey = 'YOUR_PUBLIC_API_KEY';
final privateKey = EthPrivateKey.fromHex('YOUR_PRIVATE_KEY');
final fuseSDK = await FuseSDK.init(apiKey, privateKey);
Examples
Get Address
Send transactions
Approve token
Retry mechanism
Send batch transactions
Staking
Unstake
Trading

Features

The Fuse Wallet SDK provides several features that allow developers to create, manage, and engage with Fuse Wallet SDK in their applications. Some of the key features include:

Get Address

Gets the address of the wallet created.

print('Smart contract wallet address: ${fuseSDK.wallet.getSender()}');
Send transactions

Send transactions, including ERC20 and NFT transfers and interaction with arbitrary smart contracts.

final res = await fuseSDK.transferToken(
    EthereumAddress.fromHex('TOKEN_ADDRESS'), // For sending native token, use '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'
    EthereumAddress.fromHex('RECIPIENT_ADDRESS'),
    BigInt.parse('AMOUNT_IN_WEI'),
);
print('UserOpHash: ${res.userOpHash}');
print('Waiting for transaction...');
final ev = await res.wait();
Send batch transactions

The process of grouping multiple transactions into a single batch to be processed together. This is often done to optimize processing time and reduce transaction fees.

final res = await fuseSDK.executeBatch(
  [
    // Transfer Native Token call
    Call(
      to: EthereumAddress.fromHex('TARGET_ADDRESS'),
      value: BigInt.parse('AMOUNT_IN_WEI'),
      data: Uint8List(0),
    ),
    // Transfer ERC-20 Token call
    Call(
      to: EthereumAddress.fromHex('TOKEN_ADDRESS'),
      value: BigInt.zero,
      data: ContractsUtils.encodeERC20TransferCall(
        EthereumAddress.fromHex('TOKEN_ADDRESS'),
        EthereumAddress.fromHex('RECIPIENT_ADDRESS'),
        BigInt.parse('AMOUNT_IN_WEI'),
      ),
    ),
  ],
);

print('UserOpHash: ${res.userOpHash}');

print('Waiting for transaction...');
final ev = await res.wait();
print('Transaction hash: ${ev?.transactionHash}');
Sponsored Transactions

Sponsored transactions are the ability to pay for another user’s transaction fees. To do this, the Fuse operator must enable the sponsored feature in his project and deposit some funds into the paymaster contract. The SDK provides a middleware to check if the project is sponsored and the amount of funds available for sponsoring.

To use this feature, you must first initialize the SDK with the withPaymaster parameter set to true.

import 'package:fuse_wallet_sdk/fuse_wallet_sdk.dart';
final apiKey = 'YOUR_PUBLIC_API_KEY';
final privateKey = EthPrivateKey.fromHex('YOUR_PRIVATE_KEY');
final fuseSDK = await FuseSDK.init(apiKey, privateKey, withPaymaster: true);
Staking

The SDK provides a module for staking. This module allows users to stake their tokens and earn rewards.

Currently, the SDK supports staking for the following tokens: Native Fuse & VoltToken


final stakingOptions = await fuseSDK.stakingModule.getStakingOptions();

final res = await fuseSDK.stakeToken(
  StakeRequestBody(
    accountAddress: fuseSDK.wallet.getSender(),
    tokenAmount: '0.1',
    tokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
  ),
);
Trading

Smart Wallet can buy and sell popular cryptocurrencies like Bitcoin and Ethereum, Stable-coins. Behind the scenes, it uses voltage.finance decentralized exchange.

final nativeTokenAddress = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
final usdcTokenAddress = '0x28C3d1cD466Ba22f6cae51b1a4692a831696391A';

final res = await fuseSDK.swapTokens(
  TradeRequest(
    inputToken: nativeTokenAddress,
    outputToken: usdcTokenAddress,
    inputAmount: BigInt.parse('100000000000000000'),
    exactIn: true,
  ),
);

Troubleshooting

  1. User op cannot be replaced: fee too low.

    If you're getting the User op cannot be replaced: fee too low error, it means that the gas price you set is too low. You can increase the gas price by setting the TxOptions parameter when sending a transaction. To replace an user operation, a new user operation must have at least 10% higher maxPriorityFeePerGas and 10% higher maxPriorityFeePerGas than the one in the user operation mempool.

To replace the user operation, the new gas price must be at least 10% higher.

final res = await fuseSDK.transferToken(
    EthereumAddress.fromHex('TOKEN_ADDRESS'),
    EthereumAddress.fromHex('RECIPIENT_ADDRESS'),
    BigInt.parse('AMOUNT_IN_WEI'),
    FuseSDK.defaultTxOptions.copyWith(
      withRetry: true,
      feeIncrementPercentage: 11,
    ),
);
print('UserOpHash: ${res.userOpHash}');
print('Waiting for transaction...');
final ev = await res.wait();

Limitations

The Fuse Wallet SDK works only on the Fuse & Fuse Sparknet networks, an EVM based chain L1 blockchain. Support for other blockchains is planned for the future.

If you have any questions or feedback, please get in touch with our support team at support@fuse.io.

Migrating to v0.2

Introduction

Welcome to the updated version of the fuse_wallet_sdk. Our primary objective for this migration is to seamlessly align our services with the evolving landscape of EVM-based chains. We are thrilled to introduce the incorporation of the new standard, EIP 4337, commonly known as "Account Abstraction". This latest protocol promises to enhance security, provide more consistent developer experiences, and offer improved user interactions in Ethereum-based environments.

Major Changes at a Glance:

  • Seamless Smart Wallet Creation: Gone are the days where we required an API request to the Fuse APIs to craft a smart wallet. With the renewed fuse_wallet_sdk, initiation not only sets the SDK in motion but also seamlessly creates a smart wallet for the given owner. This elevates user experience, reduces developer friction, and augments transactional efficiency.

As we navigate through the details of this migration, we hope to provide you with a clear roadmap, making the transition as straightforward as possible. Embracing the future of Ethereum-based chains has never been this effortless.

Prerequisites

Before embarking on this migration journey with the new fuse_wallet_sdk, the process is made delightfully simple for our users. However, there's a minimal requirement you should be aware of:

  • API Key: The only prerequisite to utilize the updated SDK is to have a valid API key. If you haven't create one yet or need a new one, don't fret! Simply head over to our Developer's Console at https://console.fuse.io/build/ and follow the straightforward steps to obtain your key.

With your API key in hand, you're all set to integrate and experience the enhanced capabilities of the fuse_wallet_sdk.

Detailed Migration Steps

Initialization and Smart Wallet Creation

  1. Locate the Old Initialization: Start by finding your old SDK initialization in your code. This is typically where you have the FuseWalletSDK instantiation.

  2. Remove Wallet Creation Steps: In the old SDK, there were multiple steps involved in creating a smart wallet, including authenticating the credentials, creating a wallet, and handling the creation events. These steps are now greatly simplified in the new SDK.

    Identify and remove the following sections from your old SDK code:

    • The authentication step: await fuseWalletSDK.authenticate(credentials);
    • The wallet creation step: await fuseWalletSDK.createWallet();
    • The entire onSmartWalletEvent function and its associated event listening code.
  3. Update SDK Initialization: Replace the old initialization:

    final FuseWalletSDK fuseWalletSDK = FuseWalletSDK(publicApiKey);
    

    with the new one:

    final fuseSDK = await FuseSDK.init(publicApiKey, credentials);
    
  4. Access the Smart Contract Wallet Address: In the new SDK, you can obtain the smart contract wallet address directly after initialization. Replace the older method:

    print('Smart contract wallet address: ${fuseWalletSDK.smartWallet.smartWalletAddress}');
    

    with the simplified new version:

    print('Smart contract wallet address: ${fuseSDK.wallet.getSender()}');
    
    

By following the steps above, developers can smoothly transition to the new SDK and take advantage of the more streamlined and simplified process provided by the update. It’s worth noting that the migration not only reduces the lines of code but also enhances clarity and reduces complexity, resulting in a more efficient and cleaner integration process.

In summary, the new SDK code provides a more structured, modular, and extensive set of functions to interact with FuseBox. It allows for a broader range of operations, from basic token transfers to more complex operations like staking and swapping tokens. The design considerations (like separating modules) make the SDK more maintainable and scalable.

카테고리

의존성

의존성 목록 14 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.