@nekoproject/wallets
v1.2.12
Published
Cross-chain Wallet
Downloads
10
Readme
@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
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
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