1.2.12 • Published 2 years ago

@nekoproject/wallets v1.2.12

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@nekoproject/wallets

A complete crypto wallet base support for cross-chain

Table of contents

Build

Re-build project from scratch

  • Clean project
      npm run clean
  • Build
      npm run build
  • Unit test
    ```bash
      npm run test:cover
    ```

    Install

    Install @nekoproject/wallets with npm
      npm i @nekoproject/wallets
    Import
      import { Wallet, SPLWallet } from '@nekoproject/wallets'

    Documents

    Solana Keypair defined in @nekoproject/wallets
 interface SolanaKeypair {
   publicKey: web3.PublicKey;
   secretKey: Uint8Array;
 }

Wallet methods

Load or Create wallet

  • Generate new wallet
      let wallet: Wallet;
      // generate new solana wallet
      wallet = SPLWallet.generateWallet()
  • Load wallet from seed pharse
      let wallet: Wallet;
      // load solana wallet
      const mnemonic = 'seeds pharse'
      wallet = SPLWallet.fromMnemonic(mnemonic)
  • Load wallet from secret Key
      import fs from 'mz/fs';
      const filePath = path/to/json/secretKey/file
      const secretKeyString = await fs.readFile(filePath, { encoding: 'utf8' });
      const secretKey = Uint8Array.from(JSON.parse(secretKeyString));
      let wallet: Wallet;
      // load solana wallet
      wallet = SPLWallet.fromSecretKey(secretKey)
  • Load wallet from string secret Key
      ```ts
        const secretStringKey = '2PU5z5WF9oteEcMfrKswairtm4H69XakqPFNRVBoadw4uTFEPDtUWzp6YirXtVSuybJ2kYVchCPxKisbdTRurcMM'
        let wallet: Wallet;
        // load solana wallet
        wallet = SPLWallet.fromStringSecretKey(secretStringKey)
      ```

    Getter

  • Signer
        const signer: SolanaKeypair = wallet.signer
  • Address
       const publicKey = wallet.address

Notice

Ref