Skip to content

cardanoapi/cardano-test-wallet

Repository files navigation

Cardano Test Wallet

This JavaScript library injects a simulated Cardano wallet into your web application for testing purposes.

Features

  • Provides optional configuration for the wallet, including network ID, staking options, and Kuber API details.
  • Creates a test Cardano wallet object for interacting with the Cardano testnet.

Usage

  1. Load Extension:
    Use the loadExtension function to inject the wallet extension into your web application.

    import { loadExtension } from "cardano-test-wallet";
    loadExtension("myTestWallet");
  2. Import Test Wallet:
    If you wish to import your own custom wallet, use the importTestWallet `function.

    import { importTestWallet } from "cardano-test-wallet";
    importTestWallet(CustomWallet);
  3. Add wallet config:
    Set optional configurations for the wallet using the addTestWalletConfig function.

    import { addTestWalletConfig } from "cardano-test-wallet";
    
    addTestWalletConfig({
      kuberApiUrl: "https://prepod.kuber.cardanoapi.io",
      kuberApiKey: "your-api-key",
    });

Networks:

  • 0 ➔ Testnet
  • 1 ➔ Mainnet

Example:

import {
  loadExtension,
  addTestWalletConfig,
  importTestWallet,
} from "cardano-test-wallet";
loadExtension("MyTestWallet");

importTestWallet(CustomWallet);

addTestWalletConfig({
  kuberApiUrl: "https://prepod.kuber.cardanoapi.io",
  kuberApiKey: "your-api-key",
});

// Access the wallet after injection
const wallet = window.cardano.MyTestWallet;
// Use wallet functionalities here

Kuber API:

This library utilizes the Kuber API, a node interface similar to Blockfrost, for interacting with the Cardano testnet blockchain. You can generate a Kuber API key here.

Security Note:

Test wallets are for development and testing purposes only. Avoid using them in production environments due to security risks.

Available Kuber URLs: