This is a Flutter Plugin for Polygon ID Mobile SDK (https://polygon.technology/polygon-id) This plugin provides a cross-platform tool (iOS, Android) to communicate with the PolygonID platform.
To use this plugin, add polygonid_flutter_sdk
as a dependency in your pubspec.yaml
file like this
dependencies:
polygonid_flutter_sdk: ^x.y.z
This will get you the latest version.
If you want to test a specific branch of the repository, pull polygonid_flutter_sdk
like this
dependencies:
polygonid_flutter_sdk:
git:
url: ssh://[email protected]/iden3/polygonid-flutter-sdk.git
ref: branchPathName
You need to set the environment you are working on in the SDK.
You can either set the environment during initialization (with env
parameter) or later with PolygonIdSdk.setEnv().
The environment object is EnvEntity with:
final String blockchain; # The name of the blockchain (eg: polygon)
final String network; # The network of the blockchain (eg: mumbai)
final String web3Url; # URL of the blockchain (eg: https://polygon-mumbai.infura.io/v3/)
final String web3RdpUrl; # RDP URL (eg: wss://polygon-mumbai.infura.io/v3/)
final String web3ApiKey; # The API key of the web3 URL service (eg: a536514602ea4e22a2e9007b6e9dbc63)
final String idStateContract; # The ID state contract (eg: 0x453A1BC32122E39A8398ec6288783389730807a5)
final String pushUrl; # The push notification URL (eg: https://push.service.io/api/v1)
An example of initialization:
import 'package:flutter/material.dart';
import 'package:polygonid_flutter_sdk/sdk/polygon_id_sdk.dart';
Future<void> main() async {
await PolygonIdSdk.init(env: EnvEntity(
blockchain: 'polygon',
network: 'mumbai',
web3Url: 'https://polygon-mumbai.infura.io/v3/'
web3RdpUrl: 'wss://polygon-mumbai.infura.io/v3/'
web3ApiKey: 'a536514602ea4e22a2e9007b6e9dbc63'
idStateContract: '0x453A1BC32122E39A8398ec6288783389730807a5'
pushUrl: 'https://push.service.io/api/v1',
));
runApp(const App());
}
You can get the current env using PolygonIdSdk.getEnv().
- Clone this repository.
- Run
build_runner
to generate.g.dart
files:
flutter pub run build_runner build --delete-conflicting-outputs
For iOS only:
- Add to your app's Podfile the following post_install code:
post_install do |installer|
installer.pods_project.targets.each do |target|
...
end
# polygon-setup
if target.name == "Pods-Runner"
puts "Updating #{target.name} OTHER_LDFLAGS"
target.build_configurations.each do |config|
xcconfig_path = config.base_configuration_reference.real_path
xcconfig = File.read(xcconfig_path)
new_xcconfig = xcconfig.sub('OTHER_LDFLAGS = $(inherited)', 'OTHER_LDFLAGS = $(inherited) -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/librapidsnark.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_authV2.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQueryMTPV2.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libwitnesscalc_credentialAtomicQuerySigV2.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libgmp.a" -force_load "${PODS_ROOT}/../.symlinks/plugins/polygonid_flutter_sdk/ios/libpolygonid.a"')
File.open(xcconfig_path, "w") { |file| file << new_xcconfig }
end
end
end
end
Please file feature requests and bugs at the issue tracker.
To start using this package first import it in your Dart file.
import 'package:polygonid_flutter_sdk/sdk/polygon_id_sdk.dart';
P.S. Using iOS simulator for testing wallet sdk is right now under maintenance and will be available soon.