OpenBook Quickstart
INFO
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
Check if Rust is installed
WARNING
Make sure you add the Rust toolchain to your PATH
Make sure you add the Rust toolchain to your PATH
Finally, lets go ahead and install the Solana CLI tools
Switching to the Eclipse Devnet
Now set your solana cli to the Eclipse Devnet
Tokens
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
Lets begin by writing out our
lib.rs
file.First we need to include the anchor crates and declare the programId
Now lets 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 it's logic here
Now lets go ahead and interact with the OpenBook deployment.
First lets 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