{"id":13820386,"url":"https://github.com/EPNW/solana_wallets_flutter","last_synced_at":"2025-05-16T10:30:50.804Z","repository":{"id":54882730,"uuid":"502455786","full_name":"EPNW/solana_wallets_flutter","owner":"EPNW","description":"A flutter plugin to connect to a users wallet like phantom, solflare, etc.","archived":false,"fork":false,"pushed_at":"2023-03-09T17:32:15.000Z","size":3279,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-11-15T22:22:06.982Z","etag":null,"topics":["cryptocurrency","dart","flutter","solana","wallet"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/solana_wallets_flutter","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EPNW.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}},"created_at":"2022-06-11T21:03:46.000Z","updated_at":"2024-06-13T02:25:37.000Z","dependencies_parsed_at":"2024-01-13T16:23:02.722Z","dependency_job_id":"c0dfa19e-fa16-4532-b388-84fa2887f65c","html_url":"https://github.com/EPNW/solana_wallets_flutter","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"4dc2b96bcf6b4f1352f7ceb56ef836a9838ce1f3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EPNW%2Fsolana_wallets_flutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EPNW%2Fsolana_wallets_flutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EPNW%2Fsolana_wallets_flutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EPNW%2Fsolana_wallets_flutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EPNW","download_url":"https://codeload.github.com/EPNW/solana_wallets_flutter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254512402,"owners_count":22083389,"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":["cryptocurrency","dart","flutter","solana","wallet"],"created_at":"2024-08-04T08:01:02.428Z","updated_at":"2025-05-16T10:30:45.786Z","avatar_url":"https://github.com/EPNW.png","language":"Dart","funding_links":[],"categories":["Flutter"],"sub_categories":["Flutter SDK / Libraries"],"readme":"# solana_wallets_flutter\n\nThis plugin allows to connect to the solana wallet of a user in a web browser like [phantom](https://phantom.app/), [solflare](https://solflare.com/), [sollet](https://www.sollet.io/) and many more.\n\nIt wraps and includes solanas official [`@solana/wallet-adapter-wallets`](https://www.npmjs.com/package/@solana/wallet-adapter-wallets). The wallet can then be used to sign transactions directly in flutter. Additionally you can pass the wallet adapter object to JavaScript and to work with it there, while providing all ui in flutter.\n\nCurrently this plugin wraps `@solana/wallet-adapter-wallets` version `0.19.15` and provides access to all wallet adapters included in this version. If there is an other version you want to use, see `tool/README.md` to learn how to build it yourself.\n\n## Theory needed to understand the API doc\nIn flutter web the [`js` package](https://pub.dev/packages/js) can be used to manipulate JavaScript objects what is done by this plugin. We can also use the [`js` package](https://pub.dev/packages/js) to call JavaScript functions. Furthermore there exists objects that are of the `Object` type in flutter, but \"are linked to\" or \"proxy\" a JavaScript object. We can now call a function using the [`js` package](https://pub.dev/packages/js) and use a \"proxied\" object as parameter. The JavaScript function then has access to the \"real\" object. The term \"pass the wallet adapter object to JavaScript\" from above means just that.\n\n## UI\nThe library `solana_wallets_flutter_ui` contains functions to show a dialog where the user can pick the preffered wallet. You don't have to use it and can create your own dialog.\n![](https://raw.githubusercontent.com/EPNW/solana_wallets_flutter/master/example/example.webp)\n\n## Usage\nThese are the usual steps to use this plugin:\n* Call (but not await) `initSolanaWallets` from the `solana_wallets_flutter` library in the `main` method of your project\n* Call `getWalletAdaptersWhenInitalized` from the `solana_wallets_flutter` library to get the adapter list and optionally filter the returned list to exclude adapters you don't want to support in your dApp\n* Call `showWalletSelectDialog` from `solana_wallets_flutter_ui` with the (filtered) adapter list to let the user choose a wallet from a dialog or build your own system to let the user decide on a wallet to use\n* You now have the `BaseWalletAdapter` the user wants to use, call `addListener` on it to watch the `walletState`. IMPORTANT: If you are done with the adapter, call `removeListener` OR YOU MIGHT RUN INTO PERFORMANCE ISSUES!\n* Call `connect` on it, the users browser will open the wallets extension or popup where the users has to accept your dApp\n* The future from `connect` either completes or throws an error. Once it's complete you might want to check `walletState` again to see if you are connected. If you have registered a listener, it should have fired if the `walletState` changed\n* You can now use the `BaseWalletAdapter` in flutter or pass it's `js` property to JavaScript and do stuff with it there\n\n### Usage in JavaScript\nMake sure to read the \"theory\" section above first. All child classes of `Adapter` (which `BaseWalletAdapter` also is) contain a `js` property which is a proxied JavaScript object of the wallet adapter. You can pass this `js` property to JavaScript and used it there, e.g. in conjunction with [anchor](https://github.com/coral-xyz/anchor). There you would use the `js` property as `wallet` parameter to create an [`AnchorProvider`](https://coral-xyz.github.io/anchor/ts/classes/AnchorProvider.html).\n\nHere is some code do summarize this. Assume you loaded the following JavaScript into the browser:\n```javascript\nimport { AnchorProvider } from '@coral-xyz/anchor';\nimport { Connection } from '@solana/web3.js';\n\nfunction doSomething(wallet) {\n    const url = 'https://solana-mainnet.rpc.extrnode.com';\n    const provider = new AnchorProvider(new Connection(url), wallet, {});\n    //do something related to your project with the provider\n}\n\nconst my_project = {\n    'doSomething': doSomething\n};\n\nif (window.dartInteropt == undefined) {\n    window.dartInteropt = new Object();\n}\n\nwindow.dartInteropt.my_project = my_project;\n```\nThen you can interact with it from dart using the `js` property of `Adapter` like:\n```dart\n@JS('window.dartInteropt.my_project')\nlibrary my_project;\n\nimport 'package:js/js.dart';\nimport 'package:solana_wallets_flutter/solana_wallets_flutter.dart';\n\n@JS('doSomething')\nexternal void _doSomething(Object wallet);\n\nvoid main() async {\n  BaseWalletAdapter phantom = await getPhantom();\n  _doSomething(phantom.js);\n}\n\nFuture\u003cBaseWalletAdapter\u003e getPhantom() async {\n    // ...\n    // get the phantom wallet and connect it,\n    // see example/lib/main.dart how to do this!\n}\n```\nTo get a better unterstanding of what's going on here, read the documentation of the [`js` package](https://pub.dev/packages/js).\n\n### Usage in flutter\nThis plugin only provides access to the users wallet, it is out of scope to create or send transactions. The `BaseWalletAdapter` has a `sendTransaction` method, but this is just a proxied JavaScript function and explained in detail in its API documentation (make sure to read the \"theory\" section to understand it), so it might be hard to use this function with \"pure\" flutter (because it requires you to provide a JavaScript `@solana/web3.js/Connection` object). However, you can use a package like [`solana`](https://pub.dev/packages/solana) to create and send transactions, and `solana_wallets_flutter` to sign it using the users wallet. In order to do so you need a `BaseSignerWalletAdapter`. Most adapters returned by `getWalletAdaptersWhenInitalized` are actually of this type (so you can cast them). Then, take a look at `BaseSignerWalletAdapter.signTransaction` and `BaseSignerWalletAdapter.signAllTransactions`. The example also demonstrates this (see `example/lib/transaction_example.dart`).\n\n## Examples\nThe examples folder contains a project demonstrating how to connect a wallet. It also demonstrates how to use the [`solana`](https://pub.dev/packages/solana) dart package to create a transaction, sign it with `solana_wallets_flutter` and send it with the [`solana`](https://pub.dev/packages/solana) package. If you want to see a solana dApp that is written in flutter and uses this plugin, take a look at [NFT-Pixels.io](https://nft-pixels.io).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEPNW%2Fsolana_wallets_flutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEPNW%2Fsolana_wallets_flutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEPNW%2Fsolana_wallets_flutter/lists"}