0.35.0 • Published 3 days ago

@graphprotocol/graph-ts v0.35.0

Weekly downloads
1,874
License
-
Repository
-
Last release
3 days ago

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 { crypto, store } from '@graphprotocol/graph-ts'
// This is just an example event type generated by `graph-cli`
// from an Ethereum smart contract ABI
import { NameRegistered } from './types/abis/SomeContract'
// This is an example of an entity type generated from a
// subgraph's GraphQL schema
import { Domain } from './types/schema'

function handleNameRegistered(event: NameRegistered) {
  // Example use of a crypto function
  let id = crypto.keccak256(name).toHexString()

  // Example use of the generated `Entry` class
  let domain = new Domain()
  domain.name = name
  domain.owner = event.params.owner
  domain.timeRegistered = event.block.timestamp

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

Helper Functions for AssemblyScript

Refer to the helper-functions.ts file in this repository for a few common functions that help build on top of the AssemblyScript library, such as byte array concatenation, among others.

API

Documentation on the API can be found here.

For examples of graph-ts in use take a look at one of the following subgraphs:

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.

0.35.0

3 days ago

0.34.0

1 month ago

0.33.0

2 months ago

0.32.0

4 months ago

0.30.0

12 months ago

0.31.0

11 months ago

0.29.3

1 year ago

0.29.2

1 year ago

0.29.0

1 year ago

0.29.1

1 year ago

0.28.1

2 years ago

0.28.0

2 years ago

0.28.0-alpha.1

2 years ago

0.28.0-alpha.0

2 years ago

0.27.0-alpha.1

2 years ago

0.27.0

2 years ago

0.27.0-alpha.0

2 years ago

0.26.0

2 years ago

0.25.0

2 years ago

0.24.0-alpha.0

2 years ago

0.24.0-alpha.1

2 years ago

0.24.1

2 years ago

0.24.0

2 years ago

0.23.1

2 years ago

0.23.0

2 years ago

0.23.0-alpha.1

2 years ago

0.22.1

3 years ago

0.22.0

3 years ago

0.22.0-alpha.3

3 years ago

0.22.0-alpha.2

3 years ago

0.23.0-alpha.0

3 years ago

0.22.0-alpha.1

3 years ago

0.22.0-alpha.0

3 years ago

0.20.1

3 years ago

0.20.0

3 years ago

0.19.0

4 years ago

0.18.1

4 years ago

0.18.0

4 years ago

0.17.0

4 years ago

0.16.0

4 years ago

0.15.1

5 years ago

0.15.0

5 years ago

0.14.0

5 years ago

0.13.0

5 years ago

0.12.0

5 years ago

0.11.0

5 years ago

0.10.0

5 years ago

0.9.0

5 years ago

0.6.0

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.0.1

6 years ago