{"_id":"@graphprotocol/statechannels-contracts","_rev":"70-7f7379bd67d5a633e2f0af84640f79bf","name":"@graphprotocol/statechannels-contracts","dist-tags":{"next":"0.0.2-next.a995f4b.40","latest":"0.0.2"},"versions":{"0.1.0":{"name":"@graphprotocol/statechannels-contracts","version":"0.1.0","license":"MIT","_id":"@graphprotocol/statechannels-contracts@0.1.0","maintainers":[{"name":"alicehenshaw","email":"henshawalice@gmail.com"},{"name":"ytal","email":"yaniv@thegraph.com"},{"name":"jannispohlmann","email":"jannis@thegraph.com"},{"name":"nenadjaja","email":"nena@thegraph.com"},{"name":"fordn","email":"fnickels@gmail.com"},{"name":"lutter","email":"lutter@watzmann.net"},{"name":"davekaj","email":"kajpustd@gmail.com"},{"name":"zerim","email":"brandon.ramirez@live.com"},{"name":"rhlsthrm","email":"rksethuram9@gmail.com"},{"name":"martintel","email":"me@martintel.co"},{"name":"abarmat","email":"abarmat@gmail.com"},{"name":"that3percent","email":"That3Percent@gmail.com"},{"name":"snario","email":"liam@counterfactual.com"},{"name":"geoknee","email":"george@magmo.com"},{"name":"andrew.gord.stewart","email":"andrew.gord.stewart@gmail.com"},{"name":"kerzhner","email":"mikerzhner@gmail.com"},{"name":"tomclose","email":"tom@magmo.com"},{"name":"lagap","email":"alex.gap@consensys.net"},{"name":"nachobonilla","email":"ignacio@openzeppelin.com"},{"name":"jcarpanelli","email":"juanbanelli@gmail.com"},{"name":"leoyvens","email":"leoyvens@gmail.com"},{"name":"hex0punk","email":"alex.useche@trailofbits.com"},{"name":"kristinmayo","email":"kristin.mayo@trailofbits.com"},{"name":"xaler","email":"dariolobuglio@gmail.com"},{"name":"alexo382","email":"alexandrumanuelolteanu@gmail.com"},{"name":"juanmardefago","email":"juanma.rdefago@gmail.com"},{"name":"baboialex95","email":"baboialex95@gmail.com"}],"homepage":"https://github.com/statechannels/graph-payments#readme","bugs":{"url":"https://github.com/statechannels/graph-payments/issues"},"dist":{"shasum":"6e80fbfb9cfe4e94c78ef557c35a609bd21cc1f7","tarball":"https://registry.npmjs.org/@graphprotocol/statechannels-contracts/-/statechannels-contracts-0.1.0.tgz","fileCount":37,"integrity":"sha512-HhzkrO61MGtWguZ4Zd4aGfsSKV2A+4U32QeI+hwSiw8fC+2FeTmcpf5CIkSFDpFd+7i5iK4fCay7xoql3CvOHA==","signatures":[{"sig":"MEYCIQDuPiCaJRG6nycKILw9RYdbObtMKZdKR/4KlN+UYAjbfAIhAO5+/VoONcs6RipagIKbYcZhVjGbMamqzjTYnUiGv+wl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":92730,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf4RJ3CRA9TVsSAnZWagAAM8MP/RBk6WWnzVZvTcAON3CP\nY3u2V1aALc3y8loPZ+RscZQtO7I5hrfiwPE1UjQN9srmcUmp2yYkTDlbZtG6\nxnYDInolU0qiFuZ7GR4PfK2UxwfMtKwnDcIWLiS9VCCpCkw9RQ6tVIjIGGio\nwpYq85ffZN7Ttn5BTpQNHK8nGKfOTga3iK6uxrdrBk8htjsYwcD/nkTWA2b+\nEG+Z6bM+rDsoTf6Wyn7Gerfx2hC1wdBOj1m8g+S9K1a441IwdAS9IDOPu86/\n5TCE57Rf3hWTKVt/pzjUDKcIxj/oKsFS1XQuG8/3xHeKZ4y1dU5VDyzR+V8u\nxCQaoWLLqc8lkAHl7q/Z5PGCDt+m9rZDaiGoyazP6WGXUgZ0xuVsjqDfZrnO\nh5QzDVi9m5vImzVg+od8qwnOFOsWsjFu6xYWYwrgZK6mzTxCriBFAuWuTP1C\n+ssq6iTBsaDJMmMt1i2tE7r9G4HHew4ygJth9/kPXUAvgdnZCRgnHxWjVeyr\n20mRE0e0prb+FSzmfliAJNCXR8xNm3fqtAlu+kpd3Tik4jICmT42OdfdznjI\neW9KjwV0gmTyIdhcDCSFkjEH18fvi4Oe9g63fFzmhElxO2G14++VAdiOpHbN\nGGjdCBgp90LzxkBaHuBtQ8PKA7eEHt/wyvkePG+7LOBLMZ3956/lgC7bom7V\njKmq\r\n=uRTO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/src/index.js","gitHead":"a61a0f783fba67660935d3dd576369a9ed99839e","scripts":{"test":"jest -c ./jest/jest.config.js --onlyFailures --runInBand","bench":"ts-node src/utils/__tests__/benchmark.ts","prepare":"run-s contract:compile build:typescript","test:ci":"yarn test","lint:check":"eslint . --ext .ts --cache && yarn prettier:check","lint:write":"eslint . --ext .ts --fix; yarn prettier:write","prettier:check":"prettier --list-different **/*.sol","prettier:write":"prettier --write **/*.sol","build:typescript":"rm -rf lib; tsc -b .","contract:compile":"yarn hardhat compile --force"},"_npmUser":{"name":"jannispohlmann","email":"jannis@thegraph.com"},"repository":{"url":"git+https://github.com/statechannels/graph-payments.git","type":"git"},"_npmVersion":"lerna/3.16.4/node@v12.16.3+x64 (darwin)","description":"Contracts for the Gateway-Indexer statechannels interaction","directories":{},"_nodeVersion":"12.16.3","dependencies":{"lodash":"4.17.20","@openzeppelin/contracts":"3.2.2-solc-0.7","@graphprotocol/common-ts":"1.0.1","@statechannels/wallet-core":"0.9.8","@statechannels/client-api-schema":"0.4.9"},"_hasShrinkwrap":false,"devDependencies":{"jest":"26.1.0","benny":"^3.6.14","eslint":"^7.7.0","ethers":"5.0.3","hardhat":"^2.0.3","ts-jest":"26.1.1","prettier":"2.0.5","typescript":"4.1.2","@types/jest":"26.0.4","npm-run-all":"4.1.5","@types/eslint":"^7.2.3","@types/lodash":"4.14.161","@types/prettier":"2.1.0","eslint-config-prettier":"6.10.0","eslint-plugin-prettier":"3.1.2","@statechannels/devtools":"0.5.0","prettier-plugin-solidity":"1.0.0-alpha.54","@typescript-eslint/parser":"^3.10.1","@statechannels/nitro-protocol":"0.9.1","@types/eslint-plugin-prettier":"3.1.0","@typescript-eslint/eslint-plugin":"^3.10.1"},"_npmOperationalInternal":{"tmp":"tmp/statechannels-contracts_0.1.0_1608585847204_0.8000301640426011","host":"s3://npm-registry-packages"}},"0.0.2-next.a995f4b.40":{"name":"@graphprotocol/statechannels-contracts","version":"0.0.2-next.a995f4b.40","license":"MIT","_id":"@graphprotocol/statechannels-contracts@0.0.2-next.a995f4b.40","maintainers":[{"name":"alicehenshaw","email":"henshawalice@gmail.com"},{"name":"ytal","email":"yaniv@thegraph.com"},{"name":"jannispohlmann","email":"jannis@thegraph.com"},{"name":"nenadjaja","email":"nena@thegraph.com"},{"name":"fordn","email":"fnickels@gmail.com"},{"name":"lutter","email":"lutter@watzmann.net"},{"name":"davekaj","email":"kajpustd@gmail.com"},{"name":"zerim","email":"brandon.ramirez@live.com"},{"name":"rhlsthrm","email":"rksethuram9@gmail.com"},{"name":"martintel","email":"me@martintel.co"},{"name":"abarmat","email":"abarmat@gmail.com"},{"name":"that3percent","email":"That3Percent@gmail.com"},{"name":"snario","email":"liam@counterfactual.com"},{"name":"geoknee","email":"george@magmo.com"},{"name":"andrew.gord.stewart","email":"andrew.gord.stewart@gmail.com"},{"name":"kerzhner","email":"mikerzhner@gmail.com"},{"name":"tomclose","email":"tom@magmo.com"},{"name":"lagap","email":"alex.gap@consensys.net"},{"name":"nachobonilla","email":"ignacio@openzeppelin.com"},{"name":"jcarpanelli","email":"juanbanelli@gmail.com"},{"name":"leoyvens","email":"leoyvens@gmail.com"},{"name":"hex0punk","email":"alex.useche@trailofbits.com"},{"name":"kristinmayo","email":"kristin.mayo@trailofbits.com"},{"name":"xaler","email":"dariolobuglio@gmail.com"},{"name":"alexo382","email":"alexandrumanuelolteanu@gmail.com"},{"name":"juanmardefago","email":"juanma.rdefago@gmail.com"},{"name":"baboialex95","email":"baboialex95@gmail.com"}],"homepage":"https://github.com/statechannels/graph-payments#readme","bugs":{"url":"https://github.com/statechannels/graph-payments/issues"},"dist":{"shasum":"e4e3b76c8202b0c9a362e328bf20012dc5a63081","tarball":"https://registry.npmjs.org/@graphprotocol/statechannels-contracts/-/statechannels-contracts-0.0.2-next.a995f4b.40.tgz","fileCount":37,"integrity":"sha512-xfBTWR4MhpFmYoa6uSdKyDfCdE8TVhpE/ZH/tXeiArF/QjDhJ8pan/idy0DTY3eTX/lVrKcbv0SMZlM9hL6Plw==","signatures":[{"sig":"MEQCIBWALjo5s7GD04vSZne7zvlckS6mxtHNCrTkgxCYreXuAiBlj97FBMDc0tOm5fwd1pmRaU0GAKsGRx6PUW/hrALp6Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":105780,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgHQ05CRA9TVsSAnZWagAAE6kQAJ6FBk9UXB7uaI+wG2/c\nXpHJXTx9yoAWlD+sPtxXRFnj+kDuc+MlLArX26NS00Ac9YF9yucEFgQbhoRX\nNvI0coOaeBK15AXdF2w1T0tNPQz7Lsuyv0JGe2/CWSJM3bXViNN6qbWXawFR\nYFMmHPoI/1ps792rJ6FfFSP59kBouMjdbYpen8vAK3K4qqObW23ozt4n4zle\n3vzhVC8lIILrjYzks9+swwE3/1lllt7r0ecVGeWBQX9x5Yr/ctWCASrSoVW4\noXLPyCVi4XJBgWvWzM+uH5wpSTUdhZXHzE0z2RBMvMpCJYqFOlIXvHDVFrfc\nqPzDW7SZHDErvJGDwoIR3WDg7sTPwUyayFt4zooq5esmxQbDa4z2Yck8pSqj\nIWd/Ocb1ho7locnUKKStFT6Wl58m/IxElz27jKTTDbGGNafdpQ5eP9T/G+ya\nABomUos2e0NYYeeahqm/XTwyQcKCYTGwTflwoDMGqIZiMeYhEfPmFts/746H\npND3ElYZi29KJO3KfiQz6Ur8nDawLMkupHKSZHxZtxdKC4oX08TFOTc0i4zR\n4VJISXNLcsuE6qiO8y7RVWhlfoE9Wu85p8P40CXmY7Hb7NkNQOczboFRX83G\npCUENWh8IoVpbEAR6tHd5l7nhw8TLI/1LJQMywP5DkonvHYkZA5HZWMZLRGv\n/Flf\r\n=0TqL\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/src/index.js","readme":"# Conditional Graph payments\n\n## What is a `ForceMove` app?\n\n### Short answer\n\n[https://docs.statechannels.org/contract-api/natspec/forcemoveapp/](https://docs.statechannels.org/contract-api/natspec/forcemoveapp/)\n\n### Medium answer\n\nIt's a smart contract that implements a `validTransition` function with the following signature.\n\n```swift\nstruct VariablePart {\n bytes outcome,\n bytes appData\n}\n\nfunction validTransition(\n\tstruct ForceMoveApp.VariablePart a,\n\tstruct ForceMoveApp.VariablePart b,\n\tuint48 turnNumB,\n\tuint256 nParticipants\n) external pure returns(bool)\n```\n\nThe `outcome` is an encoding (using the ethereum ABI encoder) of a non-simple type `OutcomItem[]` where `OutcomeItem` is defined [here](https://docs.statechannels.org/contract-api/natspec/Outcome).\n\nThe `appData` is an encoding of an arbitrary solidity data type, designed specifically for the channel's application.\nIt is entirely possible for `appData` to always be the null `0x` bytes value.\n\n### Example\n\n[This](https://github.com/statechannels/statechannels/blob/ee1a0aa/packages/nitro-protocol/contracts/examples/SingleAssetPayments.sol) is a payment channel where any participant can send any of its peers any amount of its remaining funds, on their turn.\nThis particular app uses no `appData`.\n\n[This](https://github.com/statechannels/apps/blob/master/packages/rps/contracts/RockPaperScissors.sol) is a more complicated example, implementing the rules of Rock Paper Scissors. Thus, it makes use of app data to store game state, such as the current player's move.\n\n## What is the `AttestationApp`?\n\nIt is a `ForceMove` app with the following intended properties:\n\n1. On the gateway's turn, it embeds a query ID (`queryCID`) and an allocation id (`allocationId`) in the app data.\n2. On the indexer's turn, it embeds an attestation in the app data\n   1. It deducts the `paymentAmount` from the gateway's total in the outcome, and adds it to the indexer's total for that allocation. If the indexer hasn't been payed yet through that allocation, a new outcome item is created\n   2. It signs the attestation\n\n**Reminder**: Peers take turns in Nitro state channels. In these channels, the gateway takes even turns, and the indexer takes odd turns. For example, if the current turn number is 7, then it is the gateway's turn to update the channel on turn 8, because it is even.\n\nThe _outcome_ in the AttestationApp should be a single `AssetOutcome` where the asset holder address is the `GRTAssetHolder`.\n\nThe _app data_ in the AttestationApp contains at most one of:\n\n1. A \"Query request\", which is a `bytes32 requestCID` as well as a `uint256 paymentAmount`\n2. An \"Attestation\", which is a `bytes32 responseCID` as well as a signature.\n\nIt is possible for the app data to contain neither of (1) or (2).\nThis is allowed in two cases:\n\n1. In the \"starting state\"\n2. When the indexer declines a query.\n\n### Security\n\nAn honest indexer would\n\n1. execute the query\n2. compute the query result's `responseCID` from the query result\n3. constructs the attestation, which is composed of the `requestCID`, the `responseCID`, and the `subgraphDeploymentID`\n4. signs the attestation\n\nA malicious indexer can skip (1), and put a random value for the `responseCID`.\nThus, signing the attestation does not guarantee that the query result is correct.\n\nThe gateway can, in this case, penalize the indexer's stake by _challenging_ the result. The penalty is very severe, providing an incentive for indexers to be honest.\n\n## Testing\n\nThere is [one positive test case](https://github.com/statechannels/graph-payments/blob/7e545a839cd6cf98ec6a57126e5075e8a3cec9fe/packages/statechannels-contracts/test/attestationStateMachine.test.ts#L158-L161) for each possible (state, event) pair in the happy path.\n\nIn addition, there are [some test cases](https://github.com/statechannels/graph-payments/blob/7e545a839cd6cf98ec6a57126e5075e8a3cec9fe/packages/statechannels-contracts/test/attestationStateMachine.test.ts#L218-L225) of invalid transitions.\n\nThese are tested against contracts deployed to a local ganache network.\n","gitHead":"a995f4bfaa1927f62821bcbd27955beed50875bd","scripts":{"test":"jest -c ./jest/jest.config.js --onlyFailures --runInBand","bench":"ts-node src/utils/__tests__/benchmark.ts","prepare":"run-s contract:compile build:typescript","test:ci":"yarn test","lint:check":"eslint . --ext .ts --cache && yarn prettier:check","lint:write":"eslint . --ext .ts --fix; yarn prettier:write","prettier:check":"prettier --list-different **/*.sol","prettier:write":"prettier --write **/*.sol","build:typescript":"rm -rf lib; tsc -b .","contract:compile":"yarn hardhat compile --force","contract:compile:watch":"yarn hardhat watch compilation"},"_npmUser":{"name":"geoknee","email":"george@magmo.com"},"repository":{"url":"git+https://github.com/statechannels/graph-payments.git","type":"git"},"_npmVersion":"lerna/3.16.4/node@v12.16.3+x64 (linux)","description":"Contracts for the Gateway-Indexer statechannels interaction","directories":{},"_nodeVersion":"12.16.3","dependencies":{"lodash":"4.17.20","@openzeppelin/contracts":"3.2.2-solc-0.7","@graphprotocol/common-ts":"1.0.1","@statechannels/wallet-core":"0.11.0","@statechannels/client-api-schema":"0.8.0"},"_hasShrinkwrap":false,"readmeFilename":"readme.md","devDependencies":{"jest":"26.1.0","benny":"^3.6.14","eslint":"^7.7.0","ethers":"5.0.3","hardhat":"^2.0.3","ts-jest":"26.1.1","prettier":"2.0.5","typescript":"4.1.2","@types/jest":"26.0.4","npm-run-all":"4.1.5","@types/eslint":"^7.2.3","@types/lodash":"4.14.161","@types/prettier":"2.1.0","hardhat-watcher":"^2.0.0","eslint-plugin-import":"2.22.1","eslint-config-prettier":"6.10.0","eslint-plugin-prettier":"3.1.2","@statechannels/devtools":"0.5.3","prettier-plugin-solidity":"1.0.0-alpha.54","@typescript-eslint/parser":"^3.10.1","@statechannels/nitro-protocol":"0.14.0","@types/eslint-plugin-prettier":"3.1.0","@typescript-eslint/eslint-plugin":"^3.10.1"},"_npmOperationalInternal":{"tmp":"tmp/statechannels-contracts_0.0.2-next.a995f4b.40_1612516665340_0.07630560963843869","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"@graphprotocol/statechannels-contracts","version":"0.0.2","license":"MIT","_id":"@graphprotocol/statechannels-contracts@0.0.2","maintainers":[{"name":"alicehenshaw","email":"henshawalice@gmail.com"},{"name":"ytal","email":"yaniv@thegraph.com"},{"name":"jannispohlmann","email":"jannis@thegraph.com"},{"name":"nenadjaja","email":"nena@thegraph.com"},{"name":"fordn","email":"fnickels@gmail.com"},{"name":"lutter","email":"lutter@watzmann.net"},{"name":"davekaj","email":"kajpustd@gmail.com"},{"name":"zerim","email":"brandon.ramirez@live.com"},{"name":"rhlsthrm","email":"rksethuram9@gmail.com"},{"name":"martintel","email":"me@martintel.co"},{"name":"abarmat","email":"abarmat@gmail.com"},{"name":"that3percent","email":"That3Percent@gmail.com"},{"name":"snario","email":"liam@counterfactual.com"},{"name":"geoknee","email":"george@magmo.com"},{"name":"andrew.gord.stewart","email":"andrew.gord.stewart@gmail.com"},{"name":"kerzhner","email":"mikerzhner@gmail.com"},{"name":"tomclose","email":"tom@magmo.com"},{"name":"lagap","email":"alex.gap@consensys.net"},{"name":"nachobonilla","email":"ignacio@openzeppelin.com"},{"name":"jcarpanelli","email":"juanbanelli@gmail.com"},{"name":"leoyvens","email":"leoyvens@gmail.com"},{"name":"hex0punk","email":"alex.useche@trailofbits.com"},{"name":"kristinmayo","email":"kristin.mayo@trailofbits.com"},{"name":"xaler","email":"dariolobuglio@gmail.com"},{"name":"alexo382","email":"alexandrumanuelolteanu@gmail.com"},{"name":"juanmardefago","email":"juanma.rdefago@gmail.com"},{"name":"baboialex95","email":"baboialex95@gmail.com"}],"homepage":"https://github.com/statechannels/graph-payments#readme","bugs":{"url":"https://github.com/statechannels/graph-payments/issues"},"dist":{"shasum":"fefe0a9a91ca62367edc7948f18779e5c9f2d9b1","tarball":"https://registry.npmjs.org/@graphprotocol/statechannels-contracts/-/statechannels-contracts-0.0.2.tgz","fileCount":38,"integrity":"sha512-Eu8f8fUiVOkV2K0YauNZbE6GQ+GUPAMZreENdUzYq2abr3fmM6f5Pm7f7hO1LiPHQMo8l85fNU2+xsX3nKf+Bw==","signatures":[{"sig":"MEUCIGZGQIVcO4KqlEbWzqHsWbalH2GKWZxJsha+d4xaCNg1AiEA3s7yfoTJDjbNWTKEwSxGFvUYsKAKIzIO8DIU6uLHRhU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":106170,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJZ1pCRA9TVsSAnZWagAA/DMP/2lThkyTt0qnt8y+ozcr\nNUyzr8bJKgh3MHjWxgYhvv9wRjDH99ypXv5rmT1r8vrVoK/9pJo1rgzKAWwI\nuVeClyX9D4lSs4SVDUUcKySEjKqdEnN10B2FUGfxbFau4qqxxLJbvRUJFeBm\nTwwOIlJ87cc/psC0bDQT67MOE7TTFUYhHaN03eMEzOmw3cRgbaERNzgPWR7M\nfjMmsAaNzVY5lcMbZ1GVV1SF6Zz/ANHlm/M+S16N7rcpYPauGSjXQWbZkqZ7\nK+ZbqbXnxOzLhE0X2r/YLyUXxK8XyDznN2pzW+JSFOcVClSCXlO8VH+axFYs\nv16Hku2IWn+XDq7rLASNygjzXuGuLb73damk421vmgT4TrXs2Hs/5wFXQdXE\n9XRBSsuqrdy5Hsg6pSoKfd2x/FdPbBBrc1TlXJKai1fZ1sT1JAclpiYIS6fP\nbeFOBgdj22JH1UX28siUMt9pQiaSIWift9jnjdITKwDGwMAv8+YvsIeVMtdP\nybRLuZiCpM0Xq2Dy//JfeEl1wLey56EnNl5orthODD+1m5BZnt0jRKOUOBbS\nbwBDag1bLsfS6zoRUU4W5ixvqMg0S6h3Kj9P0f2zvRqJOnI7jJpqzh9WpW7K\n1hAt0Nk65hSIuA1vTBr9Rv2ecH1Xp37+CTLFcq181iBArhNi5vkUMYBjkD9W\n03ps\r\n=Nnhh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"lib/src/index.js","gitHead":"b48f97181920361cd6206707a3de243dc6703191","scripts":{"test":"jest -c ./jest/jest.config.js --onlyFailures --runInBand","bench":"ts-node src/utils/__tests__/benchmark.ts","prepare":"run-s contract:compile build:typescript","test:ci":"yarn test","lint:check":"eslint . --ext .ts --cache && yarn prettier:check","lint:write":"eslint . --ext .ts --fix; yarn prettier:write","prettier:check":"prettier --list-different **/*.sol","prettier:write":"prettier --write **/*.sol","build:typescript":"rm -rf lib; tsc -b .","contract:compile":"yarn hardhat compile --force","contract:compile:watch":"yarn hardhat watch compilation"},"_npmUser":{"name":"geoknee","email":"george@magmo.com"},"repository":{"url":"git+https://github.com/statechannels/graph-payments.git","type":"git"},"_npmVersion":"lerna/3.16.4/node@v12.16.3+x64 (linux)","description":"Contracts for the Gateway-Indexer statechannels interaction","directories":{},"_nodeVersion":"12.16.3","dependencies":{"lodash":"4.17.20","@openzeppelin/contracts":"3.2.2-solc-0.7","@graphprotocol/common-ts":"1.0.1","@statechannels/wallet-core":"0.12.0","@statechannels/client-api-schema":"0.9.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"26.1.0","benny":"^3.6.14","eslint":"^7.7.0","ethers":"5.0.3","hardhat":"^2.0.3","ts-jest":"26.1.1","prettier":"2.0.5","typescript":"4.1.2","@types/jest":"26.0.4","npm-run-all":"4.1.5","@types/eslint":"^7.2.3","@types/lodash":"4.14.161","@types/prettier":"2.1.0","hardhat-watcher":"^2.0.0","eslint-plugin-import":"2.22.1","eslint-config-prettier":"6.10.0","eslint-plugin-prettier":"3.1.2","@statechannels/devtools":"0.5.4","prettier-plugin-solidity":"1.0.0-alpha.54","@typescript-eslint/parser":"^3.10.1","@statechannels/nitro-protocol":"0.15.0","@types/eslint-plugin-prettier":"3.1.0","@typescript-eslint/eslint-plugin":"^3.10.1"},"_npmOperationalInternal":{"tmp":"tmp/statechannels-contracts_0.0.2_1613077864491_0.4438278198001422","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-12-21T21:24:07.204Z","modified":"2026-09-09T22:31:04.276Z","0.1.0":"2020-12-21T21:24:07.361Z","0.0.2-next.a995f4b.40":"2021-02-05T09:17:45.564Z","0.0.2":"2021-02-11T21:11:04.599Z"},"bugs":{"url":"https://github.com/statechannels/graph-payments/issues"},"license":"MIT","homepage":"https://github.com/statechannels/graph-payments#readme","repository":{"url":"git+https://github.com/statechannels/graph-payments.git","type":"git"},"description":"Contracts for the Gateway-Indexer statechannels interaction","maintainers":[{"email":"ford@edgeandnode.com","name":"fordn"},{"email":"npm@tmigone.com","name":"tmigone"},{"email":"juanma.rdefago@gmail.com","name":"juanmardefago"},{"email":"miguel.deelias@gmail.com","name":"migueldeelias"},{"email":"pdiogo@duck.com","name":"pdiogo-tgf"}],"readme":"# Conditional Graph payments\n\n## What is a `ForceMove` app?\n\n### Short answer\n\n[https://docs.statechannels.org/contract-api/natspec/IForceMoveApp](https://docs.statechannels.org/contract-api/natspec/IForceMoveApp)\n\n### Medium answer\n\nIt's a smart contract that implements a `validTransition` function with the following signature.\n\n```swift\nstruct VariablePart {\n bytes outcome,\n bytes appData\n}\n\nfunction validTransition(\n\tstruct ForceMoveApp.VariablePart a,\n\tstruct ForceMoveApp.VariablePart b,\n\tuint48 turnNumB,\n\tuint256 nParticipants\n) external pure returns(bool)\n```\n\nThe `outcome` is an encoding (using the ethereum ABI encoder) of a non-simple type `OutcomItem[]` where `OutcomeItem` is defined [here](https://docs.statechannels.org/contract-api/natspec/Outcome).\n\nThe `appData` is an encoding of an arbitrary solidity data type, designed specifically for the channel's application.\nIt is entirely possible for `appData` to always be the null `0x` bytes value.\n\n### Example\n\n[This](https://github.com/statechannels/statechannels/blob/ee1a0aa/packages/nitro-protocol/contracts/examples/SingleAssetPayments.sol) is a payment channel where any participant can send any of its peers any amount of its remaining funds, on their turn.\nThis particular app uses no `appData`.\n\n[This](https://github.com/statechannels/apps/blob/master/packages/rps/contracts/RockPaperScissors.sol) is a more complicated example, implementing the rules of Rock Paper Scissors. Thus, it makes use of app data to store game state, such as the current player's move.\n\n## What is the `AttestationApp`?\n\nIt is a `ForceMove` app with the following intended properties:\n\n1. On the gateway's turn, it embeds a query ID (`queryCID`) and an allocation id (`allocationId`) in the app data.\n2. On the indexer's turn, it embeds an attestation in the app data\n   1. It deducts the `paymentAmount` from the gateway's total in the outcome, and adds it to the indexer's total for that allocation. If the indexer hasn't been payed yet through that allocation, a new outcome item is created\n   2. It signs the attestation\n\n**Reminder**: Peers take turns in Nitro state channels. In these channels, the gateway takes even turns, and the indexer takes odd turns. For example, if the current turn number is 7, then it is the gateway's turn to update the channel on turn 8, because it is even.\n\nThe _outcome_ in the AttestationApp should be a single `AssetOutcome` where the asset holder address is the `GRTAssetHolder`.\n\nThe _app data_ in the AttestationApp contains at most one of:\n\n1. A \"Query request\", which is a `bytes32 requestCID` as well as a `uint256 paymentAmount`\n2. An \"Attestation\", which is a `bytes32 responseCID` as well as a signature.\n\nIt is possible for the app data to contain neither of (1) or (2).\nThis is allowed in two cases:\n\n1. In the \"starting state\"\n2. When the indexer declines a query.\n\n### Security\n\nAn honest indexer would\n\n1. execute the query\n2. compute the query result's `responseCID` from the query result\n3. constructs the attestation, which is composed of the `requestCID`, the `responseCID`, and the `subgraphDeploymentID`\n4. signs the attestation\n\nA malicious indexer can skip (1), and put a random value for the `responseCID`.\nThus, signing the attestation does not guarantee that the query result is correct.\n\nThe gateway can, in this case, penalize the indexer's stake by _challenging_ the result. The penalty is very severe, providing an incentive for indexers to be honest.\n\n## Testing\n\nThere is [one positive test case](https://github.com/statechannels/graph-payments/blob/a995f4bfaa1927f62821bcbd27955beed50875bd/packages/statechannels-contracts/test/attestationApp.test.ts#L175-L182) for each possible (state, event) pair in the happy path.\n\nIn addition, there are [some test cases](https://github.com/statechannels/graph-payments/blob/a995f4bfaa1927f62821bcbd27955beed50875bd/packages/statechannels-contracts/test/attestationApp.test.ts#L200-L207) of invalid transitions.\n\nThese are tested against contracts deployed to a local ganache network.\n","readmeFilename":"readme.md"}