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

casper-cep78-js-client

v1.5.1

Published

CEP78 Enhanced NFT JS Client

Downloads

32

Readme

casper-cep78-js-client

This package was created to help JS/TS users with the cep-78-enhanced-nft and is published in npm as the casper-cep78-js-client. It was built on top of the casper-js-sdk.

Users can treat this package as a deploy builder for all of these possible interactions:

  • contract installation including different configurations
  • token minting
  • token transfers
  • token burning
  • approvals
  • changing configurations after installation
  • setting token metadata
  • storing some of the contract-related data in an Account's NamedKeys

Usage

  1. To install, run:

    npm i -S casper-cep78-js-client

  2. Import the contract in your code:

    import { CEP78Client } from 'casper-cep78-js-client'

  3. If you want to install it, look at the install method and all of the possible configuration options (InstallArgs).

  4. If you want to start working with a previously installed contract, use the setContractHash(contractHash) method.

NOTE: Since version 1.3 both casper-js-sdk and @make-software/ces-js-parser are peer dependencies. If you are using npm version <7 you may need to install both dependencies manually.

Examples

As a good starting point, you can look into the examples/ directory to see the most common usage scenarios (install.ts and usage.ts). You can install the contract and run the example scenario by running the npm run example:install and npm run example:usage. You will need to specify environment variables, preferebly in a client-js/.env file. Here are some example values for the environment variables that need to be specified:

NODE_URL=http://localhost:11101/rpc
NETWORK_NAME=casper-net-1
MASTER_KEY_PAIR_PATH=/Users/someuser/.casper/casper-node/utils/nctl/assets/net-1/faucet
USER1_KEY_PAIR_PATH=/Users/someuser/.casper/casper-node/utils/nctl/assets/net-1/users/user-1

Events Handling

As CEP-78 1.2 supports two events modes - CEP47 and CES we have two parsers as a part of this SDK.

  • Example usage of CEP47 parser
import { EventStream, EventName } from 'casper-js-sdk';
import { CEP47EventParserFactory, CEP47Events } from 'casper-cep78-js-sdk';

const cep47EventParser = CEP47EventParserFactory({
  contractPackageHash,
  eventNames: [
    CEP47Events.Mint,
    CEP47Events.Transfer,
    CEP47Events.Burn
  ],
});

const es = new EventStream(EVENT_STREAM_ADDRESS);

es.subscribe(EventName.DeployProcessed, async (event) => {
  const parsedEvents = cep47EventParser(event);

  if (parsedEvents?.success) {
    console.log(parsedEvents.data);
  }
});

es.start();
  • Example usage of CES parser
import { EventStream, EventName, CasperServiceByJsonRPC } from 'casper-js-sdk';
import { CESEventParserFactory } from 'casper-cep78-js-sdk';

const casperClient = new CasperServiceByJsonRPC(NODE_URL);

const cesEventParser = CESEventParserFactory({
  contractHashes: [contractHash],
  casperClient,
});

const es = new EventStream(EVENT_STREAM_ADDRESS);
es.subscribe(EventName.DeployProcessed, async (event) => {
  const parsedEvents = await cesEventParser(event);

  if (parsedEvents?.success) {
    console.log(parsedEvents.data);
  }
});
es.start();