The AssemblyScript Mapping API is the foundational specification for the graph-ts library and the host environment in which subgraph mappings execute. Every subgraph developer writing event handlers, call handlers, or block handlers interacts with this API, which provides the bridge between raw blockchain data and the structured entities stored in the subgraph's database. The specification governs critical host imports for cryptographic functions (crypto.keccak256), data source context management (dataSource.context), logging (log.info), and Ethereum-specific data types (Address, BigInt, Bytes).

AssemblyScript Mapping API
Introduction
The AssemblyScript Mapping API defines the deterministic runtime environment for all subgraph transformation logic on The Graph.
Changes to this API are high-impact events for the entire ecosystem. A modification to a core type, a new required host function, or a deprecation of an existing import can break every active subgraph that depends on the altered behavior. This creates a cascading risk: indexers must upgrade their Graph Node software to support the new API, subgraph developers must refactor and redeploy their mappings, and all downstream API consumers—dApps, wallets, analytics dashboards—must verify that query responses remain consistent after the transition. The deterministic indexing guarantee means that any divergence in mapping execution across indexers will fracture the network's data consensus.
For teams operating production subgraphs, the AssemblyScript Mapping API is not an abstract standard but a direct dependency with a narrow compatibility surface. Chainscore Labs can audit mapping codebases against upcoming API revisions, identify non-deterministic patterns that violate indexing guarantees, and model the downstream impact of host import changes on query consumers. A proactive review before a graph-ts major version bump is the difference between a planned migration and an emergency redeployment.
Quick Facts
Operational impact and compatibility assessment for changes to the subgraph mapping runtime and graph-ts library.
| Area | What changes | Who is affected | Action |
|---|---|---|---|
Host Import APIs | New or modified cryptographic, logging, and data source context functions in the graph-ts library. | Subgraph developers writing AssemblyScript mappings. | Audit mapping code for usage of deprecated imports and test against new runtime versions. |
Runtime Behavior | Changes to deterministic execution guarantees, event ordering, or error handling in the mapping runtime. | Indexers, exchanges, and DeFi protocols consuming indexed data. | Verify indexing determinism across Graph Node versions to prevent state divergence. |
Data Source Contexts | Modifications to the | Subgraph developers using dynamic data sources or multi-chain templates. | Review data source creation logic to ensure context is correctly propagated. |
Cryptographic Functions | Addition or deprecation of hashing and signature verification host imports. | Subgraphs performing on-chain validation or identity verification. | Test all cryptographic assertions against the new API to confirm compatibility. |
Logging and Debugging | Changes to | Indexer operators and developers debugging subgraph failures. | Adjust log aggregation and monitoring to parse new log formats. |
Ethereum JSON-RPC Integration | Alterations to how mappings call | Subgraphs relying on contract state lookups within mappings. | Validate that all |
BigInt and Type System | Updates to | All subgraph developers performing numeric computation. | Run unit tests on all mapping logic involving token amounts, prices, or precision-sensitive math. |
ABI Decoding | Changes to | Subgraphs parsing complex event logs or calldata. | Verify event and function decoding against updated ABI specifications. |
Technical Mechanism
How the AssemblyScript mapping runtime connects subgraph logic to The Graph's host environment via the graph-ts library.
The AssemblyScript Mapping API defines the deterministic execution environment for subgraph transformation logic within The Graph. When a subgraph developer writes mapping.ts files, they are not writing code that runs directly on a bare-metal machine or a standard Node.js runtime. Instead, the code compiles to WebAssembly and executes inside a sandboxed runtime provided by Graph Node. This runtime exposes a set of host imports—functions imported from the host environment—that provide the only bridge between the deterministic mapping logic and external data sources like the Ethereum Virtual Machine, IPFS, or cryptographic primitives. The graph-ts library (@graphprotocol/graph-ts) acts as the typed AssemblyScript interface to these host imports, defining classes like ethereum, crypto, ipfs, and dataSource.
The core mechanism relies on a strict separation of concerns: the mapping code is purely functional and deterministic, while the host imports handle all side effects and data retrieval. For example, when a mapping calls crypto.keccak256(), it invokes a host import that executes the hashing operation outside the WebAssembly sandbox. Similarly, ethereum.call() performs a static call to an Ethereum node managed by the indexer. This architecture ensures that given the same input events and the same block state, every indexer produces identical output, which is the foundation of Proof of Indexing (POI). The API also provides context objects like dataSource.context() and dataSource.address() that allow the same mapping logic to be reused across multiple contract instances, a critical feature for factory-deployed contracts.
Operationally, changes to this API—such as adding new host imports for cryptographic functions, modifying the behavior of ethereum.decode(), or introducing new data source kinds—require coordinated upgrades across the graph-ts library, Graph Node implementations, and all downstream subgraphs. A breaking change in the mapping API can cause subgraphs to fail synchronization, produce non-deterministic results, or become incompatible with newer Graph Node versions. Teams operating subgraphs should monitor graph-ts releases and Graph Node changelogs for API deprecations. Chainscore Labs can audit mapping code for compatibility with upcoming API changes, identify reliance on deprecated host imports, and verify that subgraph logic remains deterministic across indexer implementations.
Affected Actors
Subgraph Developers
Mapping API changes directly impact the core logic of every subgraph. Developers must audit mapping.ts files for deprecated host imports, altered cryptographic function signatures, or new data source context requirements introduced in updated graph-ts versions.
Action Steps:
- Pin
graph-tsversions inpackage.jsonand test against release candidates. - Review changelogs for breaking changes to
crypto.keccak256,dataSource.context, orlogfunctions. - Update manifest
apiVersionif required by the new specification. - Run deterministic indexing tests to verify identical output across Graph Node versions.
Chainscore can audit mapping codebases for compatibility gaps and identify non-deterministic patterns introduced by API migrations.
Implementation Impact
Changes to the AssemblyScript Mapping API directly affect the transformation logic of every subgraph. Developers must assess host import deprecations, new cryptographic requirements, and data source context modifications to prevent indexing failures.
Cryptographic Host Import Changes
The mapping API exposes cryptographic primitives via host imports. Changes to available hash functions, signature verification algorithms, or elliptic curve operations directly affect subgraphs that perform on-chain data validation or identity proofs. A removed or altered crypto import can silently corrupt derived data. Teams should verify their mapping's cryptographic assumptions against the latest API specification and implement fallback patterns where necessary.
Data Source Context Modifications
The dataSource context object provides runtime information about the current indexing source. Changes to its structure, such as new fields for multi-chain support or modified address resolution, can break mappings that depend on context properties. Indexers and developers must ensure their mapping logic handles new context shapes gracefully to avoid crashes during synchronization.
Logging and Debugging Interface
API-level changes to the log module affect how subgraphs emit diagnostic information. New log levels, structured logging requirements, or changes to output formatting can impact indexer monitoring and developer debugging workflows. Operational teams should update their log aggregation pipelines to parse any new formats and ensure critical errors remain visible during indexing.
Deterministic Execution Guarantees
The AssemblyScript Mapping API must enforce strict determinism to ensure all indexers produce identical databases. Any new API feature that introduces non-deterministic behavior—such as timestamps, random number generation, or external API calls—creates a proof of indexing divergence risk. Chainscore can audit your mapping code for non-deterministic patterns and verify compliance with the latest determinism rules.
Subgraph Upgrade Sequencing
When the mapping API introduces breaking changes, subgraph developers must coordinate a version upgrade that maintains backward compatibility for existing API consumers. A poorly sequenced upgrade can disrupt dApp frontends, analytics pipelines, and downstream services. Chainscore can plan your subgraph version transition, including deprecation windows and consumer communication strategies.
Compatibility and Risk Matrix
Operational impact and required actions for teams building, maintaining, or consuming subgraphs when the AssemblyScript mapping runtime or graph-ts library changes.
| Area | What changes | Who is affected | Action |
|---|---|---|---|
Host Import APIs | Addition, deprecation, or signature change to host functions (e.g., crypto, dataSource, log) | Subgraph developers, indexer operators | Audit mapping code for deprecated imports; test against new Graph Node version before release |
graph-ts Library | New types, utility functions, or breaking changes to existing class methods | All subgraph developers | Pin graph-ts version in package.json; run full test suite against updated library; review changelog for removed methods |
Data Source Context | Changes to dataSource.context(), address, or network fields | Subgraph developers using dynamic data sources | Verify context access patterns; check for assumptions about field availability after data source creation |
Cryptographic Primitives | New or modified crypto host imports (keccak256, sha256, ripemd160) | Subgraph developers implementing hashing logic | Validate hash outputs against known test vectors; confirm availability of new primitives before deploying |
Logging Interface | Changes to log level behavior, output format, or log filtering | Indexer operators, subgraph developers debugging mappings | Review log output format for monitoring tool compatibility; adjust log level usage to avoid excessive indexer overhead |
Ethereum Value Types | Changes to BigInt, BigDecimal, Bytes, Address, or ByteArray handling | All subgraph developers | Check for implicit conversion changes; test edge cases with large numbers and zero-value handling |
Entity and Store API | Modifications to store.set, store.remove, or entity instantiation patterns | Subgraph developers, dApp frontend teams | Verify entity creation and update logic; test GraphQL query responses for schema consistency after migration |
JSON and Data Parsing | Changes to JSON parsing host imports, try_fromBytes, or data extraction helpers | Subgraph developers processing complex event data | Test parsing of malformed or edge-case event data; confirm error handling behavior aligns with expected failure modes |
Developer Migration Checklist
A structured checklist for subgraph development teams preparing to migrate mapping logic in response to changes in the AssemblyScript Mapping API or `graph-ts` library. Each item identifies a critical verification step, explains why it matters for deterministic indexing and query integrity, and specifies the signal or artifact that confirms readiness.
Review every graph-ts host import (e.g., crypto, ethereum, store, log, dataSource) used in your mapping handlers. API upgrades may deprecate, rename, or alter the behavior of these imports.
Why it matters: Host imports are the bridge between AssemblyScript mapping logic and the indexer's runtime. A changed or removed import will cause a deterministic indexing failure, corrupting the subgraph's database state across all indexers.
Readiness signal: A complete inventory of all host imports used in your subgraph, with each import verified against the latest graph-ts changelog and the canonical AssemblyScript Mapping API specification. No import is flagged as deprecated or experimental without a documented migration path.
Source Resources
Primary resources for teams reviewing The Graph AssemblyScript Mapping API, graph-ts usage, host imports, deterministic indexing behavior, and subgraph compatibility. Verify implementation details against these sources before upgrading mappings or relying on new runtime functions.
Looking to build on a specific blockchain?
We build smart contracts, DeFi applications, wallets, tokenization platforms, and blockchain infrastructure across the major ecosystems teams choose today. That includes Ethereum, Arbitrum, Optimism, Polygon, Avalanche, Solana, Sui, Aptos, Hedera, Stellar, and NEAR, with support for additional EVM and non-EVM networks based on your product requirements.
EVM ecosystems
- Ethereum
- Arbitrum
- Optimism
- Polygon
- Avalanche
- Cronos

