⛏️generateWallet

Description

The generateWallet function generates a new key pair using the Ed25519 cryptographic algorithm.

It then returns the public key, private key, and account hash for the newly generated wallet

Parameters

This function does not take any parameters.

Response

Name
Type
Description

privateKey

string

The private key of the newly generated wallet

publicKey

string

The public key of the newly generated wallet

accountHash

string

The account hash of the newly generated wallet on the specified blockchain network

Example Request and Response

Prerequisites

Before making requests with Nest SDK, you must have it installed.

You can install Nest SDK using either npm or yarn. Use the following commands to install Nest SDK:

npm install @nest25/casper-lib
OR
yarn add @nest25/casper-lib

Request

Here is an example of how to make a generateWallet request using the Nest SDK:

// import Nest25 Casper library
const { Casper } = require('@nest25/casper-lib');
// create a new Casper instance
const casper = new Casper();

async function main() {
  // generate a new wallet
  let wallet = await casper.generateWallet();
  console.log({ wallet });
}

main();

Response

{
        wallet: {
          privateKey: '5PjVtasdHeiRVvKaRyhG7qKfWxZnzwez9FbNS9Qx8hALSiAWoE6C6HFSoctqxaZbErNNk9yYyfPwQ9pKiuSbyoi',
          publicKey: '01442e4e84C5Da665eCcFbf766400E9C6B21A0000f8cdc202E35133dA4A41A3715',
          accountHash: 'account-hash-26d819b30dafeb95f3bd333f1ba27ecab71b5a3637ea8e63725b8374abbe3875'
        }
      }

Use Cases

  • Decentralized Applications: The function can be used by decentralized applications to generate new public-private key pairs for user accounts and facilitate transactions on blockchain networks.

  • Blockchain Development: The function can be used by developers to quickly generate test accounts and keys for development and testing purposes.

  • Blockchain Education: The function can be used by educators and students to demonstrate and learn about public-private key pairs and their role in blockchain transactions.

Last updated