To interact with Keeper Wallet in your iOS or Android app, complete the following steps:
For more information on using Flutter implementation of WalletConnect, see their docs.
pubspec.yaml:
walletconnect_flutter_v2: ^1.2.3
Describe your app and define its appearance in Keeper Wallet when a user is prompted to connect or sign a transaction/order/message.
static const projectId = 'YOUR_PROJECT_ID';
_wcClient = await Web3App.createInstance(
relayUrl: 'wss://relay.walletconnect.com',
projectId: projectId,
metadata: const PairingMetadata(
name: 'YOUR_APP_NAME',
description: 'YOUR_APP_DESC',
url: 'YOUR_WEBSITE',
icons: ["YOUR_IMAGE_URLS"],
),
);
Send a request to WalletConnect to get a pairing URI for Keeper Wallet.
// Set the chain ID: 'W' for Mainnet or 'T' for Testnet
static const testChainId = 'waves:T';
static const mainChainId = 'waves:W';
final resp = await _wcClient?.connect(requiredNamespaces: {
namespace: const RequiredNamespace(
chains: [testChainId],
methods: [
'waves_signTransaction',
'waves_signTransactionPackage',
'waves_signOrder',
'waves_signMessage',
'waves_signTypedData',
],
events: [],
),
});
final wcUrl = resp?.uri.toString();
Here’s how it works:
Deep Links are used to interact with Keeper Wallet. You can use url_launcher plugin to call Keeper. For the callback, the Deep Link must be configured in your app.
static const callback = 'YOUR_LINK_OR_SCHEME';
final parameters = <String>[];
parameters.add('wcurl=${Uri.encodeComponent(wcUrl)}');
parameters.add('callback=$callback');
final query = parameters.join('&');
final url = Uri.parse('https://link.keeper-wallet.app/auth?$query');
//url_launcher
launchUrl(url, mode: LaunchMode.externalApplication);
The result of connecting comes to the listener:
_wcClient?.onSessionConnect.subscribe((SessionConnect? connect) {
print('onSessionConnect: $connect');
_topic = connect?.session.topic;
});
Here is how it works:
Example:
static const testChainId = 'waves:T';
static const mainChainId = 'waves:W';
static const Map<String, Object> invoke = { YOUR_TX_PARAMS };
_wcClient?.request(
topic: _topic,
chainId: testChainId,
request: SessionRequestParams(
method: 'waves_signTransaction',
params: [invoke],
),
)
.then((value) => print('request result: $value'))
.onError((error, _) => print('request error: $error'));
static const testChainId = 'waves:T';
static const mainChainId = 'waves:W';
static const Map<String, Object> order = { YOUR_ORDER_PARAMS };
_wcClient?.request(
topic: _topic,
chainId: testChainId,
request: SessionRequestParams(
method: 'waves_signOrder',
params: [order],
),
)
.then((value) => print('request result: $value'))
.onError((error, _) => print('request error: $error'));
static const testChainId = 'waves:T';
static const mainChainId = 'waves:W';
static const message = 'YOUR_MESSAGE';
_wcClient?.request(
topic: _topic,
chainId: testChainId,
request: SessionRequestParams(
method: 'waves_signMessage',
params: [message],
),
)
.then((value) => print('request result: $value'))
.onError((error, _) => print('request error: $error'));
Specify topic
and callback
in the request.
static const callback = 'YOUR_LINK_OR_SCHEME';
final parameters = <String>[];
parameters.add('topic=$_topic');
parameters.add('callback=$callback');
final query = parameters.join('&');
final url = Uri.parse('https://link.keeper-wallet.app/wakeup?$query');
//url_launcher
launchUrl(url, mode: LaunchMode.externalApplication);