Giter Club home page Giter Club logo

ethereum-to-graphql's Introduction

Ethereum ABI to GraphQL Scheme

This will consume an ABI object created when deploying a Solidity/Viper/Serpent Smart contract, and return a graphql schema and resolver. This object can be plugged into a the graphql server of your choice.

Setup:

Install the package with npm or yarn.

  1. npm install ethereum-to-graphql
  2. yarn add ethereum-to-graphql

Your server will have to read an abi file and pass it through this package. We return an object that you pass into your graqhQL server.

const express = require('express');
const graphqlHTTP = require('express-graphql');
const graphql = require('graphql')

const app = express();
const MetaCoinArtifact = require('./build/contracts/Metacoin')
const url = 'http://localhost:8545'

const { genGraphQlProperties } = require('ethereum-to-graphql')
const { schema, rootValue } = genGraphQlProperties({ artifacts: [MetaCoinArtifact], provider: { url }, graphql })


app.use('/graphql', graphqlHTTP({
  schema: schema,
  rootValue: rootValue,
  graphiql: true
}));

app.listen(4000);

Testing

To run tests, you will need to have truffle and testrpc installed globally.

  1. Terminal Window 1: cd <this project>
  2. Terminal Window 1: testrpc
  3. Terminal Window 2: cd <this project>
  4. Terminal Window 2: truffle migrate
  5. Terminal Window 2: npm test

ethereum-to-graphql's People

Contributors

sogoiii avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.