2.0.1-alpha.6 • Published 7 months ago

@statechannels/nitro-protocol v2.0.1-alpha.6

Weekly downloads
281
License
MIT
Repository
github
Last release
7 months ago

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.

2.0.0-alpha.5

8 months ago

2.0.1-alpha.6

7 months ago

2.0.1-alpha.5

7 months ago

2.0.0-alpha.4

11 months ago

2.0.0-alpha.3

1 year ago

2.0.0-alpha.0

2 years ago

2.0.0-alpha.1

2 years ago

2.0.0-alpha.2

1 year ago

0.17.3

3 years ago

0.17.2

3 years ago

0.17.1

3 years ago

0.17.0

3 years ago

0.16.0

3 years ago

0.15.0

3 years ago

0.14.0

3 years ago

0.13.0

3 years ago

0.12.0

3 years ago

0.11.2

3 years ago

0.11.1

3 years ago

0.11.0

3 years ago

0.10.1

3 years ago

0.10.0

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago

0.8.5

3 years ago

0.8.6

3 years ago

0.8.4

3 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.8.0

3 years ago

0.7.0

4 years ago

0.5.0

4 years ago

0.6.0

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.10

4 years ago

0.3.10-alpha.0

4 years ago

0.3.9-alpha.0

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.2

4 years ago

0.3.4

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago