{"id":15554995,"url":"https://github.com/mrtnetwork/xrpl_dart","last_synced_at":"2025-04-23T20:25:26.093Z","repository":{"id":194087758,"uuid":"690034754","full_name":"mrtnetwork/xrpl_dart","owner":"mrtnetwork","description":"Effortlessly sign, create, and send all XRP transaction types using the xrpl_dart package. Securely manage your XRP Ledger transactions with ease","archived":false,"fork":false,"pushed_at":"2025-04-11T19:00:55.000Z","size":59866,"stargazers_count":5,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T20:22:30.243Z","etag":null,"topics":["cross-platform","dart","dart-package","ed25519","secp256k1","xaddress","xrp","xrp-wallet"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrtnetwork.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-11T12:08:04.000Z","updated_at":"2025-04-11T19:00:59.000Z","dependencies_parsed_at":"2023-09-11T16:28:36.195Z","dependency_job_id":"bf563321-d7d9-4677-b885-c7d104d2436b","html_url":"https://github.com/mrtnetwork/xrpl_dart","commit_stats":null,"previous_names":["mohsenhaydari/xrp_dart","mrtnetwork/xrp_dart","mrtnetwork/xrpl_dart"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtnetwork%2Fxrpl_dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtnetwork%2Fxrpl_dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtnetwork%2Fxrpl_dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtnetwork%2Fxrpl_dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrtnetwork","download_url":"https://codeload.github.com/mrtnetwork/xrpl_dart/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250507558,"owners_count":21442022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-platform","dart","dart-package","ed25519","secp256k1","xaddress","xrp","xrp-wallet"],"created_at":"2024-10-02T15:05:34.598Z","updated_at":"2025-04-23T20:25:26.067Z","avatar_url":"https://github.com/mrtnetwork.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XRPL Dart Package\n\nThis package offers comprehensive functionality for signing XRP transactions using two prominent cryptographic algorithms, ED25519 and SECP256K1. Beyond transaction signing, it provides support for various features, including JSON-RPC, socket, and HTTP interactions. This versatility empowers developers to securely create, sign, and interact with XRP transactions.\n\nFor BIP32 HD wallet, BIP39, and Secret storage definitions, please refer to the [blockchain_utils](https://github.com/mrtnetwork/blockchain_utils) package.\n\n## Features\n\n### Transaction Types\n\nThe XRP Ledger accommodates a diverse range of transaction types, each tailored for specific purposes. Some of these are outlined below:\n\n- Payment Transactions: Standard transactions used to send XRP or Issue from one address to another.\n- Escrow Transactions: These transactions lock up XRP until certain conditions are met, providing a trustless way to facilitate delayed payments.\n- TrustSet Transactions: Used to create or modify trust lines, enabling users to hold and trade assets other than XRP on the ledger.\n- OrderBook Transactions: Used to place and cancel offers on the decentralized exchange within the XRP Ledger.\n- PaymentChannel Transactions: Allow for off-chain payments using payment channels.\n- NFT: Mint NFTs, cancel them, create offers, and seamlessly accept NFT offers.\n- Issue: Issue custom assets.\n- Automated Market Maker: Operations like bidding, creation, deletion, deposits, and voting.\n- RegularKey: Transactions to set or update account regular keys.\n- Offer: Creation and cancellation.\n- Multi-signature Transaction: Transactions requiring multiple signatures for validation.\n- XChainAccountCreateCommit: Creates a new account on one of the chains a bridge connects.\n- XChainAddAccountCreateAttestation: Transaction provides an attestation from a witness server that an XChainAccountCreateCommit - - transaction occurred on the other chain.\n- XChainAddClaimAttestation: Transaction provides proof from a witness server, attesting to an XChainCommit transaction.\n- XChainClaim: Transaction completes a cross-chain transfer of value.\n- XChainCreateBridge: Transaction creates a new Bridge ledger.\n...\n\n### Addresses\n\n- classAddress: They are straightforward representations of the recipient's address on the XRP Ledger\n- xAddress: newer format, which provides additional features and interoperability. xAddresses include destination tags by default and are designed to simplify cross-network transactions and improve address interoperability\n\n### Sign\n\n- Sign XRP transactions with ED25519 and SECP256K1 algorithms.\n\n### JSON-RPC Support\n\nThis package streamlines communication with XRP nodes using both the JSON-RPC protocol and WebSocket technology. While endeavors have been undertaken to integrate all methods into RPC, it's crucial to acknowledge that, currently, the majority of data APIs are presented in JSON format and haven't been entirely modeled. The addition of WebSocket support enhances the package's versatility for real-time and asynchronous interactions with XRP nodes.\n\n## EXAMPLES\n\nDiscover at least one example for each transaction type in the [examples](https://github.com/mrtnetwork/xrpl_dart/tree/main/example/lib) folder.\n\n### Key and addresses\n\n```dart\n  /// create random privateKey\n  final randomPrivate =\n      XRPPrivateKey.random(algorithm: CryptoAlgorithm.SECP256K1);\n  final toHex = randomPrivate.toHex();\n  \n  /// access private key with hex\n  final private = XRPPrivateKey.fromHex(toHex);\n\n  /// accesss publicKey\n  final publicKey = private.getPublic();\n\n  final addressClass = publicKey.toAddress();\n\n  /// rpjEqWDFtoin7fFxuw6oQG2onkZkf72hhc\n  final classicAddress = addressClass.address;\n\n  /// X7ZBWLX4XnxEwvQa4sgH11QbhQzuTuGeoZKEb2naE92oNEc\n  final xAddress = addressClass.toXAddress(isTestNetwork: false);\n\n  /// sign with privateKey\n  final sig = private.sign(...)\n  \n```\n\n### Transaction\n\nEvery transaction type has a dedicated class for transaction creation.\nDescriptions for some of these classes are outlined below.\nExplore training examples for each transaction type in the examples folder [here](https://github.com/mrtnetwork/xrpl_dart/tree/main/example/lib/examples).\n\n- Simple payment\n  \n  ```dart\n    final transaction = Payment(\n      destination: destination, // destination account\n      account: ownerAddress, // Sender account\n      amount: amount, // The amount sent can be in XRP or any other token.\n      signingPubKey: ownerPublic); // Sender's public key\n\n  ```\n\n- NTF, mint, createOffer, acceptOffer\n\n  ```dart\n  // mint token\n  final transaction = NFTokenMint(\n      flags: NFTokenMintFlag.TF_TRANSFERABLE.value,\n      account: ownerAddress,\n      uri: \"...\", // that points to the data and/or metadata associated with the NFT\n      signingPubKey: ownerPublic,\n      memos: [memo], // Additional arbitrary information attached to this transaction\n      nftokenTaxon: 1); // Indicates the taxon associated with this token\n\n  // create offer\n  final offer = NFTokenCreateOffer(\n    amount: CurrencyAmount.xrp(BigInt.from(1000000)),\n    flags: NFTokenCreateOfferFlag.TF_SELL_NFTOKEN.value,\n    nftokenId: tokenId, /// Identifies the TokenID of the NFToken object that the offer references. \n    account: ownerAddress,\n    signingPubKey: ownerPublic,\n    memos: [memo],\n  );\n  \n  // accept offer\n  final offer = NFTokenAcceptOffer(\n    nfTokenSellOffer: offerId,\n    account: ownerAddress,\n    signingPubKey: ownerPublic,\n    memos: [memo],\n  );\n\n  ```\n\n- Completely create, sign, and send transactions\n\n  ```dart\n  // create escrowCreate transaction\n  final escrowCreate = EscrowCreate(\n    account: ownerAddress,\n    destination: destination,\n    cancelAfterTime: cancelAfterOnDay,\n    finishAfterTime: finishAfterOneHours,\n    amount: BigInt.from(25000000),\n    condition:\n        \"A0258020E488CD4C1AC9A7673CA2D2712B47049B87C308181BF3B89D6FBB74FC36836BB5810120\",\n    signingPubKey: ownerPublic,\n    memos: [memo],\n  );\n\n  // It receives the transaction, the RPC class, and then fulfills the transaction requirements, including the fee amount, account sequence, and the last network ledger sequence.\n  await autoFill(rpc, escrowCreate);\n  \n  // At this point, we need to sign the transaction with the sender's account.\n  // We receive the transaction blob and sign it with the sender's private key.\n  final sig = owner.sign(escrowCreate.toBlob());\n  // After completing the signature, we add it to the transaction.\n  escrowCreate.setSignature(sig);\n\n  /// In the final step, we need to send the transaction to the network.\n  /// We receive another transaction blob that already contains a signature. At this point, we no longer need to include a signature, and we must set the 'forSigning' variable to false.\n  final trBlob = escrowCreate.toBlob(forSigning: false);\n\n  // broadcasting transaction\n  final result = await rpc.submit(trBlob)\n  // transaction hash: result.txJson.hash ()\n  // engine result: result.engineResult result.engineResult\n  // engine result message: result.engineResultMessage\n  \n  ```\n\n### JSON-RPC\n\nCheck out the [http_service](https://github.com/mrtnetwork/xrpl_dart/blob/main/example/lib/socket_rpc_example/http_service.dart) and [socket_service](https://github.com/mrtnetwork/xrpl_dart/blob/main/example/lib/socket_rpc_example/socket_service.dart) files to learn how to create an HTTP/WEBSOCKET RPC service.\n\n- HTTP JSON RPC\n\n```dart\n  /// access devent\n  final rpc = await XRPProvider.devNet((httpUri, websocketUri) async {\n    service = RPCHttpService(httpUri, http.Client());\n    return service!;\n  });\n\n  /// sync\n  final syncRpc = XRPProvider(RPCHttpService(XRPProviderConst.devFaucetUrl, http.Client()));\n  \n  await rpc.request(RPCFee());\n  await rpc.request(RPCServerInfo());\n  await rpc.request(RPCAccountInfo(account: \"...\"));\n  await rpc.request(RPCServerState());\n  await rpc.request(RPCServerDefinitions());\n  ...\n```\n\n- WEBSOCKET JSON RPC\n\n```dart\n  /// access devent\n  final rpc = await XRPProvider.devNet((httpUri, websocketUri) async {\n    service = await RPCWebSocketService.connect(websocketUri);\n    return service!;\n  });\n\n  await rpc.request(RPCFee());\n  await rpc.request(RPCServerInfo());\n  await rpc.request(RPCAccountInfo(account: \"...\"));\n  await rpc.request(RPCServerState());\n  await rpc.request(RPCServerDefinitions());\n  service?.discounnect();\n  ...\n```\n\n- WEBSOCKET Subscribe\n\n```dart\n  /// stream event\n  void onEnvet(Map\u003cString, dynamic\u003e event) {}\n\n  void onClose(Object? err) {}\n\n  /// access devent\n  final rpc = await XRPProvider.mainnet((httpUri, websocketUri) async {\n    service = await RPCWebSocketService.connect(websocketUri,\n        onClose: onClose, onEvents: onEnvet);\n    return service!;\n  });\n\n  /// subscribe\n  await rpc.request(RPCSubscribe(streams: [\n    StreamParameter.ledger,\n  ]));\n  ...\n```\n\n- Tailor the RPC response to your specifications.\n\n```dart\n/// Create a class that inherits from XRPLedgerRequest and customize it for handling Account NFT Offers IDs. Here's an example:\nclass RPCAccountNftOffersIDs extends XRPLedgerRequest\u003cList\u003cString\u003e\u003e {\n  RPCAccountNftOffersIDs({\n    required this.account,\n    this.limit,\n    this.marker,\n    XRPLLedgerIndex? ledgerIndex = XRPLLedgerIndex.validated,\n  });\n  @override\n  String get method =\u003e XRPRequestMethod.accountNfts;\n\n  final String account;\n  final int? limit;\n\n  final dynamic marker;\n\n  @override\n  Map\u003cString, dynamic\u003e toJson() {\n    return {\"account\": account, \"limit\": limit, \"marker\": marker};\n  }\n\n  /// Override the `onResponse` method to manage and handle the desired outcomes from the RPC result as per your requirements.\n  @override\n  List\u003cString\u003e onResonse(Map\u003cString, dynamic\u003e result) {\n    final List\u003cdynamic\u003e nfts = result[\"account_nfts\"];\n    return nfts.map\u003cString\u003e((e) =\u003e e[\"nft_offer_index\"]).toList();\n  }\n  }\n\n  final syncRpc = XRPProvider(RPCHttpService(XRPProviderConst.devFaucetUrl, http.Client()));\n  final List\u003cString\u003e nftOfferIds =\n      await syncRpc.request(RPCAccountNftOffersIDs(account: \"...\"));\n\n  ...\n```\n\n## Contributing\n\nContributions are welcome! Please follow these guidelines:\n\n- Fork the repository and create a new branch.\n- Make your changes and ensure tests pass.\n- Submit a pull request with a detailed description of your changes.\n\n## Feature requests and bugs\n\nPlease file feature requests and bugs in the issue tracker.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrtnetwork%2Fxrpl_dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrtnetwork%2Fxrpl_dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrtnetwork%2Fxrpl_dart/lists"}