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

@cityofzion/props

v0.2.5

Published

an sdk for interfacing with props to use in decentralized applications

Downloads

114

Readme

To install the package: npm install @cityofzion/props --save

Documentation

For a more complete set of project documentation, visit the project documentation.

For SDK specific documentation, visit our sdk documentation

ScriptHashes:

N3 Privatenet (like neo-express):

Scripthashes are baked into the sdk, but can be referenced within each class (example). We also include a configuration enum at types.NetworkOption to make network configuration easy. In most cases, we recommend using this approach. A complete list of configuration options can be found here

import Collection, types from '@cityofzion/props'

collection: Collection = new Collection({
  'network': types.NetworkOption.LocalNet
})
await collection.init()
console.log(collection.scriptHash)

N3 Testnet/Mainnet:

Refer to the relevant contract in the contracts documentation.

Quickstart:

Setup:

To install the package: npm install @cityofzion/props --save

Each contract interface is represented by a class. To interface with a contract, create an instance of the interface as follows:

import Puppet, helpers from '@cityofzion/props'
import {wallet} from '@cityofzion/neon-core'

const node = //refer to dora.coz.io/monitor for a list of nodes.
const scriptHash = //refer to the scriptHashes section above
puppet = await new Puppet({
  'network': types.NetworkOption.LocalNet
})
await puppet.init()
  • Note: For a local neo-express deployment, the class can be initialized without a configuration object ( e.g. new sdk.Collection())*

Other contract interfaces are initialized using the same pattern. Refer to the SDK documentation for a list of available interfaces.

From here, you can quickly interface with the smart contract deployed on the target network.

const symbol = await puppet.symbol() //returns the token symbol
const totalSupply = await puppet.totalSupply() //returns the total supply
const decimals = await puppet.decimals() //returns the decimals

All props classes use a variable invoke mechanism. This means the that method which are traditionally handled by test invocations (like the ones above), can optionally be relayed to the network by providing a user wallet as an optional parameter. When populating this optional field, the response will be a transaction id.

const myAwesomeCOZWallet = new wallet.Account() //remember that you will need some GAS in the wallet in order to pay the transaction fee
const txid = await puppet.symbol(myAwesomeCOZWallet) //relays the transaction to the network and returns the transaction id

await helpers.sleep(5000) //wait for the transaction to publish to a block.  This time will be dependent on the network you are connected to (try 30000 for testnet and mainnet)

const res = await helpers.txDidComplete(node, txid, true) //read the logs and parse the result
console.log(res)