|
| 1 | +import { allocateFrom, deriveChannelKey, randomHexBytes, stake, toGRT } from '@graphprotocol/sdk' |
| 2 | +import hre, { ethers } from 'hardhat' |
| 3 | + |
| 4 | +async function main() { |
| 5 | + const graph = hre.graph() |
| 6 | + const deployer = await graph.getDeployer() |
| 7 | + const [indexer] = await graph.getTestAccounts() |
| 8 | + |
| 9 | + console.log('Deployer:', deployer.address) |
| 10 | + console.log('Indexer:', indexer.address) |
| 11 | + |
| 12 | + const receipt = { |
| 13 | + requestCID: '0x8bec406793c8e1c5d4bd4e059833e95b7a9aeed6a118cbe335a79735836f9ff7', |
| 14 | + responseCID: '0xbdfc41643b5ff8d55f6cdb50f05575e1fdf177fa54d98cae1b9c76d8b360ff57', |
| 15 | + subgraphDeploymentID: '0xa3bfbfc6f53fd8a61b78e0b9a90c7fbe9ff290cba87b045bc476137fb2963cf9', |
| 16 | + } |
| 17 | + |
| 18 | + console.log('Receipt requestCID:', receipt.requestCID) |
| 19 | + console.log('Receipt response CID:', receipt.responseCID) |
| 20 | + console.log('Receipt subgraphDeploymentID:', receipt.subgraphDeploymentID) |
| 21 | + |
| 22 | + const indexerChannelKey = deriveChannelKey() |
| 23 | + console.log('Indexer channel key:', indexerChannelKey.address) |
| 24 | + console.log('Indexer channel key privKey:', indexerChannelKey.privKey) |
| 25 | + |
| 26 | + // Set up indexer |
| 27 | + await deployer.sendTransaction({ value: toGRT('0.05'), to: indexer.address }) |
| 28 | + await graph.contracts.GraphToken.connect(deployer).transfer(indexer.address, toGRT('100000')) |
| 29 | + await stake(graph.contracts, indexer, { amount: toGRT('100000') }) |
| 30 | + await allocateFrom(graph.contracts, indexer, { |
| 31 | + channelKey: indexerChannelKey, |
| 32 | + amount: toGRT('100000'), |
| 33 | + subgraphDeploymentID: receipt.subgraphDeploymentID, |
| 34 | + }) |
| 35 | +} |
| 36 | + |
| 37 | +main().catch((error) => { |
| 38 | + console.error(error) |
| 39 | + process.exitCode = 1 |
| 40 | +}) |
0 commit comments