Skip to content

Instantly share code, notes, and snippets.

View vibern0's full-sized avatar
🥸
do you even blockchain?

Bernardo vibern0

🥸
do you even blockchain?
View GitHub Profile
@vibern0
vibern0 / gist:fa70e8c28761bf5dedf1236beb0cd926
Created November 12, 2019 23:28 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
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;
[
{
"inputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
pragma solidity ^0.5.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
/**
* @title Simple Storage
* @dev A simple way to save a number.
*/
contract SimpleStorage {
{
setXEntities(
where:
{
x_gt: 4,
x_lt: 9,
timestamp_gt: 1572362160,
timestamp_lt: 1572362179
}
) {
type SetXEntity @entity {
id: ID!
x: BigInt! # uint256
by: Bytes!
timestamp: BigInt! # uint256
}
eventHandlers:
- event: SetX(uint256,address,uint256)
handler: handleSetX
$ npx truffle console - network development
truffle(development)> simpleStorage = await SimpleStorage.deployed()
truffle(development)> await simpleStorage.set(5)
truffle(development)> await simpleStorage.set(8)
{
exampleEntities {
x
}
}
git clone https://github.com/graphprotocol/graph-node/
cd graph-node/docker
./setup.sh
docker-compose up