Stellar SDK for flutter - dart, Stellar, Horizon, Soneso

Overview

Stellar SDK for Flutter

Dart Flutter

The Soneso open source Stellar SDK for Flutter is build with Dart and provides APIs to build and sign transactions, connect and query Horizon.

Installation

From pub.dev

  1. Add the dependency to your pubspec.yaml file:
dependencies:
  stellar_flutter_sdk: ^1.2.7
  1. Install it (command line or IDE):
flutter pub get
  1. In your source file import the SDK, initialize and use it:
import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart';

final StellarSDK sdk = StellarSDK.TESTNET;

String accountId = "GASYKQXV47TPTB6HKXWZNB6IRVPMTQ6M6B27IM5L2LYMNYBX2O53YJAL";
AccountResponse account = await sdk.accounts.account(accountId);
print("sequence number: ${account.sequenceNumber}");

Manual

Add the SDK is a Flutter Dart plugin. Here is a step by step that we recommend:

  1. Clone this repo.
  2. Open the project in your IDE (e.g. Android Studio).
  3. Open the file pubspec.yaml and press Pub get in your IDE.
  4. Go to the project's test directory, run a test from there and you are good to go!

Add it to your app:

  1. In your Flutter app add the local dependency in pubspec.yaml and then run pub get:
dependencies:
   flutter:
     sdk: flutter
   stellar_flutter_sdk:
     path: ../stellar_flutter_sdk
  1. In your source file import the SDK, initialize and use it:
import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart';

final StellarSDK sdk = StellarSDK.TESTNET;

String accountId = "GASYKQXV47TPTB6HKXWZNB6IRVPMTQ6M6B27IM5L2LYMNYBX2O53YJAL";
AccountResponse account = await sdk.accounts.account(accountId);
print("sequence number: ${account.sequenceNumber}");

Quick Start

1. Create a Stellar key pair

Random generation

// create a completely new and unique pair of keys.
KeyPair keyPair = KeyPair.random();

print("${keyPair.accountId}");
// GCFXHS4GXL6BVUCXBWXGTITROWLVYXQKQLF4YH5O5JT3YZXCYPAFBJZB

print("${keyPair.secretSeed}");
// SAV76USXIJOBMEQXPANUOQM6F5LIOTLPDIDVRJBFFE2MDJXG24TAPUU7

Deterministic generation

The Stellar Ecosystem Proposal SEP-005 describes methods for key derivation for Stellar Accounts. This improves key storage and moving keys between wallets and apps.

Generate mnemonic
String mnemonic =  await Wallet.generate24WordsMnemonic();
print(mnemonic);
// mango debris lumber vivid bar risk prosper verify photo put ridge sell range pet indoor lava sister around panther brush twice cattle sauce romance
Generate key pairs
Wallet wallet = await Wallet.from("mango debris lumber vivid bar risk prosper verify photo put ridge sell range pet indoor lava sister around panther brush twice cattle sauce romance");

KeyPair keyPair0 = await wallet.getKeyPair(index: 0);
print("${keyPair0.accountId} : ${keyPair0.secretSeed}");
// GBYTVBTOVXBIT23X4YUEE32QBAAA537OAF553FWABUAZHT3FNPN3FUGG : SBEQZ4XGS434POXNQYUXQYFV6JYUHV56U2MNMUZBBBLBGR5X6PUUCYO5

KeyPair keyPair1 = await wallet.getKeyPair(index: 1);
print("${keyPair1.accountId} : ${keyPair1.secretSeed}");
// GD5JFZ6U4TBKLWOVGAJQZ4CWRHNVXIFF65BBXZG6UEQE74RUXWAKQVQN : SD3IXULYMZKB6ML7AJW4OLAXKN6U3BYDUMOZLKUZTCCGZXUFXAS7NKIO

Supported languages are: english, french, spanish, italian, korean, japanese, simplified chinese and traditional chinese. Find more details in our SEP-005 examples.

2. Create an account

After the key pair generation, you have already got the address, but it is not activated until someone transfers at least 1 lumen into it.

2.1 Testnet

If you want to play in the Stellar test network, the SDK can ask Friendbot to create an account for you as shown below:

bool funded = await FriendBot.fundTestAccount(keyPair.accountId);
print ("funded: ${funded}");

2.2 Public net

On the other hand, if you would like to create an account in the public net, you should buy some Stellar Lumens (XLM) from an exchange. When you withdraw the Lumens into your new account, the exchange will automatically create the account for you. However, if you want to create an account from another account of your own, you may run the following code:

/// Create a key pair for your existing account.
KeyPair keyA = KeyPair.fromSecretSeed("SAPS66IJDXUSFDSDKIHR4LN6YPXIGCM5FBZ7GE66FDKFJRYJGFW7ZHYF");

/// Load the data of your account from the stellar network.
AccountResponse accA = await sdk.accounts.account(keyA.accountId);

/// Create a keypair for a new account.
KeyPair keyB = KeyPair.random();

/// Create the operation builder.
CreateAccountOperationBuilder createAccBuilder = CreateAccountOperationBuilder(keyB.accountId, "3"); // send 3 XLM (lumen)

// Create the transaction.
Transaction transaction = new TransactionBuilder(accA)
        .addOperation(createAccBuilder.build())
        .build();

/// Sign the transaction with the key pair of your existing account.
transaction.sign(keyA, Network.PUBLIC);

