npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

metaversejs

v0.3.98

Published

MetaverseJS library

Readme

Installation

Install using npm:

npm install metaversejs

Setup

NodeJS

let Metaverse = require('metaversejs');

Browser

For use in webapps the npm package contains a dist/metaverse.min.js. You can generate this file from source using grunt.

Usage

Please also check the examples folder.

Wallet generation

let Metaverse = require('metaversejs')

let number_of_addresses = 10

Metaverse.wallet.generateMnemonic()
    .then((mnemonic) => Metaverse.wallet.fromMnemonic(mnemonic)
        .then((wallet) => {
            let addresses = []
            for (let i = 0; i < number_of_addresses; i++) {
                addresses.push(wallet.getAddress(i))
            }
            return {
                "mnemonic": mnemonic,
                "addresses": addresses,
                "wallet": wallet
            }
        }))
    .then(console.log)

This will generate a new random wallet and return the mnemonic words as well as the first 10 addresses of the wallet.

Send ETP or MST

As Metaverse is UTXO based you need to specify the inputs and outputs of the transaction. The following example creates a basic P2PKH (pay to public key hash) transaction.

//Transaction object
var tx = new Metaverse.transaction()
//Add inputs
tx.addInput("MKXYH2MhpvA3GU7kMk8y3SoywGnyHEj5SB","5554b27dbf657d008511df56e747ffb2173749fd933b03317cee3c1fde271aea",1)
//Add outputs
tx.addOutput("MVpxH8aAa3BAXvbdqUUJwEP6s2ajGKKtyd","ETP",1)
tx.addOutput("MKXYH2MhpvA3GU7kMk8y3SoywGnyHEj5SB","ETP",4939995)
console.log('transaction details: ' + tx)
//Sign the inputs
wallet.sign(tx)
    .then( (stx) => {
        console.log('signed transaction: ' + stx)
        //Encode (serialize) the transaction
        return stx.encode()
    })
    .then( (raw_tx) => {
        console.log('Encoded transaction: ' + raw_tx)
    })

You can also add other assets to the transaction. The resulting raw transaction can be broadcasted to any blockchain nodes.

Another way for creating transactions is to use the transaction builder.

const target = {
   "ETP": 100000000,
   "MST": {
      "MVS.HUG": 5
   }
}
Metaverse.transaction_builder.send(utxo, recipient_address, recipient_avatar, target, change_address, change, locked_asset_change, fee, messages)
    .then( tx => wallet.sign(tx))
    .then( stx => {
        console.log('signed transaction: ' + stx)
        //Encode (serialize) the transaction
        return stx.encode()
    })
    .then( (raw_tx) => {
        console.log('Encoded transaction: ' + raw_tx.toString('hex'))
    })

For standard transaction the transaction builder is the preferred way so the next examples will use the transaction builder only.

Deposit

In order to create a deposit and get interest you just have to add a lock output to a transaction. Possible values for the duration are: 25200, 108000, 331200, 655200 and 1314000 blocks on the mainnet.

Metaverse.transaction_builder.deposit(utxo, recipient_address, quantity, duration, change_address, change, fee, network, messages)
    .then( tx => wallet.sign(tx))
    .then( stx => {
        console.log('signed transaction: ' + stx)
        //Encode (serialize) the transaction
        return stx.encode()
    })
    .then( (raw_tx) => {
        console.log('Encoded transaction: ' + raw_tx.toString('hex'))
    })

The reward transaction will be generated by the miner of the block that will contain the transaction.

Issue asset

In order to issue a new asset add an asset issue output to a transaction. Please make sure that the asset symbol is unique. Precision must be in range 0..19 and the maximum supply is must be provided as a quantity of the smallest unit. An asset with 1000 tokens that should have a precision of 2 decimals must be provided as 1000000 and precision 2. The transaction fee must be 10 ETP.

