Custodial Wallet Kit

Wallet Manager

Wallet Manager Service is a component of the KrypCore Web3 SDK that provides a set of methods and functionalities for managing wallets and interacting with blockchain networks. It allows developers to perform various wallet-related operations such as creating wallets, retrieving wallet details, signing transactions, getting wallet balances, and more.

With the Wallet Manager Service, developers can easily integrate wallet management capabilities into their decentralized applications (DApps) and streamline the interaction between users and the blockchain network.

Now, let's dive into the documentation for each method provided by the Wallet Manager Service in the KrypCore Web3 SDK:

Table of Contents

  • Create Wallet

  • Create and Execute Transaction

  • Get All Wallets

  • Get Wallet Details

  • Get Wallet Balance

  • Call Contract

  • Get Transaction History

  • Sign Message

  • Sign Transaction Hash

  • Verify Signature

  • Sign Typed Data

  • Deploy Contract

Bootstrapping the SDK for custodial wallet kit

const krypcore_web3_sdk = require("@krypc/krypcore-web3-sdk");
const configFilePath = '../../config.json';
const Web3Engine = new krypcore_web3_sdk.Web3Engine(configFilePath);
const WalletMgrService = new Web3Engine.Services.WalletManager(configFilePath);

SDK Methods

createWallet(walletName, curveType)

Creates a new wallet with the specified name and curve type.

Parameters:

  • walletName (string): The name of the wallet.

  • curveType (string): The type of elliptic curve to use for key generation.

Usage:

const walletName = "sample-test-123456789012";
const curveType = "secp256k1";
const creationStatus = await WalletMgrService.createWallet(walletName, curveType);
console.log(creationStatus);

createAndExecuteTx(chainId, contractAddress, abi, isContractTx, method, accessToken, value, args)

Creates and executes a transaction on the specified chain with the given parameters.

Parameters:

  • chainId (number): The ID of the chain on which to execute the transaction.

  • contractAddress (string): The address of the contract.

  • abi (string): The ABI of the contract in JSON string format.

  • isContractTx (boolean): Indicates whether the transaction is for a contract method.

  • method (string): The name of the contract method to invoke.

  • accessToken (string): The access token for authentication.

  • value (number): The value to send with the transaction.

  • args (array): An array of arguments for the contract method.

Usage:

const chainId = 80001;
const contractAddress = "0xE396a584D29036c44c138E98072341C4174778BD";
const abi = JSON.stringify(sampleAbi);
const isContractTx = true;
const method = "mintNFT";
const accessToken = process.env.WALLET_ACCESS_TOKEN;
const value = 0;
const args = [];

const txStatus = await WalletMgrService.createAndExecuteTx(chainId, contractAddress, abi, isContractTx, method, accessToken, value, args);
console.log(txStatus);

getAllWallets()

Retrieves the details of all wallets associated with the current user.

Usage:

const allWallets = await WalletMgrService.getAllWallets();
console.log(allWallets);

getWallet(walletName)

Retrieves the details of a specific wallet based on its name.

Parameters:

  • walletName (string): The name of the wallet to retrieve.

Usage:

const walletName = process.env.WALLET_NAME;
const walletDetails = await WalletMgrService.getWallet(walletName);
console.log(walletDetails);

getBalance(walletName)

Retrieves the balance of a wallet.

Parameters:

  • walletName (string): The name of the wallet.

Usage:

const walletName = process.env.WALLET_NAME;
const balanceDetails = await WalletMgrService.getBalance(walletName);
console.log(balanceDetails);

callContract(chainId, contractAddress, abi, method, args, accessToken)

Invokes a view or pure method of a contract.

Parameters:

  • chainId (number): The ID of the chain on which the contract is deployed.

  • contractAddress (string): The address of the contract.

  • abi (string): The ABI of the contract in JSON string format.

  • method (string): The name of the contract method to invoke.

  • args (array): An array of arguments for the contract method.

  • accessToken (string): The access token for authentication.

Usage:

const chainId = 80001;
const contractAddress = "0xE396a584D29036c44c138E98072341C4174778BD";
const abi = JSON.stringify(sampleAbi);
const method = "owner";
const args = [];
const accessToken = process.env.WALLET_ACCESS_TOKEN;

const callStatus = await WalletMgrService.callContract(chainId, contractAddress, abi, method, args, accessToken);
console.log(callStatus);

getTxHistory(chainId, accessToken)

Retrieves the transaction history of the specified chain for the current user.

Parameters:

  • chainId (number): The ID of the chain.

  • accessToken (string): The access token for authentication.

Usage:

const chainId = 80001;
const accessToken = process.env.WALLET_ACCESS_TOKEN;

const txHistory = await WalletMgrService.getTxHistory(chainId, accessToken);
console.log(txHistory);

signMessage(message, accessToken)

Signs a message using the wallet.

Parameters:

  • message (string): The message to sign.

  • accessToken (string): The access token for authentication.

Usage:

const message = "Hello there";
const accessToken = process.env.WALLET_ACCESS_TOKEN;

const signMessage = await WalletMgrService.signMessage(message, accessToken);
console.log(signMessage);

signTxHash(txHash, accessToken)

Signs a transaction hash using the wallet.

Parameters:

  • txHash (string): The transaction hash to sign.

  • accessToken (string): The access token for authentication.

Usage:

const txHash = "0x157755d6d077c508b02526308399d14b8c4e731849bcf81c51936405139d701f";
const accessToken = process.env.WALLET_ACCESS_TOKEN;

const signTxHash = await WalletMgrService.signTxHash(txHash, accessToken);
console.log(signTxHash);

verifySignatureOffChain(message, signature, accessToken)

Verifies the off-chain signature.

Parameters:

  • message (string): The message that was signed.

  • signature (string): The signature to verify.

  • accessToken (string): The access token for authentication.

Usage:

const message = "Hello there";
const signature = "0x00e6ec512a9496c9ecb63cb0875f2357e5e0e4e7f3b5741bac9ac0f8e17a17df538b66bde141e083bf6ef0bc74129b6295e72bce792755a9a5937bd7ef35053701";
const accessToken = process.env.WALLET_ACCESS_TOKEN;

const verifySignature = await WalletMgrService.verifySignatureOffChain(message, signature, accessToken);
console.log(verifySignature);

signEip712TypedData(typedData, accessToken)

Signs the EIP-712 typed data using the wallet.

Parameters:

  • typedData (string): The EIP-712 typed data as a JSON string.

  • accessToken (string): The access token for authentication.

Usage:

const typedData = JSON.stringify(typedData);
const accessToken = process.env.WALLET_ACCESS_TOKEN;

const signTyped

Data = await WalletMgrService.signEip712TypedData(typedData, accessToken);
console.log(signTypedData);

deployContract(chainId, abi, bytecode, accessToken, constructorParams)

Deploys a contract on the specified chain.

Parameters:

  • chainId (number): The ID of the chain on which to deploy the contract.

  • abi (string): The ABI of the contract in JSON string format.

  • bytecode (string): The bytecode of the contract.

  • accessToken (string): The access token for authentication.

  • constructorParams (array): An array of constructor parameters for the contract.

Usage:

const chainId = 80001;
const abi = sampleAbiBase64;
const bytecode = sampleBytecode;
const accessToken = process.env.WALLET_ACCESS_TOKEN;
const constructorParams = ["Test Collection", "TEST"];

const deployStatus = await WalletMgrService.deployContract(chainId, abi, bytecode, accessToken, constructorParams);
console.log(deployStatus);

Last updated