OpenBook Quickstart

circle-info

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

Prerequisitesarrow-up-right

Install and configure Rustarrow-up-right

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

Check if Rust is installedarrow-up-right

rustc --version
cargo --version
circle-exclamation

Make sure you add the Rust toolchain to your PATH

Finally, let's go ahead and install the Solana CLI toolsarrow-up-right

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

Switching to the Eclipse Devnetarrow-up-right

Now set your solana cli to the Eclipse Devnetarrow-up-right

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

Tokensarrow-up-right

solana airdrop 0.2

Now you should be good to go!arrow-up-right


Writing the smart contract:arrow-up-right

Interfacing with OpenBookarrow-up-right

  • 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:arrow-up-right

  • 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?