✍️Build Documentation

xAndria SDK

we're open source! Here's a link to our Github Repo: https://github.com/SolCharms/xAndria

This README is intended to cater to experienced developers with a focus on protocol level program interactions. To simply use the protocol as an end-user, visit ------ where you will be greeted with nice graphical interfaces and buttons which do things.

Disclaimer

October 15 2023:

The project, codenamed xAndria, is still un-audited open-source software. As it stands, the program has only been deployed to devnet. As such, no real harm can result from it's use. However, any use of this software via a Mainnet deploy is done so at your own risk and the developer induces zero liabilty in doing so. (Edit: Indeed, see the Program Improvements / Debugging section at the end of this readme to grasp how much was learned just in the process of this demonstration and how much is left to do to have a fully 'fleshed-out' product).

Furthermore, any speculative positions in this demo are purely hypothetical and intended for use as educational tools only. They are not to be construed as having any financial relevance whatsoever, nor insight into the financial markets, nor financial advice.

Prelude

Open the terminal and cd into the desired working directory (For me it's ~/Development/Solana/SDKs).

Clone the Repository using the command 'git clone'. You should now have a local copy of the project as something like ~/Development/Solana/SDKs/xAndria/

To conveniently use the program's CLI functionality from any directory without having to account for relative paths or typing out the absolute path to the CLI's directory every time, we will create a shorthand path alias. Open your .bashrc file (located in the Home directory) and add the following line at the bottom of the textfile:

alias forum-cli='ts-node ~/Development/Solana/SDKs/xAndria/src/forum.cli.ts'

accounting for the fact that your path to the forum.cli.ts file may be slightly different depending on where in your filesystem you put the cloned repository.

The remainder of this demonstration assumes a familiarity with Solana's CLI. You will need to create filesystem wallet keypairs and airdrop yourself some Solana to follow along with the demo.

Configuration

In order to use the program we need to create some filesystem wallets and then configure the .ts files in ../src/cli/config_devnet/

To make filesystem wallets run the Solana CLI command:

solana-keygen new --outfile ~/path-to-file/name-of-file.json

I've gone ahead and created 6 wallets and airdropped each of them about 5-10 Sol.

  • /home/SolCharms/.config/solana/devnet-forum/forum_manager.json

  • /home/SolCharms/.config/solana/devnet-forum/user_1.json

  • ...

  • ...

  • ...

  • /home/SolCharms/.config/solana/devnet-forum/user_5.json

There are 7 configuration files and we will edit them as needed throughout the demonstration. They are:

  • the network configuration

  • the forum configuration

  • the about me configuration

  • the bigNotes configuration

  • the question configuration

  • the answer configuration

  • the comment configuration

The choice for using configuration files was two-fold. For one, since there are multiple public keys / numerical values required for many of the commands, and users can have a multitude of accounts of each type, storage files would be necessary anyways. And secondly, entering multiple options in the process of a command would require a tedious copying/pasting process which configuration files ultimately forego. Nonetheless, the command line interface built here tries to be as flexible as possible, forcing you to use configuration files when it is absolutely in your best interest and otherwise giving you the flexibility to enter options manually.

The network configuration (../config_devnet/networkConfig-devnet.ts) is necessary right away. We will first set up the configuration from the perspective of someone who will initialize and manage a forum (later we will also do it from the perspective of other users). Two inputs are required:

the clusterApiUrl
the signerKeypair

Here's what mine looks like:

Initializing a Forum

The forum is where all the business takes place. It is an account that stores all the data needed protocol-wide. To initialize a forum account, one must decide on all the protocol fees and all the ways reputation can be earned. To configure a forum, we need to input all the required parameters into the config file (../config_devnet/forumConfig-devnet.ts). Here's mine:

Notice that all quantities of Sol are entered in terms of Lamports (the conversion is 1 Sol = 10^9 Lamports). This holds true for any SPL-Tokens as well. That is, as integer multiples of their respective smallest denomination and their conversion follows 10^n where n is the token's number of decimals.

Once this file is configured, we will run the command

forum-cli init-forum

The output to the terminal, upon successful transaction, should appear as:

We can view all the forums associated to this manager's pubkey by running

forum-cli fetch-all-forums

which produces an output as:

where mine correctly states that there are 2 forum accounts (one from prior testing). We see all chosen fee and reputation parameters reflected in the account's data.

Suppose however, that we wanted to change some of the parameters (say, answer repuatation to 25, comment reputation to 5 and forum big notes bounty minimum to 2.5 Sol). Updating the config file to reflect the changes

and running the command (with the -f option necessary and being the forum pubkey)

forum-cli update-forum-params -f 5CL3JJC156CrDGvQfWpCcmdW3v2HJQYs6bYe3FhzAJts

A successful transaction outputs

and running the command

forum-cli fetch-forum-by-key -k 5CL3JJC156CrDGvQfWpCcmdW3v2HJQYs6bYe3FhzAJts

displays the changes reflected:

Creating a User Profile

To create a user profile, we will change the network config's signer keypair as follows:

Running the command

forum-cli create-profile -f 5CL3JJC156CrDGvQfWpCcmdW3v2HJQYs6bYe3FhzAJts

the output to the terminal should appear as something like

We can fetch the user profile by running the command

forum-cli fetch-profile-by-key -k FNdJSvCWraqKrELHFdvaHuQHqKNCYKLw1JbbKNdBDHPA

which displays the user profile state account to the terminal as something like

Fetching the forum account, we see that there is now 1 forum profile account present:

The next step after a user's profile has been created is to create an 'about me'. This first requires configuring the file (../config_devnet/aboutMeConfig-devnet.ts) to add the necessary about me text

and then by running the command

forum-cli create-about-me

obtaining an output similar to

Fetching the user profile

we now see that the user profile has an about me and has earned 100 reputation!

We can also view the about me state account by running the command

forum-cli fetch-about-me-by-profile -p FNdJSvCWraqKrELHFdvaHuQHqKNCYKLw1JbbKNdBDHPA

which displays the following output to the terminal

To edit the about me, change the content in the config file and execute

forum-cli edit-about-me

A successful transaction outputs

and the about me account is updated to reflect the changes

I'll later create the remaining user profiles, as necessary.

Asking a Question, Providing an Answer, or Leaving a Comment

To ask a question on the forum, we must first configure the question config file (../config_devnet/questionConfig-devnet.ts). I've gone ahead and grabbed a question off of solana stack exchange as an homage to the inspiriation for xAndria. Here's what the config looks like:

The front end app will have the ability to pick up newline characters, code block delimiters and even latex math equations.

Running the command

forum-cli ask-question

the output to the terminal upon a successful transaction is something of the form

We can fetch the question either by fetching all questions for a given user profile or by the question account's pubkey. Here, running

forum-cli fetch-question-by-key -k 8SMeMaXARPZDJHyBtoPiZiGXW89c731UjKAgqyUdgiLi

the question state account displays to the terminal as

Fetching the forum account again,

we see that there is now 1 question in the count.

We can then edit or add additional content to the question. Showing the addition of content, we first update the config file inputting the additional content to the

const additionalQuestionContent: string[]

Running the command

forum-cli add-to-question -q 8SMeMaXARPZDJHyBtoPiZiGXW89c731UjKAgqyUdgiLi

the output gives

and the updated question state account

reflects the additional desired content.

Now, another user may come along and take interest your question. Being also particularly interested in knowing the answer, the user may choose to supplement the question bounty to help drive up engagement. Running

forum-cli supplement-question-bounty -q 8SMeMaXARPZDJHyBtoPiZiGXW89c731UjKAgqyUdgiLi -x 1000000000

The output to the terminal appears as

and the question account's state

reflects the supplemental bounty contribution.

REMARK: An improtant comment to make in passing is that this bounty is held onchain in a PDA account and can only be released to the owner of the user profile who provided the 'accepted answer'.

Providing an answer or leaving a comment goes much the same way as asking a question does; by first updating the config file, either (../config_devnet/answerConfig-devnet.ts) or (../config_devnet/commentConfig-devnet.ts). Here is an example for an answer config file for a user intending to answer the question posted earlier:

Switching the network config to user 4 and running

forum-cli answer-question

we get an output for a successful transaction as

and the answer state account can be fetched by running

forum-cli fetch-answer-by-key -k 23vTfWpPgGzXrhCmHPDD8A7sBsDgNY9AD95p8H9W16zQ

which gives

I'll go ahead and post some comments without going through all of the details, but to give you an idea of what a typical question stack would look like, here is the following series of interactions following the posted question which can be fetched by running

forum-cli fetch-question-stack -q AWfY9S8GmdQfCJa4bdcTRwZMpnWQLcJfzaqTUbRmf2Mw

Obviously, a front-end application with nice graphical interfaces will present the relevent data to the user in a much more appealing way, with the unhashed content data, but that's neither here nor there for the moment. To accept an answer, the poster of the question (user 2) can run the command

forum-cli accept-answer -q AWfY9S8GmdQfCJa4bdcTRwZMpnWQLcJfzaqTUbRmf2Mw -a 7KevVgZyhART5EyRBrZdL97yvV1jykK9g8aKJtuxV32J

with output to the terminal as follows

We then see that both the question and the accepted answer have been updated to reflect the fact that there is now an accepted answer along with the user profiles

The bounty is transferred to the account owner of the user profile which posted the accepted answer. Here is the transaction signature which you can use to verify it yourself:

txSig: LR5eShjQ6VdEsf7PwxFGqB5nv8d9rp9Fuq4CCLKicazBNiCLX5iEUf9gsSS6CuPuanuMUa9Vfmt47gjvr5FTiYH

Program ToDo's / Improvements / Debugging

  1. Institute instruction fees for certain of the remaining IX's

  2. Implement bounty refund instructions initiated by OP's for questions / big notes that have not received engagement for sufficiently long periods of time.

  3. Consider implications of allowing users to close accounts with seed dependents (current protocol structure)

    • Pros: Users can independently close accounts (despite seed dependents)

    • Cons: Obtain stale data which need new IX's to handle closing such accounts

  4. Build the FE application

The timeframe to complete such work is estimated to be 2-3months. That is, one can expect a mainnet deploy sometime in Q1 2024.

Last updated