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 🙏

© 2024 – Pkg Stats / Ryan Hefner

meta-contract-debug

v1.0.5

Published

Meta Contract SDK

Downloads

3

Readme

Meta-Contract SDK

This sdk helps you to interact with MVC meta contracts

Please read the documentation for more.

How to install

npm install meta-contract --save

How to use(FT)

Init

const { FT } = require('meta-contract')

const { signers, signerSelecteds } = await FT.selectSigners()
const ft = new FT({
  network: 'testnet', //mainnet or testnet
  purse: '', //the wif of a mvc address to offer transaction fees
  feeb: 0.5,
  signers,
  signerSelecteds,
})

Genesis

Define a token with name,symbol,decimal number. You should save the returned values.(genesis、codehash、sensibleId)

let { txid, genesis, codehash, sensibleId } = await ft.genesis({
  genesisWif: CoffeeShop.wif,
  tokenName: 'COFFEE COIN',
  tokenSymbol: 'CC',
  decimalNum: 3,
})

Issue

Issue 1000000000000 tokens

let { txid } = await ft.issue({
  genesis: genesis,
  codehash: codehash,
  sensibleId: sensibleId,
  genesisWif: CoffeeShop.wif,
  receiverAddress: CoffeeShop.address,
  tokenAmount: '1000000000000',
  allowIncreaseIssues: false, //if true then you can issue again
})

Transfer

Transfer from CoffeShop to Alice and Bob

let { txid } = await ft.transfer({
  senderWif: CoffeeShop.wif,
  receivers: [
    {
      address: Alice.address,
      amount: '5000000',
    },
    {
      address: Bob.address,
      amount: '5000000',
    },
  ],
  codehash: codehash,
  genesis: genesis,
})

Query Balance

Query token's balance

let { balance, pendingBalance, utxoCount, decimal } = await ft.getBalanceDetail({
  codehash,
  genesis,
  address: Alice.address,
})

How to use(NFT)

Init

import {API_NET, API_TARGET, mvc, NftManager} from "meta-contract"


// Generate new seed , need to memorize this mnemonic or use your own
// let mnemonic = mvc.Mnemonic.fromString(cute siren parrot merit swamp plate federal buddy sing tourist family tragic)
let mnemonic = mvc.Mnemonic.fromRandom()
console.log(mnemonic.toString())
let hdPrivateKey = mnemonic.toHDPrivateKey("", "testnet").deriveChild("m/44'/0'/0'");
console.log(hdPrivateKey.publicKey.toAddress("testnet").toString())
console.log(mnemonic.toHDPrivateKey("", "testnet").deriveChild("m/44'/0'/0'").privateKey.toString());
// use this private key to sign txs later
const privKey = mnemonic.toHDPrivateKey("", "testnet").deriveChild("m/44'/0'/0'").privateKey.toString()
const nftManager = new NftManager({apiTarget: API_TARGET.MVC, network: API_NET.TEST, purse: privKey});
// todo remove authorize in the future
nftManager.api.authorize({authorization: "METASV_KEY"})

Genesis

Define the NFT with totalSupply You should save the returned values.(genesis、codehash、sensibleId)

const result = await nftManager.genesis({totalSupply: "10"})
console.log(result)

Mint

Mint a NFT to CoffeeShop's address metaTxId is created by metaid which stands for NFT State

// todo generate metaId tx before mint
const mintResult = await nftManager.mint({
    metaOutputIndex: 0,
    metaTxId: "0000000000000000000000000000000000000000000000000000000000000000",
    sensibleId: result.sensibleID
});
console.log(mintResult)

Transfer

Transfer #1 NFT from CoffeShop to Alice

const result = await nftManager.transfer({
    codehash: "48d6118692b459fabfc2910105f38dda0645fb57",
    genesis: "4920af2eb18493255e662b07d1d80610de7cb2e3",
    receiverAddress: "mymqKrpZjY31ABhPXfXjfVcUd78L1LCHEv",
    senderWif: privKey,
    tokenIndex: "1"
});
console.log(result)

Sell

Sell #1 NFT

let { sellTx, tx } = await nft.sell({
  codehash,
  genesis,
  sellerWif: Alice.wif,
  tokenIndex: '1',
  satoshisPrice: 2000,
})

Cancel Sell

Cancel Sell #1 NFT

let { unlockCheckTx, tx } = await nft.cancelSell({
  codehash,
  genesis,
  tokenIndex: '1',
  sellerWif: Alice.wif,
})

Buy

Buy #1 NFT

let { unlockCheckTx, tx } = await nft.buy({
  codehash,
  genesis,
  tokenIndex: '1',
  buyerWif: Bob.wif,
})

Example

Go to examples