/// Submit the transaction to the stellar network.
SubmitTransactionResponse response = await sdk.submitTransaction(transaction);

if (response.success) {
  print ("account ${keyB.accountId} created");
}

3. Check account

3.1 Basic info

After creating the account, we may check the basic information of the account.

String accountId = "GASYKQXV47TPTB6HKXWZNB6IRVPMTQ6M6B27IM5L2LYMNYBX2O53YJAL";

// Request the account data.
AccountResponse account = await sdk.accounts.account(accountId);

// You can check the `balance`, `sequence`, `flags`, `signers`, `data` etc.

for (Balance balance in account.balances) {
  switch (balance.assetType) {
    case Asset.TYPE_NATIVE:
      print("Balance: ${balance.balance} XLM");
      break;
    default:
      print("Balance: ${balance.balance} ${balance
          .assetCode} Issuer: ${balance.assetIssuer}");
  }
}

print("Sequence number: ${account.sequenceNumber}");

for (Signer signer in account.signers) {
  print("Signer public key: ${signer.accountId}");
}

for (String key in account.data.keys) {
  print("Data key: ${key} value: ${account.data[key]}");
}

3.2 Check payments

You can check the payments connected to an account:

Page<OperationResponse> payments = await sdk.payments.forAccount(accountAId).order(RequestBuilderOrder.DESC).execute();

for (OperationResponse response in payments.records) {
  if (response is PaymentOperationResponse) {
    PaymentOperationResponse por = response as PaymentOperationResponse;
    if (por.transactionSuccessful) {
      print("Transaction hash: ${por.transactionHash}");
    }
  }
}

You can use:limit, order, and cursor to customize the query. Get the most recent payments for accounts, ledgers and transactions.

Horizon has SSE support for push data. You can use it like this:

String accountId = "GDXPJR65A6EXW7ZIWWIQPO6RKTPG3T2VWFBS3EAHJZNFW6ZXG3VWTTSK";

sdk.payments.forAccount(accountId).cursor("now").stream().listen((response) {
  if (response is PaymentOperationResponse) {
    switch (response.assetType) {
      case Asset.TYPE_NATIVE:
        print("Payment of ${response.amount} XLM from ${response.sourceAccount} received.");
        break;
      default:
        print("Payment of ${response.amount} ${response.assetCode} from ${response.sourceAccount} received.");
    }
  }
});

3.3 Check others

Just like payments, you you check assets, transactions, effects, offers, operations, ledgers etc.

sdk.assets.
sdk.transactions.
sdk.effects.
sdk.offers.
sdk.operations.
sdk.orderBook.
sdk.trades.
// add so on ...

4. Building and submitting transactions

Example "send native payment":

KeyPair senderKeyPair = KeyPair.fromSecretSeed("SAPS66IJDXUSFDSDKIHR4LN6YPXIGCM5FBZ7GE66FDKFJRYJGFW7ZHYF");
String destination = "GDXPJR65A6EXW7ZIWWIQPO6RKTPG3T2VWFBS3EAHJZNFW6ZXG3VWTTSK";

// Load sender account data from the stellar network.
AccountResponse sender = await sdk.accounts.account(senderKeyPair.accountId);

// Build the transaction to send 100 XLM native payment from sender to destination
Transaction transaction = new TransactionBuilder(sender)
    .addOperation(PaymentOperationBuilder(destination,Asset.NATIVE, "100").build())
    .build();

// Sign the transaction with the sender's key pair.
transaction.sign(senderKeyPair, Network.TESTNET);

// Submit the transaction to the stellar network.
SubmitTransactionResponse response = await sdk.submitTransaction(transaction);
if (response.success) {
  print("Payment sent");
}

5. Resolving a stellar address by using Federation

FederationResponse response = await Federation.resolveStellarAddress("bob*soneso.com");

print(response.stellarAddress);
// bob*soneso.com

print(response.accountId);
// GBVPKXWMAB3FIUJB6T7LF66DABKKA2ZHRHDOQZ25GBAEFZVHTBPJNOJI

print(response.memoType);
// text

print(response.memo);
// hello memo text

Documentation and Examples

Examples