Non-EVM ecosystems
- Solana
- Sui
- Aptos
- Hedera
- Stellar
- NEAR
Additional ecosystems
- Polkadot
- Cosmos
- TON
- Cardano
- Algorand
- Tempo
Also available for Base, appchains, custom EVM networks, and cross-chain product architecture.
Frequently Asked Questions
Common questions from subgraph developers about the AssemblyScript mapping runtime, host imports, and graph-ts library compatibility.
The mapping runtime provides a deterministic set of host imports exposed via the graph-ts library. These include:
- Cryptographic functions:
crypto.keccak256(),crypto.sha256(), andcrypto.ripemd160()for hashing operations. - Data source context:
dataSource.address(),dataSource.network(), anddataSource.context()to access the triggering data source's configuration. - Logging:
log.debug(),log.info(),log.warning(),log.error(), andlog.critical()for structured log output during indexing. - Ethereum utilities:
ethereum.encode(),ethereum.decode(), andethereum.cryptofor ABI encoding/decoding and elliptic curve operations.
Why this matters: Using unsupported host imports causes deterministic indexing failures. Indexers must produce identical database outputs, so any non-deterministic or unavailable import will cause subgraph synchronization errors.
Compatibility signal: Review the graph-ts version specified in your package.json against the Graph Node release notes. New host imports are added in minor graph-ts releases and require corresponding Graph Node versions.
Delivering blockchain solutions for 5+ years.
We have partnered with 50+ leading DeFi protocols, NFT ecosystems, and fintech innovators to build secure, scalable, and capital-efficient blockchain products.
Selected Partners & Clients
“I've been working with Chainscore Labs for last 3+ years, they've consistently delivered with strong ownership across multiple projects. The team is reliable and detail-oriented.”
How to get started?
If you're looking for blockchain integration, ChainScore Labs has 5+ years of experience helping teams build and integrate exchanges, wallets, smart contracts, tokenization solutions, and protocol-connected products, we can help you choose the right path, integrate securely, and get to production faster. Our team consists of experienced blockchain developers and architects who can help you with your blockchain integration needs.
Exploration & Strategy
Define your product goals and choose the right blockchain architecture for your use case.
Architecture & Design
Design the smart contracts, tokenomics, and security parameters of your system.
Development & Integration
Build and integrate with wallets, oracles, and front-end dApps for a seamless experience.
Security & Launch
Comprehensive audits followed by a risk-managed mainnet deployment to protect your users.
Discover our
blockchain development services.
We build production-grade blockchain solutions for top-tier projects across DeFi and Web3.
Need a blockchain engineering team?
Send the project context and we will respond with next steps, scope questions, and a practical path to delivery.


