Uses midpointapi.com to return a single cell value from any table or sql request on Tableland
✓ Published0🌍 Public
Aandrewxhill
Last edited Nov 5, 2022
Created on Nov 5, 2022
This example demonstrates how a Solidity smart contract can use the Midpoint API to retrieve a single cell value from any Tableland table or SQL query. The contract wraps the user’s SQL query into a `SELECT ... LIMIT 1` statement and sends it to the Midpoint contract via `callMidpoint`, then handles the asynchronous string response through a callback interface. It uses OpenZeppelin’s `Strings` and `EnumerableMap` libraries to manage request IDs and callback addresses, emitting events for each request and received response. The code shows both a basic query without a callback and a version that routes the response to a user-specified contract implementing `IStringCallback`.
AI-generated description