Example Description Documentation
Create a new account A new account is created by another account. In the testnet we can also use Freindbot. Create account
Send native payment A sender sends 100 XLM (Stellar Lumens) native payment to a receiver. Payments
Crerate trustline An trustor account trusts an issuer account for a specific custom token. The issuer account can now send tokens to the trustor account. Assets & Trustlines and Change trust
Send tokens - non native payment Two accounts trust the same issuer account and custom token. They can now send this custom tokens to each other. Assets & Trustlines and Change trust and Payments
Path payments Two accounts trust different custom tokens. The sender wants to send token "IOM" but the receiver wants to receive token "ECO". Path payment strict send and Path payment strict receive
Merge accounts Merge one account into another. The first account is removed, the second receives the funds. Account merge
Bump sequence number In this example we will bump the sequence number of an account to a higher number. Bump sequence number
Manage data Sets, modifies, or deletes a data entry (name/value pair) that is attached to a particular account. Manage data
Manage buy offer Creates, updates, or deletes an offer to buy one asset for another, otherwise known as a "bid" order on a traditional orderbook. Manage buy offer
Manage sell offer Creates, updates, or deletes an offer to sell one asset for another, otherwise known as a "ask" order or “offer” on a traditional orderbook. Manage sell offer
Create passive sell offer Creates, updates and deletes an offer to sell one asset for another, otherwise known as a "ask" order or “offer” on a traditional orderbook, without taking a reverse offer of equal price. Create passive sell offer
Change trust Creates, updates, and deletes a trustline. Change trust and Assets documentation
Allow trust Updates the authorized flag of an existing trustline. Allow trust and Assets documentation
Stream payments Listens for payments received by a given account. Streaming
Fee bump transaction Fee bump transactions allow an arbitrary account to pay the fee for a transaction. Fee bump transactions
Muxed accounts In this example we will see how to use a muxed account in a payment operation. First-class multiplexed accounts
SEP-0001: stellar.toml In this example you can find out how to obtain data about an organization’s Stellar integration. SEP-0001
SEP-0002: Federation This example shows how to resolve a stellar address, a stellar account id, a transaction id and a forward by using the federation protocol. SEP-0002
SEP-0005: Key derivation In this examples you can see how to generate 12 or 24 words mnemonics for different languages using the Flutter SDK, how to generate key pairs from a mnemonic (with and without BIP 39 passphrase) and how to generate key pairs from a BIP 39 seed. SEP-0005
SEP-0006: Deposit and Withdrawal API In this examples you can see how to use the sdk to communicate with anchors. SEP-0006
SEP-0010: Stellar Web Authentication This example shows how to authenticate with any web service which requires a Stellar account ownership verification. SEP-0010
SEP-0011: Txrep This example shows how to to generate Txrep (human-readable low-level representation of Stellar transactions) from a transaction and how to create a transaction object from a Txrep string. SEP-0011
SEP-0012: KYC API In this examples you can see how to use the sdk to send KYC data to anchors and other services. SEP-0012

Additional examples can be found in the tests.

Documentation

You can fild additional documentation including the API documentation in the documentation folder.

SEPs implemented

How to contribute

Please read our Contribution Guide.

Then please sign the Contributor License Agreement.

License

The Stellar Sdk for Flutter is licensed under an MIT license. See the LICENSE file for details.

