OpenBook Quickstart
Prerequisites
Install and configure Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shCheck if Rust is installed
rustc --version
cargo --versionWARNING
Make sure you add the Rust toolchain to your PATH
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.xyzTokens
solana airdrop 0.2Now 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:
xY9r3jzQQLYuxBycxfT31xytsPDrpacWnyswMskn16sLet's begin by writing out our
lib.rsfile.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?