Metaverse.transaction_builder.issueAsset(inputs, recipient_address, symbol, max_supply, precision, issuer, description, secondaryissue_threshold, is_secondaryissue, change_address, change, issue_domain, bounty_fee, network)
    .then( tx => wallet.sign(tx))
    .then( stx => {
        console.log('signed transaction: ' + stx)
        //Encode (serialize) the transaction
        return stx.encode()
    })
    .then( (raw_tx) => {
        console.log('Encoded transaction: ' + raw_tx.toString('hex'))
    })

Send to multiple recipients

const recipients = [ { address: "xxx", "target": { "ETP": 123, "MST": { "SDG": 18 } }, "avatar": "EricGu" } ]
Metaverse.transaction_builder.sendMore(utxo, recipients, change_address, change, locked_asset_change, fee, messages)
    .then( tx => wallet.sign(tx))
    .then( stx => {
        console.log('signed transaction: ' + stx)
        //Encode (serialize) the transaction
        return stx.encode()
    })
    .then( (raw_tx) => {
        console.log('Encoded transaction: ' + raw_tx.toString('hex'))
    })

Lock MST

Metaverse.transaction_builder.sendLockedAsset(utxo, recipient_address, symbol, quantity, attenuation_model, change_address, change, locked_asset_change, fee, messages)
    .then( tx => wallet.sign(tx))
    .then( stx => {
        console.log('signed transaction: ' + stx)
        //Encode (serialize) the transaction
        return stx.encode()
    })
    .then( (raw_tx) => {
        console.log('Encoded transaction: ' + raw_tx.toString('hex'))
    })

Issue Avatar

Metaverse.transaction_builder.issueDid(utxo, avatar_address, symbol, change_address, change, bounty_fee, network)
    .then( tx => wallet.sign(tx))
    .then( stx => {
        console.log('signed transaction: ' + stx)
        //Encode (serialize) the transaction
        return stx.encode()
    })
    .then( (raw_tx) => {
        console.log('Encoded transaction: ' + raw_tx.toString('hex'))
    })

Issue MIT

Metaverse.transaction_builder.registerMIT(utxo, recipient_address, issuer_avatar, symbol, content, change_address, change, fee)
    .then( tx => wallet.sign(tx))
    .then( stx => {
        console.log('signed transaction: ' + stx)
        //Encode (serialize) the transaction
        return stx.encode()
    })
    .then( (raw_tx) => {
        console.log('Encoded transaction: ' + raw_tx.toString('hex'))
    })

Transfer MIT

Metaverse.transaction_builder.transferMIT(utxo, sender_avatar, recipient_address, recipient_avatar, symbol, change_address, change, fee)
    .then( tx => wallet.sign(tx))
    .then( stx => {
        console.log('signed transaction: ' + stx)
        //Encode (serialize) the transaction
        return stx.encode()
    })
    .then( (raw_tx) => {
        console.log('Encoded transaction: ' + raw_tx.toString('hex'))
    })

Attach message

To attach a message to any transaction there is a function called addMessage. If you use the transaction builder you can use the messages parameter to add an array of messages that will be added to the transaction. For manual addition of messages you can do the following:

//Transaction object
var tx = new Metaverse.transaction();
//Add inputs
tx.addInput("tK8UKnBKhk4NQYhSeSb2zeWgMSZaHsn1TY", "15a3a80a867315ee1d3f1ff67e7d5cd0709b1a1d4a48a938f33b01ec8f47425f", 0);
//Add message
tx.addMessage("tK8UKnBKhk4NQYhSeSb2zeWgMSZaHsn1TY", "hi. this is so easy!");
//Don't forget the change
tx.addOutput("tK8UKnBKhk4NQYhSeSb2zeWgMSZaHsn1TY", "ETP", 299990000);

Decode transaction

You can also easily decode a hex encoded transaction.

Metaverse.transaction.decode(rawtx)

Not all information about the previous outputs of the inputs are enoded in a raw transaction. If you want to encode the transaction again you have to add the missing values to the inputs.

Testing

To run the unit tests just execute:

npm test