@cerc-io/nitro-protocol (2.0.0-alpha.4-ts-port-0.1.3)
Installation
@cerc-io:registry=
npm install @cerc-io/nitro-protocol@2.0.0-alpha.4-ts-port-0.1.3
"@cerc-io/nitro-protocol": "2.0.0-alpha.4-ts-port-0.1.3"
About this package
Nitro Protocol
Smart contracts which implement nitro protocol for state channel networks on Ethereum, Filecoin and other EVM-compatible chains. Includes javascript and typescript support.
🆕 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.
Dependencies
Dependencies
ID | Version |
---|---|
@openzeppelin/contracts | ^4.7.3 |
@statechannels/exit-format | ^0.2.0 |
@typechain/ethers-v5 | ^9.0.0 |
Development Dependencies
ID | Version |
---|---|
@nomicfoundation/hardhat-network-helpers | ^1.0.3 |
@nomiclabs/hardhat-ethers | ^2.1.1 |
@nomiclabs/hardhat-etherscan | ^3.0.0 |
@nomiclabs/hardhat-waffle | ^2.0.2 |
@statechannels/devtools | ^0.5.7 |
@typechain/ethers-v5 | ^9.0.0 |
@typechain/hardhat | ^4.0.0 |
@types/jest | ^27.4.1 |
@types/lodash.isequal | ^4.5.5 |
@types/lodash.shuffle | ^4.2.6 |
@types/mocha | ^9.1.0 |
@types/node | ^18.11.3 |
@types/wait-on | ^5.3.1 |
@typescript-eslint/eslint-plugin | ^5.19.0 |
@typescript-eslint/parser | ^5.19.0 |
chai | ^4.3.6 |
dotenv | ^14.3.2 |
eslint | 7.17.0 |
eslint-config-prettier | ^8.5.0 |
eslint-plugin-import | ^2.26.0 |
eslint-plugin-prettier | 3.3.1 |
ethereum-waffle | ^3.4.0 |
ethers | ^5.5.4 |
hardhat | ^2.10.0 |
hardhat-deploy | ^0.10.4 |
hardhat-deploy-ethers | ^0.3.0-beta.13 |
hardhat-gas-reporter | ^1.0.7 |
hardhat-watcher | ^2.3.0 |
jest | ^27.5.1 |
lodash.isequal | ^4.5.0 |
lodash.shuffle | ^4.2.0 |
prettier | ^2.6.2 |
prettier-plugin-solidity | ^1.0.0-beta.19 |
solhint | ^3.3.7 |
solidity-coverage | ^0.7.18 |
ts-jest | ^27.1.3 |
ts-node | ^10.4.0 |
typechain | ^8.0.0 |
typescript | ^4.6.3 |
wait-on | ^6.0.1 |