Skip to main content
Address: 0x0000000000000000000000000000000000001003 The Sei JSON precompile lets EVM applications parse and query JSON data efficiently, directly within smart contracts. Solidity does not support this kind of complex data handling natively. The precompile makes it easier to work with structured data from external sources or APIs.
What is a precompile? A precompile is a special smart contract that the Sei protocol itself deploys at a fixed address. It exposes custom native chain logic to EVM-based applications. To the EVM, it behaves like a regular contract, but it executes privileged, low-level logic efficiently.

How does the JSON precompile work?

The JSON precompile at address 0x0000000000000000000000000000000000001003 exposes extractAsBytes(), extractAsBytesList(), extractAsBytesFromArray(), and extractAsUint256().
  • EVM contracts and dApps can call the JSON parsing functions directly, like any other smart contract method.
  • JSON parsing runs at the native level, which makes it efficient.
  • You do not need complex workarounds or external libraries to handle JSON.

Use cases

  • Oracle integration: Parse complex oracle responses that contain multiple data points.
  • DeFi applications: Process structured price feeds and market data.
  • Gaming: Handle complex game state and player data stored in JSON format.
  • Cross-chain communication: Parse messages and data from other chains.
  • NFT metadata: Extract and manipulate NFT metadata stored in JSON format.

Functions

The JSON precompile exposes these functions:

Query functions

Using the precompile

Setup

Prerequisites

Before you start, make sure that you have:
  • Node.js (v18 or higher)
  • The npm or yarn package manager
  • MetaMask or another compatible EVM wallet, configured for Sei Mainnet
  • SEI tokens for gas

Install dependencies

Install the required packages to interact with Sei precompiles:

Import precompile components

Precompile address: The JSON precompile is deployed at 0x0000000000000000000000000000000000001003.

Contract initialization

Set up your provider, signer, and contract instance:

Data type handling

The JSON precompile has specific limitations for different data types:

Supported data types

Value length limit: Make sure that the numeric values you pass stay within 100 characters. extractAsUint256 rejects value strings longer than 100 characters. If the numeric string extracted for the given key is longer than this, the call fails with value string too long.

Data type conversion strategies

Error handling utilities

Add error handling to all extraction functions:

Step-by-step guide: Using the JSON precompile

Extract string data

Extract numeric data

Extract array data

Extract nested data

Extract the parent object and parse it manually. The JSON precompile does not support dot notation for nested objects.

Complete integration example

Create a complete JSON parsing application for Sei Mainnet:
json-precompile-mainnet.mjs

Running the mainnet example

  1. Create a new directory and initialize npm:
  1. Install dependencies:
  1. Create a .env file:
Never commit private keys to version control. Add the .env file to your .gitignore.
  1. Create the demo file: Copy the complete integration example above into json-precompile-mainnet.mjs.
  2. Make sure that you have SEI tokens:
    • SEI for gas (view functions need only small amounts)
  3. Run the script:

Expected output

Advanced usage examples

Oracle price feed integration

Troubleshooting

Common issues and solutions

Key not found

Error code reference

Key considerations and tricks

  • Integers only: extractAsUint256 handles only integers. It does not handle decimals, booleans, or negative numbers.
  • Decimal handling: Store decimal numbers as integers with known precision. For example, use 275 for 2.75 with 2 decimal places.
  • Boolean values: Use the integer 0 for false and 1 for true.
  • Key paths: Extract parent objects first, then parse them manually. Dot notation may not be supported.
  • Arrays: Object-keyed arrays use extractAsBytesList(). JSON arrays by index use extractAsBytesFromArray().
  • Gas costs: Large JSON objects need higher gas limits.
  • Encoding: Always use UTF-8 encoding with ethers.toUtf8Bytes().
  • Error handling: Always implement fallback values for production applications.
Need help? If you have a problem that this page does not cover, look for community support in the Sei Discord or the GitHub repository.