Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphprotocol/graph-ts

Package Overview
Dependencies
Maintainers
2
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphprotocol/graph-ts

TypeScript/AssemblyScript library for writing subgraph mappings for The Graph

  • 0.3.4
  • npm
  • Socket score

Version published
Weekly downloads
17K
decreased by-9.94%
Maintainers
2
Weekly downloads
 
Created
Source

The Graph TypeScript Library (graph-ts)

npm (scoped) Build Status

TypeScript/AssemblyScript library for writing subgraph mappings to be deployed to The Graph.

Usage

For a detailed guide on how to create a subgraph, please see the Graph CLI docs.

One step of creating the subgraph is writing mappings that will process blockchain events and will write entities into the store. These mappings are written in TypeScript/AssemblyScript.

The graph-ts library provides APIs to access the Graph Node store, blockchain data, smart contracts, data on IPFS, cryptographic functions and more. To use it, all you have to do is add a dependency on it:

npm install --dev @graphprotocol/graph-ts # NPM
yarn add --dev @graphprotocol/graph-ts    # Yarn

After that, you can import the store API and other features from this library in your mappings. A few examples:

import { store, crypto, Entity } from '@graphprotocol/graph-ts'

// This is just an example event type generated by `graph-cli`
// from an Ethereum smart contract ABI
import { NameRegistered } from './abis/SomeContract'

function handleNameRegistered(event: NameRegistered) {
  let name = event.params.name
  let owner = event.params.owner

  // Example use of a crypto function
  let id = crypto.keccak256(name).toHex()

  // Example use of the `Entity` class
  let entity = new Entity()
  entity.setString('id', id)
  entity.setBytes('name', name)
  entity.setAddress('owner', address)

  // Example use of the store API
  store.set('Name', id, entity)
}

API

We will document the functionality provided by graph-ts soon. Until then, please check the types and modules exported from the library source code.

License

Copyright © 2018 Graph Protocol, Inc. and contributors.

The Graph TypeScript library is dual-licensed under the MIT license and the Apache License, Version 2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

FAQs

Package last updated on 07 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc