⛏️generateAccount
Description
The generateWallet
function utilizes the Solana Keypair library to generate a new public and private key pair. It conveniently returns an object that includes the generated public and private keys represented as strings.
Parameter
This function does not take any parameters
Response
publicKey
string
The generated public key in Base58 encoding
privateKey
string
The generated private key in Base58 encoding
Example Request and Response
Prerequisites
Before making requests with QUBIT® SDK, you must have it installed.
You can install QUBIT® SDK using either npm or yarn. Use the following commands to install QUBIT® SDK:
npm install @nest25/solana-lib
OR
yarn add @nest25/solana-lib
Request
Here is an example of how to make a generateAccount
request using the QUBIT® SDK:
// import Nest SDK
import { Solana } from '@nest25/solana-lib';
// create a new instance of the SDK
const Sol = new Solana();
async function main() {
// generate a new wallet
let wallet = await Sol.generateAccount();
console.log(wallet);
}
main();
Response
{
wallet: {
publicKey: 'J3k6z8xgH8YiDxw18oxnjYQubBfcyTTQjPieHYvxP3e2',
privateKey: '97pdpveR9T9KFFpmiBy5EpL1Te6vV6nKHNXAgfVMV8nd7y2V7EfqcfyzmRWJ5utLEkA2ThCWWxqmTw94Hv3nt34'
}
}
Use Cases
Decentralized Applications (DApps): Developers building decentralized applications on the Solana blockchain can utilize this function to generate new public and private key pairs for their users.
Crypto Wallets: Crypto wallets can leverage the
generateWallet
function to generate new key pairs for users who wish to create a new wallet.Cryptocurrency Exchanges: Cryptocurrency exchanges can integrate the
generateWallet
function to generate new key pairs for users who want to create a new account on their platform.
Last updated