Zen.js

Zen.JS is the library for interacting with the Zen Protocol node via JavaScript.

Zen.js is helps in:

  • Generate Mnemonic phrase

  • Secure Mnemonic phrase

  • Serialise and deserialise Consensus types

  • Sign transactions

  • Defining the contract message body

  • Create a wallet instance to interact with the blockchain

  • Encode and decode extendend keys to address

Install

Generating mnemonic phrase, keys and accepting payments

Creating and signing transactions

To create a transaction using a TransactionBuilder, you need to:

  • Add an input: This involves providing the transaction hash (txHash) of a previous transaction that contains the unspent transaction output (UTXO) you want to use as an input, along with the index of the UTXO in that transaction. Additionally, you need to provide the private key associated with the UTXO's address.

  • Add an output: This involves specifying the receiver's address (where you want to send the funds), the amount of Kalapas (the cryptocurrency) to send, and the asset ID (the identifier of the asset being transferred).

Once you have added the input and output to the transaction, you can proceed to sign it. The signing process involves using the private key associated with the input UTXO to create a digital signature for the transaction. The signature ensures the integrity and authenticity of the transaction.

After the transaction is signed, it needs to be transformed into hexadecimal format (hex) so that it can be published on the network. This encoding ensures that the transaction can be transmitted and understood by the blockchain network.

Here an example:

Wallet functionalities

Last updated