npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@titan-suite/aion-to-graphql

v0.0.13

Published

Create a graphql server to AION smart contracts

Downloads

25

Readme

ABI to GraphQL Schema

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

Usage:

Install the package with npm or yarn.

    // with yarn (recommended)
    yarn add @titan-suite/aion-to-graphql

    // with npm
    npm install @titan-suite/aion-to-graphql
  1. Once installed,You will also have to specify global.mainAccount and global.gas to withdraw gas from.

  2. You can now create your own graphql server. This means you pass in the Abi , contract instance, Main Account, Gas. Example: { artifact: abi, contract: web3.eth.contract(abi).at(address), mainAccount: web3.personal.listAccounts[0], gas:1500000 }

Example Usage

Checkout the examples in file aion-server.js , test/aion.test.js.

Please note that these examples requires creating a config.js in the root directory with format as follows:

const web3Address = 'REMOTE_NODE_ADDRESS' const mainAccountPass = 'MAIN_ACCOUNT_PASSWORD' module.exports = { web3Address, mainAccountPass }

To Learn More

Checkout Titan IDE

This package will return the schema and rootValue that you can pass into your GraphQL server.

Base Types

We have two base types that help us convert some AION int/uint and Bytes into graphQL schema types. The first is for ints/uints. Whenever a function returns these types, you will have the option of returning either the string and/or int type.

    type Value {
    string: String
    int: Int
    }

The second base type are the bytes types.

    type Bytes {
    raw: String
    decoded: String
    }

When a function returns a bytes, you can choose to return the raw data or the decoded data if desired.

Return Type Templates

Because we are auto generating the Schema, we have to define some standard conversions. We have two templates for accessing the return values from solidity:

  1. Single: ${typeName}_${IndexOfReturn}
  2. Arrays: ${typeName}Arr_${IndexOfReturn}

If you return an address as the third return value you would use: address_2. If you return a uint in the fourth value you would use uint256_3. If you return an array of bytes as the first return you would use bytes32Arr_0.

Writing Queries

To write a query, you must use the function name as the base, pass any variables if any, and then the type name with an index (${typeName}_${IndexOfOutput})

Writing Mutations

To write a mutation, you must use the function name as the base, pass any variables if any. After a Mutation succeeds you will have access to transaction receipt object with keys such blockNumber, blockHash

Inspired By Ethereum-to-GraphQL.