0.4.4 • Published 3 years ago

xtz-wallet v0.4.4

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

XTZ Wallet

XTZ Wallet is a JavaScript library for interacting with the Tezos blockchain.

Getting Started

import { Wallet, createMnemonic, importWallet } from 'xtz-wallet';

Usage

Create a new mnemonic seed phrase.

const numWords: number = 12;
const entropy: Uint8Array = new Uint8Array([1, 2, 3, 4, 5]);

// clerk find excuse juice observe cage reveal pulse language trial pumpkin culture
const mnemonic: string = createMnemonic(numWords, entropy);

Import keys from an existing mnemonic seed.

const password: string = '0ptionalPa55word';
const curve: 'ed25519' | 'secp256k1' | 'nistp256' = 'ed25519';
const rpc: string = 'https://granadanet.smartpy.io/';
const path: string = "m/44'/1729'/0'/0'";
const wallet: Wallet = importWallet(mnemonic, { password, curve, rpc, path });

Retrieve keys once your wallet has been initialized.

console.log(wallet.getSecretKey());
console.log(wallet.getPublicKey());
console.log(wallet.getAddress());   // tz1UMq5jhiizkBH7Abtmy5vFUsMfFHPyPMQT

Build a Tezos operation batch.

const batch = await wallet.buildOperationBatch([
    wallet.ops.transaction('tz1gRi6XnzpBbkNGByBgxsBm1dTsA1fivSWU', 1000)
]);

Return operations list and fee estimates.

console.log(batch.getContents());
console.log(batch.getEstimates());

Sign the operation batch.

const signature: string = await batch.getSignature(wallet.getSecretKey());
console.log(signature);

Send operation to the blockchain. This function handles pre-validation automatically.

wallet.send(batch, signature).then(console.log);

License

MIT

0.4.4

3 years ago

0.4.1

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.0

3 years ago

0.3.6

3 years ago

0.3.7

3 years ago

0.3.0

3 years ago

0.3.5

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.2.1

3 years ago

0.1.61

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.2

3 years ago

0.1.0

3 years ago