Quick Start

Execute simple queries

Futaba is still under development and its use may change before its official release.

We do not recommend using Futaba in a production environment at this time.

You can easily retrieve data from other chains as long as you implement send() and receiveQuery().

The structure of the data and what it actually does is described in the protocol section.

Here we will try to implement a contract that gets the balance of any token in any other chain from the src chain and mints a new token of that amount.

The sample code itself is in this repository and can be cloned.

Create new project

In this example we will use hardhat;

$ npx hardhat
888    888                      888 888               888
888    888                      888 888               888
888    888                      888 888               888
8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888
888    888     "88b 888P"  d88" 888 888 "88b     "88b 888
888    888 .d888888 888    888  888 888  888 .d888888 888
888    888 888  888 888    Y88b 888 888  888 888  888 Y88b.
888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888

πŸ‘· Welcome to Hardhat v2.9.9 πŸ‘·β€

? What do you want to do? …
  Create a JavaScript project
❯ Create a TypeScript project
  Create an empty hardhat.config.js
  Quithe

Choose a Typescript project. Choose y on all of the prompts.

First, install the OpenZeppelin package;

Next, install the relay SDK for gelato;

Install dotenv to protect your private key needed to deploy your contract;

At the root of your project, create a new .env file. Here you will store your private key used to deploy your contract.

Update .env with the following line:

Define the interface

First, we need to define the structs involved in the query;

Define an IGateway.sol to execute the query() function;

Also, create IReceiver.sol that defines the receiveQuery() function to receive the results of the query;

Send function

From here, the contract for the actual request is defined. First, define the function that will execute the query request.

Receive function

Create a function that receives the result of the query in the same Contract.

Now that you have finished writing the sample code, compile and deploy it.

Please check here for the target network and contract address.

Executing the Transaction

Here we create a script to execute the query from the client side.

Then run the script with the following command;

Last updated

Was this helpful?