Welcome to WakeUp Labs implementation of the Optimism Request For Grants #1 RFG1 from the Optimism Grants Council!
You can take a look at the final Delivery and Feedback Thread in our post at the Optimism Governance Forum.
The service allows anyone to query the blockchain for specific past moments.
This is a service that will be able to query the blockchain for specific moments in the past ⏰. Specifically, the queries will be enabled for any public view function of any smart contract deployed on the Optimism blockchain from its first block until the current moment. It could be extended to any EVM blockchain.
The implementation is fully open source with MIT license.
- Node.js installed on your machine
- Git installed for cloning the repository
- PostgreSQL installed and running or any database deployed
- Clone the repository:
git clone https://github.com/WakeUpLabs/RFG1-Optimism-Project.git
- Complete the environment variables in a
.env
file
URL=
PORT=
RPC_TESTNET_URL=
RPC_MAINNET_URL=
DATABASE_URL=
- URL: The base URL for the application. If you want to run it locally, it will be set to http://localhost.
- PORT: Specifies the port number on which the server will listen for incoming requests.
- RPC_URL: Refers to the Remote Procedure Call (RPC) endpoint for connecting to the Optimism blockchain. This variable is crucial for interacting with the blockchain, fetching data, or executing transactions.
- PRIVATE_KEY: Represents the private key used for authentication or signing transactions. Ensure that this key is kept confidential and not shared publicly.
- DATABASE_URL: Specifies the URL for connecting to the PostgreSQL database.
- Run database migrations:
npm run migrate
- Install dependencies:
npm install
- Start the local server:
npm run start
Our service is designed for easy integration, streamlined maintenance, and adaptable extensibility with external services.
This RESTful API seamlessly interacts with the OP blockchain, persisting invoked functions in a dedicated database. Subsequently, users can conveniently bypass providing ABI information on following interactions.
Moreover, an additional component empowers project owners to populate the database with smart contracts they deem pertinent.
To grasp the full spectrum of possibilities, delve into our sequence diagrams:
This diagram shows how to leverage pre-loaded contracts. In that way, the user could check which are those contracts considered most popular and avoid the need to manually load the ABI information.
Nevertheless, users always have the option to inspect any contract using a generic endpoint by passing the necessary parameters.
Sometimes, examples speak louder than words.
We've also coded the first implementation of these APIs. The main idea behind the integration is to provide a user-friendly UI where users can define a specific Address or ENS and determine the amount of OP tokens it holds on a specific date on the Optimism Blockchain.
Try it out here: https://rfg1-demo.wakeuplabs.link/
For your convenience, WakeUp Labs offers an easier solution by providing a deployed version and dedicated instance that is ready to use and seamlessly integrates with your services via REST APIs. To get started, simply log in to the WakeUp Platform and obtain your free apikey.
To use the service, you need to sign up and create a free API key with your email account.
Once you have completed the registration process, go to the API Key section to view your API key information.
Copy the generated API key and keep it safe, as it will be your credential for accessing our services 🔐
You can explore the service's capabilities in the WakeUp Platform API Docs
Follow the instructions to use the REST API as you please. These are some API endpoints you will find and be able to use to try RFG1 implementation:
- Healthcheck Endpoint: Check the health status of the service.
- Retrieve Wallet Balance: Retrieve the current balance of a wallet.
- Retrieve Wallet Balance at Block: Get the wallet balance at a specific block in the past.
- Retrieve Wallet Balance at Date: Fetch the wallet balance at a specific date in the past.
- Execute Contract Function: Execute a contract
public view
function to get historical data, by input of ABI. - Execute Known Contract Function: Execute a
public view
function of a known contract to get historical data, no ABI input needed. - Get View Functions of Known Contracts: List
public view
functions of known contracts. - Get most popular smart contracts: List
contract addresses
of the most popular contracts loaded previously.