Comments
  • Unable to obtain JWT token from nTokens staging server

    Unable to obtain JWT token from nTokens staging server

    Hello, With the 1.2.6 SDK, I'm trying following code to obtain JWT from nTokens staging server:

        const anchorDomain = 'staging.ntokens.com';
        final toml = await StellarToml.fromDomain(anchorDomain);
    
        final webAuth = WebAuth(
          toml.generalInformation?.webAuthEndpoint,
          Network.TESTNET,
          toml.generalInformation?.signingKey,
          anchorDomain,
        );
    
        final jwt = await webAuth.jwtToken(accountId, [keypair]);
    

    and while equivalent code works on backend (JS SDK), I'm receiving error from https://github.com/Soneso/stellar_flutter_sdk/blob/bcfa69776803c34df82204a4af7e42223e210a3c/lib/src/sep/0010/webauth.dart#L282:

    {\"detail\":\"Unsupported media type \\"text/plain; charset=utf-8\\" in request.\"}
    

    Can you please make sure that the Flutter SDK works with the nTokens server? I'm not sure if the problem is on the Flutter SDK side, or nTokens are too restrictive.

    opened by Nopik 15
  • Unable to sign transaction using example

    Unable to sign transaction using example

    I get "Unsupported operation: Int64 accessor not supported by dart2js." When trying to sign an transaction using example at: https://github.com/Soneso/stellar_flutter_sdk/blob/master/documentation/sdk_examples/send_native_payment.md Error is in browser_client.dart, row 58 in http lib completer.complete(StreamedResponse(

    Using Flutter 2.5.1 stellar_flutter_sdk: ^1.2.1 Visual Studio Code 1.60.1 on Windows 10. Flutter extension: 3.26.0

    Using Network.TESTNET and StellarSDK.TESTNET; Fetching account information works but not signing a transaction. Have created and funded two separate accounts on TESTNET just to test but without luck. Tested the same transaction with Stellar Laboratory and it works. Fairly new to flutter but have done a couple of project using the go client for Stellar.

    opened by torkel 6
  • SEP-10: muxed account and memo support (SDF)

    SEP-10: muxed account and memo support (SDF)

    SEP-10 Muxed Account & Memo Support

    SEP-10 now supports authenticating users of shared, pooled, or omnibus Stellar accounts.

    These users are either represented using a muxed account (an M... address) or a Stellar account (G...) accompanied by an ID memo.

    Changes

    buildChallengeTx() or the equivalent function

    • Allow muxed accounts as client account parameter values
    • Add a optional memo parameter that accepts a 64-bit integer representation and attach it to the challenge transaction returned
      • If your language does not support optional parameters, this may be a breaking change
    • Disallow muxed client accounts and memos to be passed in the same call; they are mutually exclusive parameters

    readChallengeTx() or the equivalent function

    • Allow muxed accounts as source accounts of the first operation within challenge transactions
    • Add a 64-bit integer representation memo to the return value if present in the challenge transaction
      • Depending on the data type of the return value, this may be a breaking change
    • Disallow muxed client accounts and memos to be present in the challenge transaction; they are mutually exclusive

    Implementations

    The JS and Python SDKs have implemented this functionality, please use them as references:

    • (stellar/js-stellar-sdk#709)[https://github.com/stellar/js-stellar-sdk/pull/709] included in release v8.3.0
    • (stellarCN/py-stellar-base#521)[https://github.com/StellarCN/py-stellar-base/pull/521] included in release v4.2.0
    opened by JakeUrban 6
  • Issues in the example code

    Issues in the example code

    after running the example code to create account i keep getting this error...

    E/flutter (28206): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Error response from the server. Code: 404 - Body: {
    E/flutter (28206):   "type": "https://stellar.org/horizon-errors/not_found",
    E/flutter (28206):   "title": "Resource Missing",
    E/flutter (28206):   "status": 404,
    E/flutter (28206):   "detail": "The resource at the url requested was not found.  This usually occurs for one of two reasons:  The url requested is not valid, or no data in our database could be found with the parameters provided."
    
    opened by gbbest15 4
  • Protocol 19 SDK Support

    Protocol 19 SDK Support

    Protocol 19 SDK Support

    Once voted in, the release of Protocol 19 will introduce two new CAPs:

    • CAP-21, which introduces new transaction validity preconditions, and
    • CAP-40, which introduces a new type of signer: signed payloads

    API Changes

    Horizon will return new fields for both accounts and transactions:

    Accounts

    Account records can now contain two new, optional fields:

    "sequence_ledger": 0, // uint32 ledger number
    "sequence_time": "0"  // uint64 unix time in seconds, as a string
    

    The absence of these fields indicates that the account hasn't taken any actions since prior to the Protocol 19 release. Note that they'll either be both present or both absent.

    Transactions

    Each transaction record can now contain the following optional object:

    "preconditions": {
      "timebounds": {
        "min_time": "0",  // uint64 unix time in seconds, as a string
        "max_time": "0"   // as above
      },
      "ledgerbounds": {
        "min_ledger": 0,  // uint32 ledger number
        "max_ledger": 0   // as above
      },
      "min_account_sequence": "0",          // int64 sequence number, as a string
      "min_account_sequence_age": "0",      // uint64 unix time in seconds, as a string
      "min_account_sequence_ledger_gap": 0, // uint32 ledger count
    
      "extra_signers": [] // list of signers as StrKeys
    }
    

    All of the top-level fields within this object are also optional. However, the "ledgerbounds" object will always have its inner values set.

    Note that the existing "valid_before_time" and "valid_after_time" fields on the top-level object will be identical to the "preconditions.timebounds.min_time" and "preconditions.timebounds.min_time" fields, respectively, if those exist. The "valid_before_time" and "valid_after_time" fields are now considered deprecated and will be removed in Horizon v3.0.0.

    StrKey Changes

    The specification for CAP-40's new signed payload signers is outlined in this SEP-23 change: stellar/stellar-protocol#0943c19e. In summary, it should be prefixed with a P, then encode the signer address followed by the payload in typical XDR fashion.

    Keypair Changes

    It should be possible to create decorated signature hints from signed payloads as described in CAP-40.

    Transaction Builder Changes

    SDKs should allow transactions to be built with the new preconditions:

    • ledger bounds
    • minimum account sequence number
    • minimum account sequence age
    • minimum ledger-gap from the account sequence
    • extra signers

    Refer to CAP-21 for the details on their intended functionality.

    For handling timebounds, we recommend the following pattern:

    • If a transaction only has a timebound set, set the PRECOND_TIME XDR structure
    • If the transaction has other preconditions set, set the PRECOND_V2 XDR structure

    This provides both backwards compatibility and future efficiency. Note that SDKs typically require that timebounds be set on a transaction. Omitting timebounds must be done explicitly, e.g. by doing .setTimeout(TIMEOUT_INFINITE) in the JavaScript SDK.

    Signers should be represented as their human-readable StrKey strings, but should decode to (and encode from) SignerKey XDR instances.

    Reference Implementations

    There are three reference implementations authored by SDF:

    • Go: stellar/go#4261
    • Java: stellar/java-stellar-sdk#409
    • JavaScript: stellar/js-stellar-sdk#763

    You can follow each respective issue to its implementation PRs.

    opened by Shaptic 4
  • Exception Submitting transaction

    Exception Submitting transaction

    Hi, I'm getting this exception after withdraw request when trying to deposit to anchor.

    Exception: Bad state: Cannot set the body fields of a Request with content-type "application/json". E/flutter ( 8436): #0 Request.bodyFields= (package:http/src/request.dart:133:7) E/flutter ( 8436): #1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:87:17) E/flutter ( 8436): #2 BaseClient.post (package:http/src/base_client.dart:32:7) E/flutter ( 8436): #3 StellarSDK.submitTransactionEnvelopeXdrBase64 (package:stellar_flutter_sdk/src/stellar_sdk.dart:160:10) E/flutter ( 8436): #4 StellarSDK.submitTransaction (package:stellar_flutter_sdk/src/stellar_sdk.dart:141:12)

    Asset asset = AssetTypeCreditAlphaNum4('SRT' , issuer);

    Transaction transaction = TransactionBuilder(sender) .addOperation(PaymentOperationBuilder( withdrawAnchorAccount, asset,'100') .build()).addMemo(MemoHash(base64Decode(withdrawMemo))) .build();

    transaction.sign(keyPair,Network.TESTNET); SubmitTransactionResponse submitTransactionResponse = await StellarSDK.TESTNET.submitTransaction(transaction);

    opened by abidnazir27 4
  • Add support for additional `_muxed` and `_muxed_id` optional fields in Horizon's JSON responses

    Add support for additional `_muxed` and `_muxed_id` optional fields in Horizon's JSON responses

    TL;DR

    Add support for additional _muxed and _muxed_id optional fields in Horizon's JSON responses (available since Horizon 2.4, following what's described in SEP 23). That is:

    Anyplace a MuxedAccount appears, if the account is of a multiplexed type (currently just KEY_TYPE_MUXED_ED2551), two new fields are added to the JSON.

    • Base field name + _muxed is the strkey of the multiplexed account.

    • Base field name + _muxed_id is the integer.

    For example, given the MuxedAccount MAQAA5L65LSYH7CQ3VTJ7F3HHLGCL3DSLAR2Y47263D56MNNGHSQSAAAAAAAAAAE2LP26, you might get the following fields:

        source_account: GAQAA5L65LSYH7CQ3VTJ7F3HHLGCL3DSLAR2Y47263D56MNNGHSQSTVY
        source_account_muxed: MAQAA5L65LSYH7CQ3VTJ7F3HHLGCL3DSLAR2Y47263D56MNNGHSQSAAAAAAAAAAE2LP26
        source_account_muxed_id: 1234
    

    For instance, here's an /operations response with the new fields:

    {
      "_links": {
        "self": {
          "href": "https://horizon.stellar.org/operations/?cursor=\u0026limit=10\u0026order=asc"
        },
        "next": {
          "href": "https://horizon.stellar.org/operations/?cursor=33818572492801\u0026limit=10\u0026order=asc"
        },
        "prev": {
          "href": "https://horizon.stellar.org/operations/?cursor=12884905985\u0026limit=10\u0026order=desc"
        }
      },
      "_embedded": {
        "records": [
          {
            "_links": {
              "self": {
                "href": "https://horizon.stellar.org/operations/12884905986"
              },
              "transaction": {
                "href": "https://horizon.stellar.org/transactions/3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889"
              },
              "effects": {
                "href": "https://horizon.stellar.org/operations/12884905986/effects"
              },
              "succeeds": {
                "href": "https://horizon.stellar.org/effects?order=desc\u0026cursor=12884905986"
              },
              "precedes": {
                "href": "https://horizon.stellar.org/effects?order=asc\u0026cursor=12884905986"
              }
            },
            "id": "12884905986",
            "paging_token": "12884905986",
            "transaction_successful": true,
            "source_account": "GAQAA5L65LSYH7CQ3VTJ7F3HHLGCL3DSLAR2Y47263D56MNNGHSQSTVY",
            "source_account_muxed": "MAQAA5L65LSYH7CQ3VTJ7F3HHLGCL3DSLAR2Y47263D56MNNGHSQSAAAAAAAAAAE2LP26",
            "source_account_muxed_id": 1234,
            "type": "payment",
            "type_i": 1,
            "created_at": "2015-09-30T17:15:54Z",
            "transaction_hash": "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889",
            "asset_type": "native",
            "from": "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ",
            "from_muxed": "MAQAA5L65LSYH7CQ3VTJ7F3HHLGCL3DSLAR2Y47263D56MNNGHSQSAAAAAAAAAAE2LP26",
            "from_muxed_id": 1234,
            "to": "GAQAA5L65LSYH7CQ3VTJ7F3HHLGCL3DSLAR2Y47263D56MNNGHSQSTVY",
            "amount": "99999999959.9999700"
          }
        ]
      }
    }   
    

    Note the:

    • "source_account_muxed" and "source_account_muxed_id" fields.
    • "from_muxed" and "from_muxed_id" fields.

    Also, note how, although the XDR destination address of the Payment operation is a Multiplexed Account, there are no to_muxed nor to_muxed_id fields in the response. This simply means that the XDR representation of the destination address is of type KEY_TYPE_ED25519 and not KEY_TYPE_MUXED_ED2551.

    Exhaustive list of new fields

    • transactions objects: "account_muxed", "account_muxed_id", "fee_account_muxed" and "fee_account_muxed_id".
    • operation objects: source_account_muxed and source_account_muxed_id. Additional fields depending on the operation type:
      • "create_account" operation: "funder_muxed", "funder_muxed_id".
      • "payment", "path_payment_strict_receive" and "path_payment_strict_send" operations: from_muxed, from_muxed_id, to_muxed and to_muxed_id.
      • "change_trust" operation: "trustor_muxed" and "trustor_muxed_id".
      • "allow_trust" operation: "trustee_muxed" and "trustee_muxed_id".
      • "account_merge" operation: "account_muxed", "account_muxed_id", "into_muxed", and "into_muxed_id".
      • "claim_claimable_balance" operation: "claimant_muxed" and "claimant_muxed_id".
      • "end_sponsoring_future_reserves" operation: "begin_sponsor_muxed", "begin_sponsor_muxed_id".
      • "clawback" operation: "from_muxed", "from_muxed_id".
    • effect objects: "account_muxed", "account_muxed_id". Additional fields depending on the effect type:
      • "trade" effect: "seller_muxed" and "seller_muxed_id".

    Reference implementation

    You can use the Go SDK implementation as a reference:

    opened by 2opremio 4
  • Protocol 16 support

    Protocol 16 support

    This issue lists the changes to the Horizon API introduced by CAP-35. This CAP comprises the public-facing changes in Stellar Protocol 16. The first Horizon version with the updated API is Horizon 2.1.0.

    This protocol upgrade is purely additive. We expect a protocol 16 compliant SDK to be able to run successfully against a protocol 16 network.

    We are aiming for the following tentative timeline:

    March 30: Horizon released with protocol 16 support (done)
    Begining of April: Core release with protocol 16 support
    May: Protocol 16 deployed to Testnet
    June: Protocol 16 Prodnet-deployment vote
    

    New objects

    None

    Modified objects

    • Claimable Balance

      • Claimable balance flags have been incorporated (by bumping it's XDR extension version to v1). For now there's only a possible flag (CLAIMABLE_BALANCE_ENABLED_FLAG)
    • Trustline

      • A new flag as been added (AUTH_CLAWBACK_ENABLED_FLAG)

    New endpoints

    None

    Modified endpoints

    None

    New Operations

    • clawback with the following fields:

      • Asset fields (identical to the asset fields in the Change Trust, Allow Trust and Set Trustline Flags operations)
        • asset_type
        • asset_code
        • asset_issuer
      • from - account from which the asset is clawed back
      • amount - asset amount clawed back
    • clawback_claimable_balance, with the following fields:

      • balance_id - claimable balance identifer of the claimable balance to be clawed back
    • set_trust_line_flags, with the following fields:

      • Asset fields (identical to the asset fields in the Change Trust, Allow Trust and Set Trustline Flags operations)
        • asset_type
        • asset_code
        • asset_issuer
      • trustor - account whose trustline is affected by this operation
      • flag fields, with the same scheme as the Set Options operation (note that CAP-35 introduces the new AUTH_CLAWBACK_ENABLED_FLAG flag)
        • set_flags - array containing the integer (XDR) representation of the flags to enable
        • set_flags_s - array containing the textual representation of the flags in set_flags (possible values are: authorized, authorized_to_maintain_liabilites and clawback_enabled)
        • clear_flags - array containing the integer (XDR) representation of the flags to disable
        • clear_flags_s - array containing the textual representation of the flags in clear_flags (possible values are: authorized, authorized_to_maintain_liabilites and clawback_enable)

    New effects

    • trustline_flags_updated, with the following fields:

      • Asset fields (like explained in the operations above):
        • asset_type
        • asset_code
        • asset_issuer
      • trustor - account whose trustline the effect refers to
      • authorized_flag - true to indicate the flag is set, field ommited if not set
      • authorized_to_maintain_liabilites - true to indicate the flag is set, field ommited if not set
      • clawback_enabled_flag - true to indicate that the flag is set, field ommitted if not set
    • claimable_balance_clawed_back, with the following fields:

      • balance_id - claimable balance identifer of the claimable balance clawed back

    Deprecations

    • Operation allow_trust is deprecated in favor of set_trust_line_flags (although it will still be supported by the network)

    • Effects trustline_authorized, trustline_authorized_to_maintain_liabilities and trustline_deauthorized are deprecated in favor of trustline_flags_updated. Note how we intentionally didn't add a new trustline_authorized_clawback_enabled effect.

      For uniformity, the allow_trust operation will start producing trustline_flags_updated from this release.

      For now trustline_authorized, trustline_authorized_to_maintain_liabilities and trustline_deauthorized will continue to be emitted as a result of the allow_trust operation but in the future we may stop doing so.

    opened by 2opremio 4
  • Protocol 14 support

    Protocol 14 support

    This issue lists the changes to the Horizon API introduced by CAP-23 and CAP-33. These two CAPs comprise the public-facing changes in Stellar Protocol 14. The first Horizon version with the updated API is Horizon 1.9.0-RC, to be released 2020-09-21 (monorepo release page).

    This protocol upgrade is purely additive. We expect a protocol 14 compliant SDK to be able to run successfully against a protocol 13 network.

    We are aiming for the following timeline:

    • 2020-09-21 Horizon 1.9.0-RC is released with support for protocol 14
    • 2020-09-30 Testnet will vote to update to protocol 14
    • 2020-10-28 Pubnet will vote to update to protocol 14

    In what follows, "canonical form" means code:address or native (for the XLM asset).

    New objects

    • Claimable Balance with the following fields:
      • id - balance ID,
      • paging_token - paging token,
      • asset - asset available to be claimed (in canonical form),
      • amount - amount available to be claimed (string, like all amounts),
      • sponsor - sponsoring account ID (can be null),
      • last_modified_ledger - sequence number of the ledger when the balance was last modified,
      • claimants - list of objects:
        • destination - destination account ID,
        • predicate - predicate required to claim a balance (see below).

    Modified objects

    • Account object:
      • New sponsor field (account ID, can be null).
      • New num_sponsoring field - number of reserves sponsored by this account,
      • New num_sponsored field - number of reserves sponsored for this account.
    • New sponsor field (account ID) in Account > Balance object (only for non-native assets, can be null).
    • New sponsor field (account ID) in Account > Signers object (can be null).
    • New sponsor field (account ID) in Account's Data object (can be null).
    • New sponsor field (account ID) in Offer object (can be null).

    New endpoints

    • /claimable_balances - the list of Claimable Balance objects with the following parameters (only one param per request allowed):
      • asset - find all claimable balances with the given asset (in canonical form),
      • claimant - find all claimable balances with the given claimant account ID,
      • sponsor - find all claimable balances sponsored by a given sponsor account ID.
    • /claimable_balances/{id} - a single Claimable Balance object.

    Modified endpoints

    • /accounts can now by filtered by sponsor (new GET param).
    • /offers can now by filtered by sponsor (new GET param).

    New operations

    • create_claimable_balance with the following fields:
      • asset - asset available to be claimed (in canonical form),
      • amount - amount available to be claimed,
      • claimants - list of claimants with predicates (see below):
        • destination - destination account ID,
        • predicate - predicate required to claim a balance (see below).
    • claim_claimable_balance with the following fields:
      • balance_id - unique ID of balance to be claimed,
      • claimant - account ID of a claimant.
    • begin_sponsoring_future_reserves with the following fields:
      • sponsored_id - account ID for which future reserves will be sponsored.
    • end_sponsoring_future_reserves with the following fields:
      • begin_sponsor - account sponsoring reserves.
    • revoke_sponsorship with the following fields:
      • account_id - if account sponsorship was revoked,
      • claimable_balance_id - if claimable balance sponsorship was revoked,
      • data_account_id - if account data sponsorship was revoked,
      • data_name - if account data sponsorship was revoked,
      • offer_id - if offer sponsorship was revoked,
      • trustline_account_id - if trustline sponsorship was revoked,
      • trustline_asset - if trustline sponsorship was revoked,
      • signer_account_id - if signer sponsorship was revoked,
      • signer_key - if signer sponsorship was revoked.

    New effects

    • claimable_balance_created with the following fields:
      • balance_id - unique ID of claimable balance,
      • asset - asset available to be claimed (in canonical form),
      • amount - amount available to be claimed.
    • claimable_balance_claimant_created with the following fields:
      • balance_id - unique ID of a claimable balance,
      • asset - asset available to be claimed (in canonical form),
      • amount - amount available to be claimed,
      • predicate - predicate required to claim a balance (see below).
    • claimable_balance_claimed with the following fields:
      • balance_id - unique ID of a claimable balance,
      • asset - asset available to be claimed (in canonical form),
      • amount - amount available to be claimed,
    • account_sponsorship_created with the following fields:
      • sponsor - sponsor of an account.
    • account_sponsorship_updated with the following fields:
      • new_sponsor - new sponsor of an account,
      • former_sponsor - former sponsor of an account.
    • account_sponsorship_removed with the following fields:
      • former_sponsor - former sponsor of an account.
    • trustline_sponsorship_created with the following fields:
      • sponsor - sponsor of a trustline.
    • trustline_sponsorship_updated with the following fields:
      • new_sponsor - new sponsor of a trustline,
      • former_sponsor - former sponsor of a trustline.
    • trustline_sponsorship_removed with the following fields:
      • former_sponsor - former sponsor of a trustline.
    • claimable_balance_sponsorship_created with the following fields:
      • sponsor - sponsor of a claimable balance.
    • claimable_balance_sponsorship_updated with the following fields:
      • new_sponsor - new sponsor of a claimable balance,
      • former_sponsor - former sponsor of a claimable balance.
    • claimable_balance_sponsorship_removed with the following fields:
      • former_sponsor - former sponsor of a claimable balance.
    • signer_sponsorship_created with the following fields:
      • signer - signer being sponsored.
      • sponsor - signer sponsor.
    • signer_sponsorship_updated with the following fields:
      • signer - signer being sponsored.
      • former_sponsor - the former sponsor of the signer.
      • new_sponsor - the new sponsor of the signer.
    • signer_sponsorship_removed with the following fields:
      • former_sponsor - former sponsor of a signer.

    predicate field

    predicate field is a JSON representation of xdr.ClaimPredicate as defined in CAP-23 and is a requirement that needs to be satisfied to claim the balance. It is a recursive structure that can be represented in JSON using for example the following Golang struct:

    type claimPredicateJSON struct {
    	And           *[]claimPredicateJSON `json:"and,omitempty"`
    	Or            *[]claimPredicateJSON `json:"or,omitempty"`
    	Not           *claimPredicateJSON   `json:"not,omitempty"`
    	Unconditional bool                  `json:"unconditional,omitempty"`
    	AbsBefore     *time.Time            `json:"absBefore,omitempty"`
    	RelBefore     *int64                `json:"relBefore,omitempty"`
    }
    

    Please refer to the Golang implementation for details.

    The following issue shows how the Golang SDK will handle predicate creation: https://github.com/stellar/go/issues/3000

    RevokeSponsorshipOp

    The RevokeSponsorshipOp requires users to build LedgerKey or a struct for signers sponsorship. Ideally SDKs should expose helpers that build a valid operation for users without require them to pass an XDR LedgerKey. See the following issue for more information https://github.com/stellar/go/issues/3001 .

    opened by abuiles 4
  • Get asset code from offers

    Get asset code from offers

    Hello I have faced an issue: I can not get Selling and Buying asset's code from offers of an account. For example, I have created an offer from native to BTC. When I load the offers, there is no property to get the asset's code. Please check this Thanks

    opened by AliKarimiENT 3
  • flutter web got exception RangeError

    flutter web got exception RangeError

    Hi, I try to use stellar_flutter_sdk in flutter web. the code simply call KeyPair.random().

    I got this exception:

    ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
    The following RangeError was thrown building MyApp(dirty):
    max must be in range 0 < max ≤ 2^32, was 0
    
    The relevant error-causing widget was:
      MyApp file:///Users/x/y/z/lib/main.dart:5:10
    
    When the exception was thrown, this was the stack:
    dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 214:49  throw_
    dart-sdk/lib/_internal/js_dev_runtime/patch/math_patch.dart 314:7             nextInt
    packages/tweetnacl/src/tweetnacl_base.dart 3150:27                            randombytes_array_len
    packages/tweetnacl/src/tweetnacl_base.dart 3139:12                            randombytes_array
    packages/tweetnacl/src/tweetnacl_base.dart 3143:12                            randombytes
    packages/stellar_flutter_sdk/src/key_pair.dart 176:46                         random
    

    that was using Chrome (web), ddc runtime. the functionality has no problem on the Android emulator.

    my pubspec.yaml:

      stellar_flutter_sdk: ^1.0.4
    

    I saw both packages stellar_flutter_sdk and tweetnacl, has flutter web badge support.

    thoughts?

    thank you.

    opened by oonid 3
Releases(1.4.1)
Owner
Soneso
Development, advisory and research on blockchain and decentralized applications
Soneso
Task List application developed in Dart language with SDK Flutter for Android, iOS and Web

Task List application developed in Dart language with SDK (Software Development Kit) Flutter for Android, iOS and Web.

João Bruno 2 Jun 2, 2022
The official sdk for the user-friendly API of Mega services on the Dart language.

megasdkdart The official sdk for the user-friendly API of Mega services in the Dart language. Example: import 'package:megasdkdart/megasdkdart.dart';

meg4cyberc4t 4 Mar 30, 2022
Unofficial Dart SDK for Decentralized Social / DeSo.org

DeSo Dart SDK Unofficial Dart SDK for Decentralized Social / DeSo.org Report Bug · Request Feature Table of Contents About the Project Built With Gett

Deverse 8 Sep 16, 2022
Dart SDK for Dapr.

Dapr dart sdk Welcome to the dart-sdk for dapr. This repository aims to provide and maintain the dart packages required to interact with dapr sidecar.

Abhilash Chandran 8 Sep 7, 2022
The Dart SDK, including the VM, dart2js, core libraries, and more.

Dart A client-optimized language for fast apps on any platform Dart is: Optimized for UI: Develop with a programming language specialized around the n

Dart 8.7k Jan 2, 2023
A Flutter plugin for the Google Mobile Ads SDK

A Flutter plugin for the Google Mobile Ads SDK

Google Ads 251 Jan 2, 2023
P2P payment solution using Stream's Flutter SDK and Rapyd's Wallet API

Peer-to-peer payment integration to a messaging app using Flutter ?? This project shows how to integrate a peer-to-peer payment solution to your Strea

Souvik Biswas 15 Dec 8, 2022
Official plugin for using Thepeer SDK with flutter https://thepeer.co

Flutter Thepeer This package makes it easy to use the Thepeer in a flutter project. ?? Screen Shots ?? How to Use plugin ThePeer Send Launch ThepeerSe

The Peer 23 Dec 27, 2022
Hybrid App build on flutter SDK able to run on Android, IOS, web, desktop

Codeforces Visualizer APP Ready to use Flutter Application. Uses codeforces API. Useful for codeforces programmers. ScreenShots Single User Page Compa

vikas yadav 13 Dec 31, 2022
A simple chat app UI using flutter SDK project.

Chatty App A simple chat app UI using flutter SDK project. Screenshot Getting Started This project is a starting point for a Flutter application. A fe

Tengku Belmiro 5 Jul 15, 2022
A Flutter plugin that supports Pangle SDK on Android and iOS.

Thanks for non-commercial open source development authorization by JetBrains. 穿山甲 Flutter SDK `pangle_flutter`是一款集成了字节跳动穿山甲 Android 和 iOS SDK的 Flutter

null 121 Dec 2, 2022
Flutter SDK for Stripe.

Flutter Stripe The Stripe Flutter SDK allows you to build delightful payment experiences in your native Android and iOS apps using Flutter. We provide

null 633 Jan 7, 2023
Cross platform application for iOS and Android using Google's SDK Flutter.

scout Cross platform application for iOS and Android using Google's SDK Flutter. Launch screen for the application. The menu for selecting cookies. Cu

null 0 Nov 9, 2021
Official Flutter SDK for Khalti Payment systems

Khalti Payment Gateway for Flutter Use Khalti Payment Gateway solution in your app or website to simplify payment for your customers. You do not need

Khalti 16 Oct 13, 2022
This project is the HERE SDK reference application for Flutter

HERE SDK Reference Application for Flutter The reference application for the HERE SDK for Flutter (Navigate Edition) shows how a complex and release-r

HERE Technologies 32 Dec 15, 2022
A Social App Built Using FLutter SDK.

Hi ?? , I'm Faheem ??‍?? A Social App Built Using FLutter SDK. The main objective of this application is to provide a single platform for the Students

Faheem Ahmad 26 Nov 10, 2022
Flutter Video Conferencing SDK & Sample App

100ms Flutter SDK ?? Here you will find everything you need to build experiences with video using 100ms iOS/Android SDK. Dive into our SDKs, quick sta

100ms 79 Dec 22, 2022
Real-world movie database mobile application with the Flutter SDK and DDD clean architecture.

Moving Pictures Moving Pictures is a mobile application built with the Flutter SDK for Android and iOS. It’s an application that gets the information

Nifemi 57 Jan 7, 2023
Sample app to demonstrate the integration and working of Dyte SDK for mobile, using Flutter.

Flutter Sample App by dyte Sample App to demonstrate Dyte SDK in flutter Explore the docs » View Demo · Report Bug · Request Feature Table of Contents

Dyte 12 Jan 1, 2023