Links

Flutter

1.Add the Wallet Service SDK to Your Flutter App

Run this command:
With Flutter:
flutter pub add particle_wallet
click here to get the demo source code

2.Configure Android project

3.Configure iOS project

Prerequisites

  • Install the following:
    • Xcode 13.3.1 or later.
  • Make sure that your project meets the following requirements:
    • Your project must target these platform versions or later:
      • iOS 13
3.1 After export iOS project, open Runner.xcworkspace under ios folder.
3.2 Create a ParticleNetwork-Info.plist into the root of your Xcode project, and make sure the file is check under Target Membership.
3.3 Copy the following text into this file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PROJECT_UUID</key>
<string>YOUR_PROJECT_UUID</string>
<key>PROJECT_CLIENT_KEY</key>
<string>YOUR_PROJECT_CLIENT_KEY</string>
<key>PROJECT_APP_UUID</key>
<string>YOUR_PROJECT_APP_UUID</string>
</dict>
</plist>
3.4 Replace YOUR_PROJECT_UUID, YOUR_PROJECT_CLIENT_KEY, and YOUR_PROJECT_APP_UUID with the new values created in your Dashboard
3.5. Import the ParticleAuthService module in your AppDelegate.swift file.
Swift
Objective-C
import ParticleAuthService
@import ParticleAuthService;
3.6. Add the scheme URL handle in your app's application(_:open:options:) method
Swift
Objective-C
return ParticleAuthService.handleUrl(url)
return [ParticleAuthService handleUrl:url];
3.7. Configure your app scheme URL, select your app from TARGETS, under Info section, click + to add the URL types, and paste your scheme in URL Schemes
Your scheme URL should be "pn" + your project app uuid.
For example, if your project app id is "63bfa427-cf5f-4742-9ff1-e8f5a1b9828f", your scheme URL is "pn63bfa427-cf5f-4742-9ff1-e8f5a1b9828f".
Config scheme url
3.8 In Xcode right-click your Info.plist file and choose "Open As Source Code".
Copy & Paste the XML snippet into the body of your file (<dict>...</dict>).
<key>LSApplicationQueriesSchemes</key>
<array>
<string>imtokenv2</string>
<string>metamask</string>
<string>phantom</string>
<string>bitkeep</string>
<string>trust</string>
<string>rainbow</string>
<string>gnosissafe</string>
</array>
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access in order to open photos of barcodes</string>
<key>NSCameraUsageDescription</key>
<string>We use the camera to scan barcodes</string>

Initialize the SDK

Before using the SDK, you have to call init(Required)
ParticleWallet.init();
ParticleWallet.navigatorWallet();
ParticleWallet.navigatorTokenReceive();
String tokenAddress = "8ci2fZwQSmArbeHkuA7M8h5rsRwwh4FMTXrZxb3KsDpb";
String toAddress = "1232fZwQSmArbeHkuA7M8h5rsRwwh4FMTXrZxb3KsDpb";
int amount = 1000000;
ParticleWallet.navigatorTokenSend(tokenAddress: tokenAddress, toAddress: toAddress, amount: amount);
String tokenAddress = "8ci2fZwQSmArbeHkuA7M8h5rsRwwh4FMTXrZxb3KsDpb";
ParticleWallet.navigatorTokenTransactionRecords(tokenAddress: tokenAddress);
String mintAddress = "0xD000F000Aa1F8accbd5815056Ea32A54777b2Fc4";
String tokenId = "1412";
ParticleWallet.navigatorNFTSend(mintAddress, tokenId, receiveAddress: "");
String mint = "0xD000F000Aa1F8accbd5815056Ea32A54777b2Fc4";
String tokenId = "1412";
ParticleWallet.navigatorNFTDetails(mint, tokenId);

Enable pay

bool enable = true;
ParticleWallet.enablePay(enable);

Get enable pay

bool isEnable = await ParticleWallet.getEnablePay();
showToast("isEnable:$isEnable");

Enable swap

bool enable = true;
ParticleWallet.enableSwap(enable);

Get enable swap

bool isEnable = await ParticleWallet.getEnableSwap();
showToast("isEnable:$isEnable");
final config = BuyCryptoConfig(walletAddress:"your wallet address", cryptoCoin:"USDT", fiatCoin:"USD", fiatAmt:1000, network:OpenBuyNetwork.ethereum);
ParticleWallet.navigatorBuyCrypto(config: config);
ParticleWallet.navigatorSwap();
daString result = await ParticleWallet.navigatorLoginList();
print("result:$result");

Set Support chain

List<ChainInfo> chainInfos = <ChainInfo>[];
chainInfos.add(EthereumChain.mainnet());
chainInfos.add(PolygonChain.mainnet());
chainInfos.add(BSCChain.mainnet());
ParticleWallet.supportChain(chainInfos);

Switch wallet

WalletType walletType = WalletType.particle;
String publicAddress = "";
String result = await ParticleWallet.switchWallet(walletType, publicAddress);
print("result:$result");

Show test network

bool enable = false;
ParticleWallet.showTestNetwork(enable);

Show manage wallet

bool enable = true;
ParticleWallet.showManageWallet(enable);

Set language

Language language = Language.system;
ParticleWallet.setLanguage(language);

Set interface style

UserInterfaceStyle interfaceStyle = UserInterfaceStyle.light;
ParticleWallet.setInterfaceStyle(interfaceStyle);
Last modified 2mo ago