OpenBook Quickstart

The goal of this section is to develop a smart contract to interact with the OpenBook deployment on the Eclipse Devnet

Prerequisites

Install and configure Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Check if Rust is installed

rustc --version
cargo --version

Make sure you add the Rust toolchain to your PATH

Finally, let's go ahead and install the Solana CLI tools

sh -c "$(curl -sSfL https://release.solana.com/stable/install)"

Switching to the Eclipse Devnet

Now set your solana cli to the Eclipse Devnet

solana config set --url https://staging-rpc.dev2.eclipsenetwork.xyz

Tokens

solana airdrop 0.2

Now you should be good to go!


Writing the smart contract:

Interfacing with OpenBook

  • We need our smart contract to connect with the OpenBook deployment on Eclipse

  • OpenBook essentially allows us keep records of the trades and transactions that take place on our network.

  • The Eclipse OpenBook deployment has its own API which is essential for us to interact with it.

  • We will mostly follow the standard deployment process for any Solana app

  • We will also need the programId for the OpenBook deployment on the Eclipse Devnet, which is as follows: xY9r3jzQQLYuxBycxfT31xytsPDrpacWnyswMskn16s

  • Let's begin by writing out our lib.rs file.

  • First we need to include the anchor crates and declare the programId

  • Now let's go ahead and write the logic for our smart contract here.

  • Since everything is an account on Solana, we need to define our accounts here.

  • We can also add any required function and its logic here

  • Now let's go ahead and interact with the OpenBook deployment.

  • First let's connect to the Eclipse devnet by supplying the RPC url

  • Now we can use the programId to connect to the OpenBook deployment

  • After this we can write whatever API calls we need

Deploying the smart contract:

  • To deploy the smart contract with anchor we can just do the following:

And then

  • Using this template you can write your own trade functions and deploy it on the Eclipse Devnet.

Last updated

Was this helpful?