| Instance | Branch |
|---|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { SetX } from '../generated/Contract/Contract';; | |
| import { SetXEntity } from '../generated/schema'; | |
| export function handleSetX(event: SetX): void { | |
| let entity = SetXEntity.load(event.transaction.hash.toHex()); | |
| if (entity == null) { | |
| entity = new SetXEntity(event.transaction.hash.toHex()); | |
| } | |
| // Entity fields can be set based on event parameters | |
| entity.x = event.params.x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "inputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "constructor" | |
| }, | |
| { | |
| "anonymous": false, | |
| "inputs": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.5.0; | |
| import "@openzeppelin/contracts/math/SafeMath.sol"; | |
| /** | |
| * @title Simple Storage | |
| * @dev A simple way to save a number. | |
| */ | |
| contract SimpleStorage { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| setXEntities( | |
| where: | |
| { | |
| x_gt: 4, | |
| x_lt: 9, | |
| timestamp_gt: 1572362160, | |
| timestamp_lt: 1572362179 | |
| } | |
| ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type SetXEntity @entity { | |
| id: ID! | |
| x: BigInt! # uint256 | |
| by: Bytes! | |
| timestamp: BigInt! # uint256 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| eventHandlers: | |
| - event: SetX(uint256,address,uint256) | |
| handler: handleSetX |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ npx truffle console - network development | |
| truffle(development)> simpleStorage = await SimpleStorage.deployed() | |
| truffle(development)> await simpleStorage.set(5) | |
| truffle(development)> await simpleStorage.set(8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| exampleEntities { | |
| x | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git clone https://github.com/graphprotocol/graph-node/ | |
| cd graph-node/docker | |
| ./setup.sh | |
| docker-compose up |