{"id":13651632,"url":"https://github.com/polkawallet-io/sdk","last_synced_at":"2026-01-12T07:45:42.688Z","repository":{"id":37361160,"uuid":"288364850","full_name":"polkawallet-io/sdk","owner":"polkawallet-io","description":"polkawallet SDK for integrating substrate-based blockchain as a plugin.","archived":false,"fork":false,"pushed_at":"2024-03-18T10:57:56.000Z","size":178047,"stargazers_count":18,"open_issues_count":7,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-18T12:10:44.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/polkawallet-io.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}},"created_at":"2020-08-18T05:39:22.000Z","updated_at":"2024-04-15T00:40:53.692Z","dependencies_parsed_at":"2024-03-18T12:03:14.039Z","dependency_job_id":"bfefa15a-6225-4b2e-a250-137ddb459b69","html_url":"https://github.com/polkawallet-io/sdk","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polkawallet-io%2Fsdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polkawallet-io%2Fsdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polkawallet-io%2Fsdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polkawallet-io%2Fsdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/polkawallet-io","download_url":"https://codeload.github.com/polkawallet-io/sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250333987,"owners_count":21413488,"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":[],"created_at":"2024-08-02T02:00:51.089Z","updated_at":"2026-01-12T07:45:42.655Z","avatar_url":"https://github.com/polkawallet-io.png","language":"Dart","funding_links":[],"categories":["Mobile"],"sub_categories":[],"readme":"# sdk\npolkawallet SDK for integrating substrate-based blockchain as a plugin.\n\n# Building a polkawallet_plugin dart package.\n\n## 1. Create your plugin repo\n\ncreate a dart package\n```shell\nflutter create --template=package polkwalllet_plugin_acala\ncd polkwalllet_plugin_acala/\n```\nadd dependencies in pubspec.yaml\n```yaml\ndependencies:\n  polkawallet_sdk: ^0.1.2\n```\nand install the dependencies.\n```shell\nflutter pub get\n```\n\n## 2. Build your polkadot-js wrapper\n\nThe App use a `polkadot-js/api` instance running in a hidden webView\nto connect to remote node.\n\nExamples:\n - kusama/polkadot: [https://github.com/polkawallet-io/js_api](https://github.com/polkawallet-io/js_api)\n - acala: [https://github.com/polkawallet-io/polkawallet_plugin_acala/tree/master/lib/js_service_acala](https://github.com/polkawallet-io/polkawallet_plugin_acala/tree/master/lib/js_service_acala)\n - laminar: [https://github.com/polkawallet-io/polkawallet_plugin_laminar/tree/master/lib/polkawallet_plugin_laminar](https://github.com/polkawallet-io/polkawallet_plugin_laminar/tree/master/lib/polkawallet_plugin_laminar)\n\n## 3. Implement your plugin class\n\nModify the plugin entry file(eg. polkwalllet_plugin_acala.dart),\ncreate a `PluginFoo` class extending `PolkawalletPlugin`:\n```dart\nclass PluginAcala extends PolkawalletPlugin {\n  /// define your own plugin\n}\n```\n\n#### 3.1. override `PolkawalletPlugin.basic`\n```dart\n  @override\n  final basic = PluginBasicData(\n    name: 'acala',\n    ss58: 42,\n    primaryColor: Colors.deepPurple,\n    gradientColor: Colors.blue,\n    // The `bg.png` will be displayed as texture on a block with theme color,\n    // so it should have a transparent or dark background color.\n    backgroundImage: AssetImage('packages/polkawallet_plugin_acala/assets/images/bg.png'),\n    icon:\n        Image.asset('packages/polkawallet_plugin_acala/assets/images/logo.png'),\n    // The `logo_gray.png` should have a gray color `#9e9e9e`.\n    iconDisabled: Image.asset(\n        'packages/polkawallet_plugin_acala/assets/images/logo_gray.png'),\n    isTestNet: false,\n  );\n```\n\n#### 3.2. override `PolkawalletPlugin.tokenIcons`\nDefine the icon widgets so the Polkawallet App can display tokens\nof your para-chain with token icons.\n```dart\n  @override\n  final Map\u003cString, Widget\u003e tokenIcons = {\n    'KSM': Image.asset(\n        'packages/polkawallet_plugin_kusama/assets/images/tokens/KSM.png'),\n    'DOT': Image.asset(\n        'packages/polkawallet_plugin_kusama/assets/images/tokens/DOT.png'),\n  };\n```\n\n#### 3.3. override `PolkawalletPlugin.nodeList`\n\n```dart\nconst node_list = [\n  {\n    'name': 'Mandala TC5 Node 1 (Hosted by OnFinality)',\n    'ss58': 42,\n    'endpoint': 'wss://node-6714447553777491968.jm.onfinality.io/ws',\n  },\n];\n```\n```dart\n  @override\n  List\u003cNetworkParams\u003e get nodeList {\n    return node_list.map((e) =\u003e NetworkParams.fromJson(e)).toList();\n  }\n```\n\n#### 3.4. override `PolkawalletPlugin.getNavItems(BuildContext, Keyring)`\nDefine your custom navigation-item in `BottomNavigationBar` of Polkawallet App.\nThe `HomeNavItem.content` is the page content widget displayed while your navItem was selected.\n```dart\n  @override\n  List\u003cHomeNavItem\u003e getNavItems(BuildContext context, Keyring keyring) {\n    return [\n      HomeNavItem(\n        text: 'Acala',\n        icon: SvgPicture.asset(\n          'packages/polkawallet_plugin_acala/assets/images/logo.svg',\n          color: Theme.of(context).disabledColor,\n        ),\n        iconActive: SvgPicture.asset(\n            'packages/polkawallet_plugin_acala/assets/images/logo.svg'),\n        content: AcalaEntry(this, keyring),\n      )\n    ];\n  }\n```\n\n#### 3.5. override `PolkawalletPlugin.getRoutes(Keyring)`\nDefine navigation route for your plugin pages.\n```dart\n  @override\n  Map\u003cString, WidgetBuilder\u003e getRoutes(Keyring keyring) {\n    return {\n      TxConfirmPage.route: (_) =\u003e\n          TxConfirmPage(this, keyring, _service.getPassword),\n      CurrencySelectPage.route: (_) =\u003e CurrencySelectPage(this),\n      AccountQrCodePage.route: (_) =\u003e AccountQrCodePage(this, keyring),\n\n      TokenDetailPage.route: (_) =\u003e TokenDetailPage(this, keyring),\n      TransferPage.route: (_) =\u003e TransferPage(this, keyring),\n\n      // other pages\n      // ...\n    };\n  }\n```\n\n#### 3.6. override `PolkawalletPlugin.loadJSCode()` method\nLoad the `polkadot-js/api` wrapper you built in step 2.\n```dart\n  @override\n  Future\u003cString\u003e loadJSCode() =\u003e rootBundle.loadString(\n      'packages/polkawallet_plugin_acala/lib/js_service_acala/dist/main.js');\n```\n\n#### 3.7. override plugin life-circle methods\n - onWillStart(), you may want to prepare your plugin state data here.\n - onStarted(), remote node connected, you may fetch data from network.\n - onAccountChanged(), user just changed account, you may clear\n cache of the prev account and query data for new account.\n\nExamples:\n - [kusama/polkadot](https://github.com/polkawallet-io/polkawallet_plugin_kusama/blob/master/lib/polkawallet_plugin_kusama.dart)\n - [acala](https://github.com/polkawallet-io/polkawallet_plugin_acala/blob/master/lib/polkawallet_plugin_acala.dart)\n - [laminar](https://github.com/polkawallet-io/polkawallet_plugin_laminar/blob/master/lib/polkawallet_plugin_laminar.dart)\n\n## 4. Fetch data and build pages\n\nWe use [https://pub.dev/packages/mobx](https://pub.dev/packages/mobx) as the App state management tool.\n So the directories in a plugin looks like this:\n\n```\n__ lib\n    |__ pages (the UI)\n    |__ store (the MobX store)\n    |__ service (the Actions fired by UI to mutate the store)\n    |__ ...\n```\nTo query data through `PolkawalletPlugin.sdk.api`:\n\n(`polkawallet-io/polkawallet_plugin_kusama/lib/service/gov.dart`)\n```dart\n  Future\u003cList\u003e queryReferendums() async {\n    final data = await api.gov.queryReferendums(keyring.current.address);\n    store.gov.setReferendums(data);\n    return data;\n  }\n```\nTo query data by calling JS directly:\n\n(`polkawallet-io/polkawallet_plugin_kusama/lib/service/gov.dart`)\n```dart\n  Future\u003cvoid\u003e updateBestNumber() async {\n    final int bestNumber = await api.service.webView\n        .evalJavascript('api.derive.chain.bestNumber()');\n    store.gov.setBestNumber(bestNumber);\n  }\n```\n\nWhile we set data to MobX store, the MobX Observer Flutter Widget will rebuild with new data.\n\n## 5. Run your pages in `example/` app\nYou may want to run an example app in dev while building your plugin pages.\n\nSee the `kusama/polkadot` or `acala` or `laminar` examples:\n - [kusama/polkadot](https://github.com/polkawallet-io/polkawallet_plugin_kusama)\n - [acala](https://github.com/polkawallet-io/polkawallet_plugin_acala)\n - [laminar](https://github.com/polkawallet-io/polkawallet_plugin_laminar)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolkawallet-io%2Fsdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolkawallet-io%2Fsdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolkawallet-io%2Fsdk/lists"}