The Wallet SDK enables you to build a Verifiable Credentials wallet inside your app and allows your users to receive, store, and manage their DOCK tokens too. This was built for mobile applications with added support for Polkadot-JS.
To use the wallet-sdk, all you need to do is wrap your app in a WalletSDKProvider
and start building your wallet.
Using polkadot-js libraries in React Native is a challenge, due to the lack of WebAssembly support. The Dock Wallet SDK handles all the Polkadot Web Assembly in a WebView, sending messages to the React Native thread through a JSON RPC layer.
Dock Mobile SDK supports devices that have Android 8.1 or higher and iOS 11 or higher.
yarn add @docknetwork/wallet-sdk-core
yarn add @docknetwork/wallet-sdk-react-native
There are some scripts and additional dependencies required. Please check our example repo for detailed steps.
The following example will create a wallet and allow the user to add credentials to it. Displaying the count of documents added to the wallet.
Notice that the all documents are accessible through the documents
object.
import {Box, Button, NativeBaseProvider, Text} from 'native-base';
import React, {useEffect} from 'react';
import {
WalletSDKProvider,
useWallet,
} from '@docknetwork/wallet-sdk-react-native/lib';
const WalletDetails = function () {
const {wallet, status, documents} = useWallet();
return (
<Box>
<Text>Wallet status: {status}</Text>
<Text>Wallet docs: {documents.length}</Text>
<Button onPress={() => wallet.addDocument({
name: 'my credential',
type: 'VerifiableCredential',
})}>
<Text>Add Credential</Text>
</Button>
</Box>
);
};
const App = () => {
return (
<NativeBaseProvider>
<WalletSDKProvider>
<Box p={8}>
<Text>Dock Wallet SDK Demo</Text>
<Text>Press on `add credential` button to create a new credential</Text>
</Box>
<WalletDetails />
</WalletSDKProvider>
</NativeBaseProvider>
);
};
export default App;
Check the following repository for detailed examples for running the Dock Wallet SDK on NodeJS, Web, and Flutter.
https://github.com/docknetwork/wallet-sdk-examples
For more details you can check the getting started guide