0 purchases
stellar wallet flutter sdk
Stellar Wallet SDK for Flutter #
The Stellar Wallet SDK for Flutter is a library that allows developers to build wallet applications on the Stellar Network faster. It
utilizes Flutter Stellar SDK to communicate with Stellar Horizon and Anchors.
Installation #
From pub.dev #
Add the dependency to your pubspec.yaml file:
dependencies:
stellar_wallet_flutter_sdk: ^0.3.5
stellar_flutter_sdk: ^1.8.7
copied to clipboard
Install it (command line or IDE):
flutter pub get
copied to clipboard
In your source file import the SDK, initialize and use it:
import 'package:stellar_wallet_flutter_sdk/stellar_wallet_flutter_sdk.dart';
Wallet wallet = Wallet.testNet;
Anchor anchor = wallet.anchor(anchorDomain);
AnchorServiceInfo serviceInfo = await anchor.sep24().getServiceInfo();
copied to clipboard
Manual #
Here is a step by step that we recommend:
Clone this repo.
Open the project in your IDE (e.g. Android Studio).
Open the file pubspec.yaml and press Pub get in your IDE.
Go to the project's test directory, run a test from there and you are good to go!
Add it to your app:
In your Flutter app add the local dependency in pubspec.yaml and then run pub get:
dependencies:
flutter:
sdk: flutter
stellar_wallet_flutter_sdk:
path: ../stellar_wallet_flutter_sdk
copied to clipboard
In your source file import the SDK, initialize and use it:
import 'package:stellar_wallet_flutter_sdk/stellar_wallet_flutter_sdk.dart';
Wallet wallet = Wallet.testNet;
Anchor anchor = wallet.anchor(anchorDomain);
AnchorServiceInfo serviceInfo = await anchor.sep24().getServiceInfo();
copied to clipboard
Functionality #
The Wallet SDK provides an easy way to communicate with Anchors. It supports:
SEP-001
SEP-006
SEP-009
SEP-010
SEP-012
SEP-024
SEP-030
SEP-038
Furthermore the wallet SDK provides extra functionality on top of the Flutter Stellar SDK. For interaction with the Stellar Network, the Flutter Wallet SDK covers the basics used in a typical wallet flow.
Getting started #
Working with the SDK #
Let's start with the main class that provides all SDK functionality. It's advised to have a singleton wallet object shared across the application. Creating a wallet with a default configuration connected to Stellar's Testnet is simple:
var wallet = Wallet.testNet;
copied to clipboard
The wallet instance can be further configured. For example, to connect to the public network:
var wallet = Wallet(StellarConfiguration.publicNet);
copied to clipboard
Configuring a custom HTTP client #
The Flutter Wallet SDK uses the standard Client from the http package for all network requests (excluding Horizon, where the Flutter Stellar SDK's HTTP client is used).
Optionally, you can set your own client from http package to be used across the app.
The client can be globally configured:
import 'package:http/http.dart';
// ...
// init and configure your HTTP client
// var myClient = ...
// set as default HTTP client
var appConfig = ApplicationConfiguration(defaultClient: myClient);
var walletCustomClient = Wallet(StellarConfiguration.testNet, applicationConfiguration: appConfig);
copied to clipboard
Some test cases of this SDK use for example MockClient.
Stellar Basics #
The Flutter Wallet SDK provides extra functionality on top of the existing Flutter Stellar SDK. For interaction with the Stellar Network, the Flutter Wallet SDK covers the basics used in a typical wallet flow. For more advanced use cases, the underlying Flutter Stellar SDK should be used instead.
To interact with the Horizon instance configured in the previous steps, simply do:
var stellar = wallet.stellar();
copied to clipboard
This example will create a Stellar class that manages the connection to the Horizon service.
You can read more about working with the Stellar Network in the respective doc section.
Stellar Flutter SDK #
The Flutter Stellar SDK is included as a dependency in
the Flutter Wallet SDK.
It's very simple to use the Flutter Stellar SDK connecting to the same Horizon instance as a Wallet class. To do so, simply call:
var stellar = wallet.stellar();
var server = stellar.server;
var transactions = await server.transactions.forAccount(accountId).execute();
copied to clipboard
But you can also import and use it for example like this:
import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart' as flutter_sdk;
final sdk = flutter_sdk.StellarSDK.TESTNET;
var accountId = "GASYKQXV47TPTB6HKXWZNB6IRVPMTQ6M6B27IM5L2LYMNYBX2O53YJAL";
var transactions = await sdk.transactions.forAccount(accountId).execute();
copied to clipboard
Anchor Basics #
Primary use of the Flutter Wallet SDK is to provide an easy way to connect to anchors via sets of protocols known as SEPs.
Let's look into connecting to the Stellar test anchor:
var anchor = wallet.anchor("https://testanchor.stellar.org");
copied to clipboard
And the most basic interaction of fetching a SEP-001: Stellar Info File:
var info = await anchor.getInfo();
copied to clipboard
The anchor class also supports SEP-010: Stellar Authentication, SEP-024: Hosted Deposit and Withdrawal features, SEP-012: KYC API and SEP-009: Standard KYC Fields.
You can read more about working with Anchors in the respective doc section.
Recovery #
SEP-030 defines the standard way for an individual (e.g., a user or wallet) to regain access to their Stellar account after losing its private key without providing any third party control of the account. During this flow the wallet communicates with one or more recovery signer servers to register the wallet for a later recovery if it's needed.
You can read more about working with Recovery Servers in the respective doc section.
Quotes #
SEP-038 defines a way for anchors to provide quotes for the exchange of an off-chain asset and a different on-chain asset, and vice versa.
You can read more about requesting quotes in the respective doc section.
Programmatic Deposit and Withdrawal #
The SEP-06 standard defines a way for anchors and wallets to interact on behalf of users.
Wallets use this standard to facilitate exchanges between on-chain assets (such as stablecoins) and off-chain assets (such as fiat, or other network assets such as BTC).
You can read more about programmatic deposit and withdrawal in the respective doc section.
Docs and Examples #
Documentation can be found in the doc folder and on the official Stellar Build a Wallet with the Wallet SDK page.
Examples can be found in the test cases and in the included example app.
Sample app #
Flutter Basic Pay is an open source demo app showing how this SDK can be used to implement a Stellar Payment App.
The app has a detailed tutorial and currently offers the following features:
Signup
Log in
Encrypting of secret key and secure storage of data
Create account
Fund account on testnet
Fetch account data from the Stellar Network
Add and remove asset support
Send payments
Fetch recent payments
Find strict send and strict receive payment paths
Send path payments
Add and use contacts
Add and use your KYC data
SEP-06 deposits and withdrawals
SEP-24 deposits and withdrawals
SEP-06 & SEP-24 transfer history
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.