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

@statechannels/nitro-protocol

v2.0.1-alpha.6

Published

Smart contracts and typescript libraries for nitro state channel protocol.

Downloads

23

Readme

Smart contracts which implement nitro protocol for state channel networks on Ethereum, Filecoin and other EVM-compatible chains. Includes javascript and typescript support.

:new: There is an accompanying documentation website.

Installation

.../my-statechannel-app> npm install --save @statechannels/nitro-protocol

Getting started

Building your state channel application contract against our interface:

Please see this section of our docs.

Import precompiled artifacts for deployment/testing

const {NitroAdjudicatorArtifact, ConsensusAppArtifact, VirtualPaymentAppArtifact} =
  require('@statechannels/nitro-protocol').ContractArtifacts;

Import typescript types

import {State} from '@statechannels/nitro-protocol';

const state: State = {
  channelNonce: 0,
  participants: ['0xalice...', '0xbob...'],
  appDefinition: '0xabc...',
  challengeDuration: '0x258',
  outcome: [],
  appData: '0x',
  turnNum: 0,
  isFinal: false,
};

For more information see this section of our docs

Import javascript helper functions

import {getChannelId, getFixedPart} from '@statechannels/nitro-protocol';

const channelId = getChannelId(getFixedPart(state));

Development (GitHub)

We use hardhat to develop smart contracts. You can run the solidity compiler in watch mode like this:

npx hardhat watch compilation

For the goerli testnet:

After successfully deploying you should see some changes to addresses.json. Please raise a pull request with this updated file.

INFURA_TOKEN=[your token here] RINKEBY_DEPLOYER_PK=[private key used for rinkeby deploy] yarn contract:deploy-goerli

For mainnet

WARNING: This can be expensive. Each contract will take several million gas to deploy. Choose your moment and gas price wisely!

INFURA_TOKEN=[your token here] MAINNET_DEPLOYER_PK=[private key used for mainnet deploy] yarn contract:deploy-mainnet --gasprice [your-chosen-gasPrice-here]

To a local blockchain (for testing)

Contract deployment is handled automatically by our test setup scripts. Note that a different set of contracts is deployed when testing. Those contracts expose some helper functions that should not exist on production contracts.

Verifying on etherscan

This is a somewhat manual process, but easier than using the etherscan GUI.

After deployment, run

ETHERSCAN_API_KEY=<a-secret> INFURA_TOKEN=<another-secret> yarn hardhat --network rinkeby verify <DeployedContractAddress> 'ConstructorArgs'

for each contract you wish to verify. Swap rinkeby for mainnet as appropriate!

You need to provide both ETHERSCAN_API_KEY and INFURA_TOKEN for this to work. For more info, see the docs.

Verifying NitroAdjudicator on Filecoin Calibration testnet

CALIBRATION_DEPLOYER_PK="<deploy_priv_key>" npx hardhat deploy --tags deploy-fvm --network calibration
npx hardhat starboard-verify NitroAdjudicator <nitro_adjudicator_address>

Starboard is a Filecoin blockchain explorer. The above command utilizes a hardhat plugin called starboard-verify to verify the contract on that explorer.