WalletManagement
The WalletManagement is a tool that helps you handle Ethereum wallets. With it, you can make a new wallet, bring in a wallet you already have, get back a wallet if you lost it, or delete your wallet.
How To Use
Import the Wallet Service:
import Wallet from '@sdk/src/services/Wallet';
import { IStorage } from '@sdk/src/services/interfaces/IStorage';
Initialize the wallet and custom storage:
The custom storage is needed by Wallet SDK to check storage.
class SecureStorage implements IStorage {
async get<T>(key: string): Promise<T | null> {
const result = await SecureStore.getItemAsync(key);
if (result) {
return JSON.parse(result) as T;
} else {
return null;
}
}
async set<T>(key: string, value: T): Promise<void> {
await SecureStore.setItemAsync(key, JSON.stringify(value));
}
async remove(key: string): Promise<void> {
await SecureStore.deleteItemAsync(key);
}
}
const storage = new SecureStorage();
const wallet = Wallet.create('YOUR_AUTH_SERVER_BASE_URL', storage);
const walletManagement = wallet.walletManagement;
Examples:
Wallet Creation
Creates a new ethereum wallet.
const result = await walletManagement.createWallet({
deviceId: deviceId,
token
});
Wallet Import
Handle to bring your wallet you already have.
const result = await walletManagement.importWallet({
deviceId,
token,
mnemonic
});
Wallet Recovery
Handle to recover your lost a wallet by recovering it.
const result = await walletManagement.recoverWallet({
deviceId,
token,
spk,
shares
});
Wallet Deletion
Handle deletion of your existing wallet.
await walletManagement.deleteWallet({
deviceId,
token
spk
});
Create Biometric Token
Generates a biometric token.
const token = await walletManagement.createBiometricToken({
spk,
type,
});
Associated Interface
IWalletManagementLast updated