somnia-agents-json-fetch

Fetch public JSON via REST and ABI-encode selected values into Solidity types.

2|2|Updated May 19, 2026
One-click install
npx skills add https://github.com/somnia-chain/agentathon --skill somnia-agents-json-fetch-somnia-chain
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: somnia-agents-json-fetch
Source: https://github.com/somnia-chain/agentathon/tree/main/somnia-agents-skills/skills/somnia-agents-json-fetch
Command: npx skills add https://github.com/somnia-chain/agentathon --skill somnia-agents-json-fetch-somnia-chain

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It turns any public REST JSON response into a deterministic on-chain-ready value, removing the need to manually parse JSON off-chain and then reformat it for smart contracts.

Core Features & Use Cases

  • Fetch-and-ABI-encode JSON values: Performs an HTTP GET, selects a value via dot-notation, then ABI-encodes it to a requested Solidity type (string, uint, int, bool, and array variants).
  • Decimal scaling for fixed-point numbers: Converts JSON numeric values into uint256/int256 using a caller-provided decimals precision rule suitable for prices and token amounts.
  • Deterministic consensus-ready agent behavior: Supports Majority/Threshold style consensus patterns so multiple validator fetches can agree on the final value for oracle workflows.

Use cases include price feeds, weather oracles, sports-score markets, governance snapshots, and any contract needing REST API data delivered as strongly typed ABI results.

Quick Start

Use somnia-agents-json-fetch to read the value at selector bitcoin.usd from a CoinGecko Bitcoin price endpoint and return it as a uint256 scaled with decimals=8.

Frequently Asked Questions about somnia-agents-json-fetch

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fetch JSON from a REST API and encode it for a Solidity smart contract?

To fetch JSON from a REST API and encode it for Solidity, perform an HTTP GET request, parse the response, select a value via dot-notation, and ABI-encode it into the requested Solidity type.

How does decimal scaling work when converting JSON numbers to uint256 for oracle workflows?

Decimal scaling for JSON to uint256 conversion applies a caller-provided precision rule to numeric values, ensuring fixed-point numbers like prices and token amounts are accurately scaled for on-chain oracle workflows.

Can I extract an array value from a REST JSON response and ABI-encode it as a Solidity type?

Yes, you can extract array values from a REST JSON response by traversing the selector path with array indexing, then ABI-encode the final result into requested Solidity array types.

What happens if the dot-notation selector path is invalid or the JSON shape is incompatible?

If the dot-notation selector path is invalid or the JSON shape is incompatible, the fetch and ABI-encoding process will fail immediately to prevent incorrect data from reaching the smart contract.

Does this JSON to Solidity ABI encoding approach support consensus patterns for validator agreement?

Yes, the JSON to Solidity ABI encoding mechanism supports deterministic consensus-ready behavior, allowing multiple validator fetches to agree on the final value for Majority or Threshold style oracle workflows.

What types of on-chain oracle data can I retrieve using REST JSON fetching and ABI encoding?

REST JSON fetching and ABI encoding supports on-chain oracle use cases including price feeds, weather data, sports scores, and governance snapshots by delivering strongly typed ABI results to smart contracts.