0.2.5 • Published 12 months ago

@cityofzion/props v0.2.5

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

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)
0.2.1

12 months ago

0.2.3

12 months ago

0.2.2

12 months ago

0.2.5

12 months ago

0.2.4

12 months ago

0.2.0

1 year ago

0.1.2

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.0

2 years ago

0.1.1

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago