### POST /install Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/SorobanClient/install Installs (uploads) the given contract code to Soroban. If successful, it returns the WASM hash of the installed contract as a hex string. ```APIDOC ## POST /install ### Description Installs (uploads) the given contract code to Soroban. If successfully it returns the wasm hash of the installed contract as a hex string. ### Method POST ### Endpoint /install ### Parameters #### Request Body - **installRequest** (InstallRequest) - Required - An object containing the necessary information for installation, including WASM bytes, source account key pair, network, RPC URL, and Soroban server logging preference. - **force** (boolean) - Optional - Defaults to `false`. If `true`, forces the installation even if it's a read-only call. ### Request Example ```json { "installRequest": { "wasmBytes": "0x...", "sourceAccountKeyPair": { "secretSeed": "..." }, "network": "TESTNET", "rpcUrl": "https://rpc.testnet.stellar.org", "enableSorobanServerLogging": true }, "force": false } ``` ### Response #### Success Response (200) - **wasmHash** (string) - The hex string representation of the WASM hash of the installed contract. #### Response Example ```json { "wasmHash": "abcdef1234567890..." } ``` #### Error Response - **Exception** - Thrown if the WASM hash cannot be extracted from the simulation result or if the WASM ID cannot be retrieved after sending the transaction. ``` -------------------------------- ### Example Usage of setSetFlags (Flutter/Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/SetOptionsOperationBuilder/setSetFlags Illustrative examples of calling the setSetFlags method with different flag combinations. These examples show how to set individual flags or combine them using bitwise OR operations to configure account authorization settings. ```dart .setSetFlags(1) // Require authorization .setSetFlags(3) // Require authorization + allow revocable (1 + 2) ``` -------------------------------- ### Install Flutter Dependencies Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/index This command-line instruction is used to fetch and install all the dependencies listed in your Flutter project's pubspec.yaml file, including the stellar_flutter_sdk. ```bash flutter pub get ``` -------------------------------- ### Install Contract to Soroban (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/SorobanClient/install Installs (uploads) contract code to Soroban using the provided InstallRequest. Returns the wasm hash as a hex string upon success. Handles transaction assembly, signing, and sending, with simulation capabilities. ```dart static Future install( {required InstallRequest installRequest, bool force = false}) async { final uploadContractHostFunction = UploadContractWasmHostFunction(installRequest.wasmBytes); final op = InvokeHostFuncOpBuilder(uploadContractHostFunction).build(); final clientOptions = ClientOptions( sourceAccountKeyPair: installRequest.sourceAccountKeyPair, contractId: "ignored", network: installRequest.network, rpcUrl: installRequest.rpcUrl, enableServerLogging: installRequest.enableSorobanServerLogging); final options = AssembledTransactionOptions( clientOptions: clientOptions, methodOptions: MethodOptions(), method: "ignored", enableSorobanServerLogging: installRequest.enableSorobanServerLogging); final tx = await AssembledTransaction.buildWithOp(operation: op, options: options); if (!force && tx.isReadCall()) { final simulationData = tx.getSimulationData(); final returnedValue = simulationData.returnedValue; if (returnedValue.bytes == null) { throw Exception("Could not extract wasm hash from simulation result"); } else { return Util.bytesToHex(returnedValue.bytes!.dataValue); } } final response = await tx.signAndSend(force: force); final wasmHash = response.getWasmId(); if (wasmHash == null) { throw new Exception("Could not get wasm hash for installed contract"); } return wasmHash; } ``` -------------------------------- ### Example Usage of buyingAsset and sellingAsset (Flutter/Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/OrderBookRequestBuilder/buyingAsset This example demonstrates how to use the `sellingAsset` and `buyingAsset` methods together to create an order book request. It shows the typical chaining pattern for defining a trading pair before executing the order book query. ```dart var orderBook = await sdk.orderBook .sellingAsset(Asset.createNonNativeAsset('BTC', issuerId)) .buyingAsset(Asset.createNonNativeAsset('USDC', issuerId)) .execute(); ``` -------------------------------- ### Example Usage of fromDomain (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/KYCService/fromDomain An example demonstrating how to use the fromDomain static method to create a KYCService instance. This involves calling the method with a domain name and awaiting the result. ```dart final kycService = await KYCService.fromDomain('testanchor.stellar.org'); ``` -------------------------------- ### Install Soroban Contract WASM Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk Configures requests for installing Soroban contract WASM code. ```APIDOC ## POST /soroban/contract/install ### Description Configures requests for installing Soroban contract WASM code. ### Method POST ### Endpoint /soroban/contract/install ### Parameters #### Request Body - **`InstallRequest`** (object) - Request configuration for installing Soroban contract WASM code. ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **``** (object) - Response indicating the status of the WASM installation. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Example Usage of baseAsset and counterAsset (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/TradesRequestBuilder/baseAsset Demonstrates how to use the `baseAsset` and `counterAsset` methods to filter trades for a specific trading pair. This example fetches trades where 'XLM' is the base asset and the native asset is the counter asset. ```dart var trades = await sdk.trades .baseAsset(Asset.createNonNativeAsset('XLM', issuerId)) .counterAsset(Asset.NATIVE) .execute(); ``` -------------------------------- ### Example Usage: Fetching Trades for an Account (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/TradesRequestBuilder/forAccount An example demonstrating how to use the `forAccount` method to fetch trades associated with a specific account ID. It also shows chaining other methods like `order` and `limit` before executing the query. ```dart var trades = await sdk.trades .forAccount('GCDNJUBQSX7AJWLJACMJ7I4BC3Z47BQUTMHEICZLE6MU4KQBRYG5JY6B') .order(RequestBuilderOrder.DESC) .limit(50) .execute(); ``` -------------------------------- ### Example Usage of postAction (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/RegulatedAssetsService/postAction An example demonstrating how to use the postAction method. It shows how to call the method with an action URL and fields, and then how to handle the different types of PostActionResponse, such as PostActionDone or PostActionNextUrl. ```dart var actionResponse = await service.postAction( response.actionUrl, { 'email_address': 'user@example.com', 'mobile_number': '+1234567890' } ); if (actionResponse is PostActionDone) { // Resubmit the original transaction } else if (actionResponse is PostActionNextUrl) { // Open next_url in browser } ``` -------------------------------- ### Example Usage of forAccount Method (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/TransactionsRequestBuilder/forAccount Demonstrates how to use the forAccount method to retrieve transactions for a specific account in descending order. This example utilizes the Stellar Flutter SDK to interact with the Stellar network. ```dart var txs = await sdk.transactions .forAccount('GCDNJUBQSX7AJWLJACMJ7I4BC3Z47BQUTMHEICZLE6MU4KQBRYG5JY6B') .order(RequestBuilderOrder.DESC) .execute(); ``` -------------------------------- ### Example Usage of fromDomain (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/TransferServerService/fromDomain Demonstrates how to use the fromDomain static method to create a TransferServerService instance and then use it to fetch service information. This example assumes an `authToken` is available for authentication. ```dart final service = await TransferServerService.fromDomain( 'testanchor.stellar.org' ); final info = await service.info(jwt: authToken); ``` -------------------------------- ### Example Usage of forSigner Method (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/AccountsRequestBuilder/forSigner Demonstrates how to use the forSigner method to fetch accounts that have a given public key as a signer. This example showcases method chaining and asynchronous execution. ```dart var accounts = await sdk.accounts .forSigner('GCDNJUBQSX7AJWLJACMJ7I4BC3Z47BQUTMHEICZLE6MU4KQBRYG5JY6B') .execute(); ``` -------------------------------- ### Example Usage of counterAsset (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/TradesRequestBuilder/counterAsset Demonstrates how to use the counterAsset method in conjunction with baseAsset to retrieve trades for a specific trading pair. The example fetches trades where the base asset is NATIVE and the counter asset is USDC. ```dart var trades = await sdk.trades .baseAsset(Asset.NATIVE) .counterAsset(Asset.createNonNativeAsset('USDC', issuerId)) .execute(); ``` -------------------------------- ### Example Usage of SHA-256 Hash (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/Util/hash Demonstrates how to use the `hash` static method to compute the SHA-256 hash of a sample byte array. This example illustrates the typical workflow for hashing data before it's used in Stellar-related operations. ```dart Uint8List data = Uint8List.fromList([1, 2, 3, 4]); Uint8List hash = Util.hash(data); ``` -------------------------------- ### InstallRequest Constructor and Properties Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/InstallRequest-class Details on how to create an InstallRequest object and its configurable properties. ```APIDOC ## Class: InstallRequest ### Description Request configuration for installing Soroban contract WASM code. Uploads and stores contract code on the ledger, returning a hash that can be used to deploy contract instances via DeployRequest. ### Constructor `InstallRequest({required Uint8List wasmBytes, required KeyPair sourceAccountKeyPair, required Network network, required String rpcUrl, bool enableSorobanServerLogging = false})` Creates an InstallRequest for uploading contract WASM code to Soroban. ### Properties - **wasmBytes** (`Uint8List`) - Required - The contract code wasm bytes to install. - **sourceAccountKeyPair** (`KeyPair`) - Required - Keypair of the Stellar account that will send this transaction. The keypair must contain the private key for signing. - **network** (`Network`) - Required - The Stellar network this contract is to be installed. - **rpcUrl** (`String`) - Required - The URL of the RPC instance that will be used to install the contract. - **enableSorobanServerLogging** (`bool`) - Optional - Enable soroban server logging (helpful for debugging). Default: false. ``` -------------------------------- ### Get Hourly Trade Aggregations (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/TradeAggregationsRequestBuilder-class This example demonstrates how to retrieve hourly trade aggregations for a given trading pair (XLM/USDC). It specifies the start and end times, resolution (1 hour), and offset. The results are then iterated to print details like timestamp, high, low, and volume. Dependencies include the Stellar SDK, Asset class, and DateTime. ```dart var baseAsset = Asset.createNonNativeAsset('XLM', issuerId); var counterAsset = Asset.createNonNativeAsset('USDC', issuerId); var startTime = DateTime.now().subtract(Duration(days: 7)).millisecondsSinceEpoch; var endTime = DateTime.now().millisecondsSinceEpoch; var resolution = 3600000; // 1 hour in milliseconds var offset = 0; var aggregations = await sdk.tradeAggregations .tradeAggregations(baseAsset, counterAsset, startTime, endTime, resolution, offset) .limit(200) .order(RequestBuilderOrder.DESC) .execute(); for (var agg in aggregations.records) { print('Time: ${agg.timestamp}'); print('High: ${agg.high}, Low: ${agg.low}'); print('Volume: ${agg.baseVolume}'); } ``` -------------------------------- ### Example: Get Newest Payments First (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/RequestBuilder/order This example demonstrates how to use the 'order' method with RequestBuilderOrder.DESC to retrieve the newest payments first. It showcases method chaining by calling '.execute()' after setting the order. ```dart // Get newest payments first var payments = await sdk.payments .order(RequestBuilderOrder.DESC) .execute(); ``` -------------------------------- ### GET /getLedgers Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/SorobanServer/getLedgers Retrieves a paginated list of ledgers with detailed information. This method returns comprehensive ledger data including headers and metadata starting from a specified sequence. Use this to analyze ledger progression, track protocol changes, or audit blockchain state transitions over time. ```APIDOC ## GET /getLedgers ### Description Retrieves a paginated list of ledgers with detailed information. This method returns comprehensive ledger data including headers and metadata starting from a specified sequence. Use this to analyze ledger progression, track protocol changes, or audit blockchain state transitions over time. Each ledger represents a snapshot of the entire blockchain state at a specific point in time. Ledgers close approximately every 5 seconds on the Stellar network. The returned data is subject to the RPC server's retention window. Ledgers outside this window are no longer available through this endpoint. ### Method GET ### Endpoint /getLedgers ### Parameters #### Query Parameters - **request** (object) - Required - An object containing: - **startLedger** (integer) - Optional - Ledger sequence to start from (inclusive). - **paginationOptions** (object) - Optional - Options for pagination: - **cursor** (string) - Optional - A cursor for fetching the next page of results. - **limit** (integer) - Optional - The maximum number of ledgers to return. #### Request Body This endpoint does not use a request body. All parameters are passed via query parameters or the request object. ### Request Example ```dart final server = SorobanServer('https://soroban-testnet.stellar.org:443'); // Get ledgers starting from sequence 1000 final request = GetLedgersRequest( startLedger: 1000, paginationOptions: PaginationOptions(limit: 100), ); final response = await server.getLedgers(request); if (response.ledgers != null) { for (final ledger in response.ledgers!) { print('Ledger ${ledger.sequence}: ${ledger.hash}'); print('Closed at: ${ledger.ledgerCloseTime}'); // Access ledger header if needed if (ledger.headerXdr != null) { final header = XdrLedgerHeader.fromBase64EncodedXdrString( ledger.headerXdr! ); } } // Paginate to next set of ledgers if (response.cursor != null) { final nextRequest = GetLedgersRequest( paginationOptions: PaginationOptions(cursor: response.cursor), ); } } ``` ### Response #### Success Response (200) - **ledgers** (array) - List of LedgerInfo objects with full ledger details. - **latestLedger** (integer) - Latest ledger sequence known to the server. - **latestLedgerCloseTime** (integer) - Unix timestamp of latest ledger close. - **oldestLedger** (integer) - Oldest ledger available in retention window. - **oldestLedgerCloseTime** (integer) - Unix timestamp of oldest ledger close. - **cursor** (string) - Pagination cursor for next page of results. **LedgerInfo Object:** - **hash** (string) - Ledger hash as hex-encoded string. - **sequence** (integer) - Ledger sequence number. - **ledgerCloseTime** (integer) - Unix timestamp when ledger closed. - **headerXdr** (string) - Base64-encoded ledger header (if available). - **metadataXdr** (string) - Base64-encoded ledger metadata (if available). #### Response Example ```json { "ledgers": [ { "hash": "0000000000000000000000000000000000000000000000000000000000000000", "sequence": 1000, "ledgerCloseTime": 1678886400, "headerXdr": "AAAA...", "metadataXdr": "BBBB..." } ], "latestLedger": 1500, "latestLedgerCloseTime": 1678887000, "oldestLedger": 500, "oldestLedgerCloseTime": 1678880000, "cursor": "some_cursor_string" } ``` #### Error Response - **Exception**: If startLedger is outside retention window or request fails. ``` -------------------------------- ### XdrManageBuyOfferOp Constructors and Properties Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrManageBuyOfferOp-class Details on how to instantiate XdrManageBuyOfferOp and access its properties. ```APIDOC ## XdrManageBuyOfferOp Class ### Description Represents an operation to manage a buy offer in the Stellar network. ### Constructor `XdrManageBuyOfferOp(XdrAsset _selling, XdrAsset _buying, XdrBigInt64 _amount, XdrPrice _price, XdrUint64 _offerID)` Initializes a new instance of the `XdrManageBuyOfferOp` class. ### Properties - **amount** (XdrBigInt64) ↔ getter/setter pair: The amount of the offer. - **buying** (XdrAsset) ↔ getter/setter pair: The asset being bought. - **offerID** (XdrUint64) ↔ getter/setter pair: The unique identifier of the offer. - **price** (XdrPrice) ↔ getter/setter pair: The price of the offer. - **selling** (XdrAsset) ↔ getter/setter pair: The asset being sold. - **hashCode** (int) → read-only: The hash code for this object. - **runtimeType** (Type) → read-only: A representation of the runtime type of the object. ### Methods - **noSuchMethod(Invocation invocation)** → dynamic: Invoked when a nonexistent method or property is accessed (inherited). - **toString()** → String: Returns a string representation of this object (inherited). ### Operators - **operator ==(Object other)** → bool: The equality operator (inherited). ### Static Methods - **decode(XdrDataInputStream stream)** → XdrManageBuyOfferOp: Decodes a `XdrManageBuyOfferOp` from an input stream. - **encode(XdrDataOutputStream stream, XdrManageBuyOfferOp encodedManageOfferOp)** → void: Encodes a `XdrManageBuyOfferOp` to an output stream. ``` -------------------------------- ### Initialize and Use SEP38QuoteService in Dart Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/SEP38QuoteService-class Demonstrates how to initialize the SEP38QuoteService from a domain, retrieve available assets, get an indicative price, and request a firm quote. This example utilizes the Dart SDK for interacting with the SEP-38 API. ```dart // Initialize from stellar.toml SEP38QuoteService quotes = await SEP38QuoteService.fromDomain( "example.com" ); // Get available assets SEP38InfoResponse info = await quotes.info(); // Get indicative price SEP38PriceResponse price = await quotes.price( context: "sep6", sellAsset: "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5", buyAsset: "iso4217:USD", sellAmount: "100" ); // Request firm quote SEP38PostQuoteRequest request = SEP38PostQuoteRequest( context: "sep6", sellAsset: "stellar:USDC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5", buyAsset: "iso4217:USD", sellAmount: "100" ); SEP38QuoteResponse quote = await quotes.postQuote(request, jwtToken); ``` -------------------------------- ### Initialize WebAuth from Domain (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/WebAuth/fromDomain Demonstrates how to initialize a `WebAuth` instance by fetching configuration from a domain's `stellar.toml` file. This method automatically discovers the authentication endpoint and signing key. It requires the domain name and the Stellar network as parameters. ```dart final webAuth = await WebAuth.fromDomain( 'testanchor.stellar.org', Network.TESTNET, ); // Then use for authentication final userKeyPair = KeyPair.fromSecretSeed('S...'); final token = await webAuth.jwtToken(userKeyPair.accountId, [userKeyPair]); ``` ```dart try { final webAuth = await WebAuth.fromDomain('example.com', Network.PUBLIC); } on NoWebAuthEndpointFoundException catch (e) { print('Domain does not support WebAuth: ${e.domain}'); } catch (e) { print('Failed to initialize WebAuth: $e'); } ``` ```dart static Future fromDomain( String domain, Network network, { http.Client? httpClient, Map? httpRequestHeaders, }) async { final StellarToml toml = await StellarToml.fromDomain( domain, httpClient: httpClient, httpRequestHeaders: httpRequestHeaders, ); if (toml.generalInformation.webAuthEndpoint == null) { throw NoWebAuthEndpointFoundException(domain); } if (toml.generalInformation.signingKey == null) { throw NoWebAuthServerSigningKeyFoundException(domain); } return new WebAuth(toml.generalInformation.webAuthEndpoint!, network, toml.generalInformation.signingKey!, domain, httpClient: httpClient, httpRequestHeaders: httpRequestHeaders); } ``` -------------------------------- ### Setting Account Flags with SetOptionsOperation Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/AccountFlag-class Demonstrates how to set various account flags using SetOptionsOperation in Dart. These examples show common regulated asset setups, enabling clawback, and making an account immutable. Flags are combined using bitwise OR operations. ```dart // Common regulated asset setup SetOptionsOperation regulated = SetOptionsOperationBuilder() .setSetFlags( AccountFlag.AUTH_REQUIRED_FLAG.value | AccountFlag.AUTH_REVOCABLE_FLAG.value ) .build(); // Enable clawback for compliance SetOptionsOperation clawback = SetOptionsOperationBuilder() .setSetFlags(AccountFlag.AUTH_CLAWBACK_ENABLED_FLAG.value) .build(); // Make account immutable (permanent) SetOptionsOperation immutable = SetOptionsOperationBuilder() .setSetFlags(AccountFlag.AUTH_IMMUTABLE_FLAG.value) .build(); ``` -------------------------------- ### Retrieve Paginated Ledgers with Stellar SDK Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/SorobanServer/getLedgers Demonstrates how to use the getLedgers method to fetch a paginated list of ledgers from the Stellar network. It shows how to create a request, process the response, access ledger details, and handle pagination. This example requires the SorobanServer and related request/response objects from the SDK. ```dart final server = SorobanServer('https://soroban-testnet.stellar.org:443'); // Get ledgers starting from sequence 1000 final request = GetLedgersRequest( startLedger: 1000, paginationOptions: PaginationOptions(limit: 100), ); final response = await server.getLedgers(request); if (response.ledgers != null) { for (final ledger in response.ledgers!) { print('Ledger ${ledger.sequence}: ${ledger.hash}'); print('Closed at: ${ledger.ledgerCloseTime}'); // Access ledger header if needed if (ledger.headerXdr != null) { final header = XdrLedgerHeader.fromBase64EncodedXdrString( ledger.headerXdr! ); } } // Paginate to next set of ledgers if (response.cursor != null) { final nextRequest = GetLedgersRequest( paginationOptions: PaginationOptions(cursor: response.cursor), ); } } ``` -------------------------------- ### XdrConfigSettingContractBandwidthV0 Constructor Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrConfigSettingContractBandwidthV0-class Initializes a new instance of the XdrConfigSettingContractBandwidthV0 class. ```APIDOC ## Constructor XdrConfigSettingContractBandwidthV0 ### Description Initializes a new instance of the XdrConfigSettingContractBandwidthV0 class. ### Parameters - **_ledgerMaxTxsSizeBytes** (XdrUint32) - Description of ledgerMaxTxsSizeBytes - **_txMaxSizeBytes** (XdrUint32) - Description of txMaxSizeBytes - **_feeTxSize1KB** (XdrInt64) - Description of feeTxSize1KB ``` -------------------------------- ### Creating Prices Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/Price-class Demonstrates various methods for creating Price objects, including direct fraction creation and approximation from strings. ```APIDOC ## Creating Prices ### Direct Creation with Fraction ```dart // Direct creation with fraction Price price1 = Price(100, 1); // 100/1 = 100 Price price2 = Price(1, 2); // 1/2 = 0.5 Price price3 = Price(355, 113); // ~3.14159 (approximation of pi) ``` ### From String (Approximates to Fraction) ```dart // From string (approximates to fraction) Price price4 = Price.fromString("1.5"); // May become 3/2 Price price5 = Price.fromString("0.333"); // Approximates 1/3 ``` ### Exact Representation Preferred ```dart // Exact representation preferred for precision Price exactHalf = Price(1, 2); // Better than fromString("0.5") ``` ``` -------------------------------- ### Initialize StellarSDK with Public Instance (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/StellarSDK/PUBLIC Demonstrates how to initialize the StellarSDK using the pre-configured PUBLIC instance for the Stellar production network. This instance is suitable for real transactions on the mainnet and connects to the public Horizon instance at https://horizon.stellar.org. ```dart StellarSDK sdk = StellarSDK.PUBLIC; ``` -------------------------------- ### Get Soroban RPC Version Info (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/SorobanServer/getVersionInfo Demonstrates how to use the getVersionInfo method to retrieve version details from a Soroban RPC server. It shows how to instantiate the server, call the method, and print key information like RPC version, protocol version, Captive Core version, and build time. This example requires the SorobanServer class and assumes a running RPC server. ```dart final server = SorobanServer('https://soroban-testnet.stellar.org:443'); final versionInfo = await server.getVersionInfo(); print('RPC Version: ${versionInfo.version}'); print('Protocol Version: ${versionInfo.protocolVersion}'); print('Captive Core: ${versionInfo.captiveCoreVersion}'); print('Build Time: ${versionInfo.buildTimeStamp}'); ``` -------------------------------- ### XdrCreateAccountOp Class Documentation Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrCreateAccountOp-class Provides detailed information about the XdrCreateAccountOp class, which is used to represent the operation of creating an account in the Stellar network. ```APIDOC ## XdrCreateAccountOp Class ### Description Represents the operation to create a new Stellar account. ### Constructor #### `XdrCreateAccountOp(XdrAccountID _destination, XdrBigInt64 _startingBalance)` Creates a new `XdrCreateAccountOp` instance. ### Properties #### `destination` ↔ `XdrAccountID` Gets or sets the destination account ID for the new account. #### `hashCode` → `int` Returns the hash code for this object. (Inherited) #### `runtimeType` → `Type` A representation of the runtime type of the object. (Inherited) #### `startingBalance` ↔ `XdrBigInt64` Gets or sets the starting balance for the new account. ### Methods #### `noSuchMethod(Invocation invocation) → dynamic` Invoked when a nonexistent method or property is accessed. (Inherited) #### `toString() → String` Returns a string representation of this object. (Inherited) ### Operators #### `operator ==(Object other) → bool` The equality operator. (Inherited) ### Static Methods #### `decode(XdrDataInputStream stream) → XdrCreateAccountOp` Decodes an `XdrCreateAccountOp` object from an input stream. #### `encode(XdrDataOutputStream stream, XdrCreateAccountOp encodedCreateAccountOp) → void` Encodes an `XdrCreateAccountOp` object to an output stream. ``` -------------------------------- ### MemoHash Usage Example Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/MemoHash-class Example code demonstrating how to create and use MemoHash objects. ```APIDOC ## Example ```dart // From byte array Uint8List hash = Uint8List.fromList([/* 32 bytes */]); MemoHash memo = MemoHash(hash); // From hex string MemoHash memo2 = MemoHash.string("a1b2c3d4..."); // Access hash data Uint8List? data = memo.bytes; String? hexValue = memo.hexValue; ``` ``` -------------------------------- ### Example Usage of Root Method (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/StellarSDK/root Demonstrates how to call the `root` method from the Stellar Flutter SDK and access the returned server information. After fetching the `RootResponse`, you can print details like the network passphrase and protocol version. ```dart RootResponse rootInfo = await sdk.root(); print("Network passphrase: ${rootInfo.networkPassphrase}"); print("Protocol version: ${rootInfo.protocolVersion}"); ``` -------------------------------- ### Creating Price Objects in Dart Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/Price-class Demonstrates various ways to create Price objects, including direct fraction initialization and conversion from strings. Emphasizes direct fraction creation for precision. ```dart // Direct creation with fraction Price price1 = Price(100, 1); // 100/1 = 100 Price price2 = Price(1, 2); // 1/2 = 0.5 Price price3 = Price(355, 113); // ~3.14159 (approximation of pi) // From string (approximates to fraction) Price price4 = Price.fromString("1.5"); // May become 3/2 Price price5 = Price.fromString("0.333"); // Approximates 1/3 // Exact representation preferred for precision Price exactHalf = Price(1, 2); // Better than fromString("0.5") ``` -------------------------------- ### SorobanClient - Install Contract Code Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/SorobanClient-class Installs contract WebAssembly (Wasm) code onto the Soroban network. ```APIDOC ## POST /contracts/install ### Description Installs contract WebAssembly (Wasm) code onto the Soroban network. This is the first step in deploying a new contract. ### Method POST ### Endpoint `/contracts/install` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **wasmBytes** (bytes) - Required - The Wasm bytecode of the contract. - **sourceAccountKeyPair** (KeyPair) - Required - The key pair of the account paying for the transaction. - **network** (Network) - Required - The Soroban network to install the contract on (e.g., TESTNET, FUTURENET). - **rpcUrl** (string) - Required - The URL of the Soroban RPC endpoint. ### Request Example ```json { "wasmBytes": "base64_encoded_wasm_bytes", "sourceAccountKeyPair": { "publicKey": "...", "secretSeed": "..." }, "network": "TESTNET", "rpcUrl": "https://soroban-testnet.stellar.org:443" } ``` ### Response #### Success Response (200) - **wasmHash** (string) - The hash of the installed contract Wasm code. #### Response Example ```json { "wasmHash": "some_wasm_hash" } ``` ``` -------------------------------- ### MuxedAccount Example Usage Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/MuxedAccount-class Code examples demonstrating how to create and use MuxedAccount objects in various scenarios, including transaction building. ```APIDOC ## Example ```dart // Create from standard account (no multiplexing) MuxedAccount account1 = MuxedAccount("GDJK...", null); // Create with ID for multiplexing MuxedAccount account2 = MuxedAccount("GDJK...", BigInt.from(12345)); // Parse from M... address MuxedAccount? account3 = MuxedAccount.fromAccountId("MAAAAA..."); // Use in transactions Transaction tx = TransactionBuilder(sourceAccount) .addOperation( PaymentOperationBuilder( account2.accountId, // Uses M... address Asset.native(), "100" ).build() ) .build(); ``` **Important notes:** * The underlying Ed25519 account must exist on the ledger * The ID is only used for routing within applications * Not all operations support muxed accounts ``` -------------------------------- ### Example: Load Contract Code by Wasm ID (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/SorobanServer/loadContractCodeForWasmId An example demonstrating how to use the loadContractCodeForWasmId method in the Stellar Flutter SDK. It initializes a SorobanServer, specifies a Wasm ID, calls the method, and processes the returned contract code entry. This example shows how to access the raw WebAssembly bytecode from the entry. ```dart final server = SorobanServer('https://soroban-testnet.stellar.org:443'); final wasmId = 'f3b5...'; // hex-encoded wasm hash final codeEntry = await server.loadContractCodeForWasmId(wasmId); if (codeEntry != null) { final wasmBytes = codeEntry.code.dataValue; print('Contract bytecode size: ${wasmBytes.length} bytes'); // Can parse bytecode to extract contract metadata } ``` -------------------------------- ### XdrSCSpecEntryKind Class Overview Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrSCSpecEntryKind-class Provides a comprehensive overview of the XdrSCSpecEntryKind class, detailing its constructors, properties, methods, operators, static methods, and constants. ```APIDOC ## XdrSCSpecEntryKind Class ### Description Represents a kind of specification entry within the XDR data stream, likely used for encoding and decoding structured data. ### Constructors #### XdrSCSpecEntryKind(dynamic _value) - **_value** (dynamic) - The internal value representing the entry kind. ### Properties #### hashCode → int - **Description**: The hash code for this object. - **Setter**: No setter - **Inherited**: override #### runtimeType → Type - **Description**: A representation of the runtime type of the object. - **Setter**: No setter - **Inherited**: inherited #### value → dynamic - **Description**: The dynamic value of the entry kind. - **Setter**: No setter ### Methods #### noSuchMethod(Invocation invocation) → dynamic - **Description**: Invoked when a nonexistent method or property is accessed. - **Inherited**: inherited #### toString() → String - **Description**: A string representation of this object. - **Inherited**: override ### Operators #### operator ==(Object other) → bool - **Description**: The equality operator. - **Inherited**: override ### Static Methods #### decode(XdrDataInputStream stream) → XdrSCSpecEntryKind - **Description**: Decodes an XdrSCSpecEntryKind from the provided XdrDataInputStream. - **Parameters**: - **stream** (XdrDataInputStream) - The input stream to decode from. #### encode(XdrDataOutputStream stream, XdrSCSpecEntryKind value) → void - **Description**: Encodes the given XdrSCSpecEntryKind value to the provided XdrDataOutputStream. - **Parameters**: - **stream** (XdrDataOutputStream) - The output stream to encode to. - **value** (XdrSCSpecEntryKind) - The value to encode. ### Constants #### SC_SPEC_ENTRY_EVENT_V0 → const XdrSCSpecEntryKind - **Description**: Constant representing the "event" specification entry kind, version 0. #### SC_SPEC_ENTRY_FUNCTION_V0 → const XdrSCSpecEntryKind - **Description**: Constant representing the "function" specification entry kind, version 0. #### SC_SPEC_ENTRY_UDT_ENUM_V0 → const XdrSCSpecEntryKind - **Description**: Constant representing the "UDT enum" specification entry kind, version 0. #### SC_SPEC_ENTRY_UDT_ERROR_ENUM_V0 → const XdrSCSpecEntryKind - **Description**: Constant representing the "UDT error enum" specification entry kind, version 0. #### SC_SPEC_ENTRY_UDT_STRUCT_V0 → const XdrSCSpecEntryKind - **Description**: Constant representing the "UDT struct" specification entry kind, version 0. #### SC_SPEC_ENTRY_UDT_UNION_V0 → const XdrSCSpecEntryKind - **Description**: Constant representing the "UDT union" specification entry kind, version 0. ``` -------------------------------- ### XdrHostFunction Static Methods for Contract Creation Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrHostFunction-class Demonstrates the static methods available in XdrHostFunction for creating smart contracts. These methods abstract the process of preparing contract creation arguments for different versions and scenarios. ```dart static XdrHostFunction forCreatingContract(XdrSCAddress address, XdrUint256 salt, String wasmId) { // Implementation details... } static XdrHostFunction forCreatingContractV2(XdrSCAddress address, XdrUint256 salt, String wasmId, List constructorArgs) { // Implementation details... } static XdrHostFunction forCreatingContractV2WithArgs(XdrCreateContractArgsV2 args) { // Implementation details... } static XdrHostFunction forCreatingContractWithArgs(XdrCreateContractArgs args) { // Implementation details... } ``` -------------------------------- ### Get MuxedAccount 'from' Property (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/ClawbackOperation/from Retrieves the MuxedAccount from which an asset is clawed back. This is a getter method within the MuxedAccount class. ```dart MuxedAccount get from => _from; ``` -------------------------------- ### Initialize Stellar SDK with FUTURENET Instance (Java) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/StellarSDK/FUTURENET Demonstrates how to initialize the Stellar SDK using the pre-configured FUTURENET instance. This instance points to the future network endpoint for testing new protocol features. ```java StellarSDK sdk = StellarSDK.FUTURENET; ``` -------------------------------- ### Get Operations Count - Dart Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/TransactionBuilder/operationsCount This snippet shows how to get the number of operations currently managed by the SDK. It accesses the length of the internal operations list. ```dart int get operationsCount => _mOperations.length; ``` -------------------------------- ### Example Usage of SEP24InfoResponse Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/SEP24InfoResponse-class Demonstrates how to fetch and process SEP24 info response to check deposit asset availability. This example assumes an initialized 'sep24' object. ```dart final info = await sep24.info(); print('Supported deposit assets: ${info.depositAssets?.keys}'); if (info.depositAssets?['USD']?.enabled == true) { print('USD deposits enabled'); } ``` -------------------------------- ### Initialize Documentation Constructor Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/Documentation/Documentation Demonstrates the initialization of the Documentation constructor. This is a fundamental step for utilizing documentation features within the SDK. ```dart Documentation() ``` -------------------------------- ### Example Usage of Execute Method (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/OperationsRequestBuilder/execute Demonstrates how to use the execute method to fetch operations for a Stellar account. It shows how to set a limit, iterate through the returned records, and fetch the next page of results using the paging token. This example requires an initialized SDK instance. ```dart final page = await sdk.operations.forAccount('account_id').limit(20).execute(); for (var operation in page.records) { print('Operation type: ${operation.type}'); } // Get next page if (page.links.next != null) { final nextPage = await sdk.operations.forAccount('account_id').cursor(page.records.last.pagingToken).execute(); } ``` -------------------------------- ### Get XdrHostFunctionType Property (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrHostFunction/type This code snippet demonstrates how to get the value of the XdrHostFunctionType property. It accesses a private variable `_type` to return the current type. ```dart XdrHostFunctionType get type => this._type; ``` -------------------------------- ### Get allowTrustResult Property (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrOperationResultTr/allowTrustResult This code snippet demonstrates how to get the value of the allowTrustResult property. It returns an XdrAllowTrustResult object or null if not set. This is a simple getter method. ```dart XdrAllowTrustResult? get allowTrustResult => this._allowTrustResult; ``` -------------------------------- ### WebAuth fromDomain Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/WebAuth/fromDomain Initializes a WebAuth instance by automatically discovering configuration from a stellar.toml file hosted on the specified domain. This is the recommended method for initializing WebAuth. ```APIDOC ## POST /websites/pub_dev_stellar_sdk/fromDomain ### Description Creates a WebAuth instance by automatically discovering configuration from stellar.toml. This method fetches the stellar.toml file from the specified domain and extracts the WEB_AUTH_ENDPOINT and SIGNING_KEY. ### Method POST ### Endpoint /websites/pub_dev_stellar_sdk/fromDomain ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **domain** (String) - Required - The domain name (without protocol) hosting the stellar.toml file. - **network** (Network) - Required - The Stellar network (Network.PUBLIC or Network.TESTNET). - **httpClient** (Client) - Optional - Custom HTTP client for testing or proxy configuration. - **httpRequestHeaders** (Map) - Optional - Custom HTTP headers for requests. ### Request Example ```json { "domain": "testanchor.stellar.org", "network": "Network.TESTNET", "httpClient": null, "httpRequestHeaders": {} } ``` ### Response #### Success Response (200) - **WebAuth** (WebAuth) - An initialized WebAuth instance. #### Response Example ```json { "webAuthInstance": "" } ``` ### Throws - **NoWebAuthEndpointFoundException**: If WEB_AUTH_ENDPOINT is missing from stellar.toml. - **NoWebAuthServerSigningKeyFoundException**: If SIGNING_KEY is missing from stellar.toml. - **Exception**: If stellar.toml cannot be fetched or parsed. ``` -------------------------------- ### Memo Constructor Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/Memo/Memo Explains the abstract base class constructor for Memo and how to create concrete instances. ```APIDOC ## Memo() ### Description Creates a Memo instance. This is an abstract base class constructor. Use factory methods to create concrete memo instances: none, text, id, hash, or returnHash. ### Method Constructor ### Endpoint N/A ### Parameters None ### Request Example N/A ### Response #### Success Response (200) - **Memo** (Object) - An instance of the Memo class. #### Response Example ```dart Memo(); ``` ``` -------------------------------- ### Get ext Property - Dart Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrOfferEntry/ext This code snippet shows how to get the 'ext' property from an XdrOfferEntry object. It accesses a private member '_ext' to return the extension data. ```dart XdrOfferEntryExt get ext => this._ext; ``` -------------------------------- ### Instantiate XdrSCSpecUDTUnionCaseTupleV0 Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrSCSpecUDTUnionCaseTupleV0-class Constructs a new XdrSCSpecUDTUnionCaseTupleV0 object. Requires a document string, a name string, and a list of XdrSCSpecTypeDef objects. ```dart XdrSCSpecUDTUnionCaseTupleV0(String _doc, String _name, List _type) ``` -------------------------------- ### Get returnValue Property - Dart Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrInvokeHostFunctionSuccessPreImage/returnValue This code snippet demonstrates how to get the value of the 'returnValue' property. It accesses a private variable '_returnValue' to return the current SCVal. ```dart XdrSCVal get returnValue => this._returnValue; ``` -------------------------------- ### Get Type Property - Dart Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/URISchemeError/type This snippet shows how to get the 'type' property from a class in Dart. It utilizes a private variable '_type' and exposes it through a public getter. ```dart int get type => _type; ``` -------------------------------- ### XdrSCEnvMetaEntry Static Methods Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrSCEnvMetaEntry-class Details about the static methods available for the XdrSCEnvMetaEntry class. ```APIDOC ## XdrSCEnvMetaEntry Static Methods ### decode(XdrDataInputStream stream) → XdrSCEnvMetaEntry **Description**: Decodes an XdrSCEnvMetaEntry from the provided stream. **Parameters**: #### Path Parameters - **stream** (XdrDataInputStream) - Required - The stream to decode from. ### encode(XdrDataOutputStream stream, XdrSCEnvMetaEntry encoded) → void **Description**: Encodes the given XdrSCEnvMetaEntry to the provided stream. **Parameters**: #### Path Parameters - **stream** (XdrDataOutputStream) - Required - The stream to encode to. - **encoded** (XdrSCEnvMetaEntry) - Required - The entry to encode. ``` -------------------------------- ### Get PaymentsRequestBuilder - Dart Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/StellarSDK/payments This code snippet demonstrates how to access the 'payments' property to get a new PaymentsRequestBuilder instance. This builder is used for constructing and sending payment-related requests. ```dart PaymentsRequestBuilder get payments => PaymentsRequestBuilder(httpClient, _serverURI); ``` -------------------------------- ### Initialize Stellar SDK and Query Account (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/index This Dart code demonstrates how to import the Stellar SDK, initialize it for the testnet, and then query account details using an account ID. It prints the account's sequence number. ```dart 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}"); ``` -------------------------------- ### Get Discriminant Property (Dart) Source: https://pub.dev/documentation/stellar_flutter_sdk/latest/stellar_flutter_sdk/XdrPathPaymentStrictSendResult/discriminant This code snippet demonstrates how to get the discriminant property from an object in the Stellar Flutter SDK. It returns the current value of the discriminant, which is of type XdrPathPaymentStrictSendResultCode. ```dart XdrPathPaymentStrictSendResultCode get discriminant => this._code; ```