kalp_dlt 1.0.0 copy "kalp_dlt: ^1.0.0" to clipboard
kalp_dlt: ^1.0.0 copied to clipboard

discontinuedreplaced by: kalp_dlt_wallet

A Flutter package for interacting with distributed ledger technology (DLT) through the Kalp wallet system.

Kalp DLT #

A Flutter package for interacting with distributed ledger technology (DLT) through the Kalp wallet system. This package provides a simple interface for creating and managing wallets, as well as performing blockchain operations.

pub package License: MIT

Features #

  • Wallet Management

    • Create seed phrases for new wallets
    • Register wallets with on Kalp DLT blockchain
    • Import existing wallets on Kalp DLT blockchain
  • Blockchain Operations

    • Read data from the blockchain
    • Write data to the blockchain
    • Calculate gas fees for transactions

Installation #

Before using this package, you'll need to generate an API key:

  1. Visit Kalp Studio Portal
  2. Generate your API key from the wallet creator app section
  3. Store your API key securely as it will be required for initialization

Add kalp_dlt to your pubspec.yaml file:

dependencies:
  kalp_dlt: ^1.0.0

Then run:

flutter pub get

Getting Started #

To use this package, you need to initialize it with your configuration:

import 'package:kalp_dlt/kalp_dlt.dart';

void main() {
  // Initialize the Kalp DLT with your configuration
  final kalpDlt = KalpDLT.initialize(
    nglBaseUrl: 'https://your-ngl-service.com',
    gatewayBaseUrl: 'https://your-gateway-service.com',
    apiKey: 'your-api-key', // Add your API key here
  );

  // Now you can use kalpDlt to interact with the blockchain
}

Network Configuration #

The package supports both test and main networks. Here are the configuration details:

NGL Configuration #

Test Network

  • URL: https://ngl-userreg-test.kalp.network/v1/pki/
  • Channel Name: prod-test-mainnet

Main Network

  • URL: https://ngl-mumbai-userreg.kalp.network/v1/pki/
  • Channel Name: kalpchaintwo

Gateway Configuration #

Test Network

  • URL: https://rpc-mumbai-test.kalp.network/transaction/v1/
  • Network Name: kalptantra

Main Network

  • URL: https://rpc-mumbai.kalp.network/transaction/v1/
  • Network Name: kalptwo

Usage Example with Network Configuration #

// For Test Network
final kalpDlt = KalpDLT.initialize(
  nglBaseUrl: 'https://ngl-userreg-test.kalp.network/v1/pki/',
  gatewayBaseUrl: 'https://rpc-mumbai-test.kalp.network/transaction/v1/',
  apiKey: 'your-api-key',
);

// For Main Network
final kalpDlt = KalpDLT.initialize(
  nglBaseUrl: 'https://ngl-mumbai-userreg.kalp.network/v1/pki/',
  gatewayBaseUrl: 'https://rpc-mumbai.kalp.network/transaction/v1/',
  apiKey: 'your-api-key',
);

Usage #

Creating a Wallet #

// Generate seed words
final seedWords = await kalpDlt.createSeedWords();
print('Generated seed words: $seedWords');

// Create a wallet with the generated seed words
await kalpDlt.createWalletWithSeedWords(
  seedWords: seedWords.split(' '),
  channelName: 'your-channel-name',
  callback: (wallet) {
    // Handle the created wallet
    print('Wallet created with enrollment ID: ${wallet.enrollmentId}');
  },
  errorCallback: (error) {
    // Handle any errors
    print('Error creating wallet: $error');
  },
);

Importing an Existing Wallet #

// Import a wallet using existing seed words
final existingSeedWords = 'word1 word2 word3 ... word12';
await kalpDlt.createWalletWithSeedWords(
  seedWords: existingSeedWords.split(' '),
  channelName: 'your-channel-name',
  importWallet: true,
  callback: (wallet) {
    // Handle the imported wallet
    print('Wallet imported with enrollment ID: ${wallet.enrollmentId}');
  },
  errorCallback: (error) {
    // Handle any errors
    print('Error importing wallet: $error');
  },
);

Reading from the Blockchain #

// Create a proposal for reading data
final proposal = Proposal(
  walletAddress: 'your-enrollment-id',
  network: 'gateway-network-name',
  contractAddress: 'gateway-contract-address',
  functionName: 'your-function-name',
  functionParams:<String>[],
  publicCertificate: 'your-public-certificate',
);

// Read data from the blockchain
final result = await kalpDlt.read(
  proposal: proposal,
);
print('Read result: $result');

Writing to the Blockchain #

// Create a proposal for writing data
final proposal = Proposal(
  walletAddress: 'your-enrollment-id',
  network: 'gateway-network-name',
  contractAddress: 'gateway-contract-address',
  functionName: 'your-function-name',
  functionParams:<String>[],
  publicCertificate: 'your-public-certificate',
);

// Write data to the blockchain
final result = await kalpDlt.write(
  proposal: proposal,
);
print('Write result: $result');

Calculating Gas Fees #

// Create a proposal for a transaction
final proposal = Proposal(
  walletAddress: 'your-enrollment-id',
  network: 'gateway-network-name',
  contractAddress: 'gateway-contract-address',
  functionName: 'your-function-name',
  functionParams:<String>[],
  publicCertificate: 'your-public-certificate',
);

// Calculate gas fees for the transaction
final fees = await kalpDlt.gasFees(
  proposal: proposal,
);
print('Gas fees: $fees');

Error Handling #

The package provides comprehensive error handling:

try {
  await kalpDlt.createWalletWithSeedWords(
    seedWords: seedWords.split(' '),
    channelName: 'your-channel-name',
    callback: (wallet) {
      // Success
    },
    errorCallback: (error) {
      // This will be called for specific wallet creation errors
      print('Wallet creation error: $error');
    },
  );
} catch (e) {
  // This will catch any other exceptions
  print('Unexpected error: $e');
}

Example #

A complete example application is available in the /example folder of this package. To run the example:

  1. Clone the repository
  2. Navigate to the example directory
  3. Run flutter pub get
  4. Run flutter run

📜 Requirements #

  • Flutter: >=3.0.0
  • Dart: >=2.17.0

🔗Security Considerations #

  • The seed phrases generated by this package are sensitive information and should be handled securely.
  • Always use HTTPS URLs for your services to ensure secure communication.
  • Consider implementing additional security measures such as biometric authentication before performing sensitive operations.

🐞Before reporting any bug #

  • Search for Existing Issues

    • Go to the repository's Issues tab.
    • Use keywords related to your bug.
    • if the issue already exists, add a comment or a 👍 reaction to show that you are affected too.
  • Click “New Issue”

    • If no existing issue matches your bug, click the “New Issue” button.
    • Select the appropriate template (e.g., "Bug Report") if available.
    • Fill Out the Bug Report in given template

Contributions are welcome! If you find a bug or want to add a feature, please open an issue or submit a pull request.

License #

This package is available under the MIT License. See the LICENSE file for more information.

2
likes
120
points
11
downloads

Documentation

API reference

Publisher

verified publisherkalp.studio

Weekly Downloads

A Flutter package for interacting with distributed ledger technology (DLT) through the Kalp wallet system.

Topics

#blockchain #wallet #kalpdlt

License

MIT (license)

Dependencies

basic_utils, bip39, dio, flutter, freezed_annotation, json_annotation, path_provider, pointycastle, pretty_dio_logger, webview_flutter

More

Packages that depend on kalp_dlt