---
# System prepended metadata

title: Tool Analysis

---


# Tool Analysis
- Table of Content
[ToC]


## Solana SDK's for Go Language
Solanas JSON RPC has a dynamic nature in which for a given procedure, depending on the parameters fed to the procedure, its response will acquire a different shape/structure. We wish to analyze/define a strategy to deal with this nature within the Go language. 

* [gagliardetto](https://github.com/gagliardetto/solana-go)
* [portto](https://github.com/portto/solana-go-sdk)
> Missing **[test case](https://github.com/portto/solana-go-sdk/blob/main/rpc/get_account_info_test.go)** for GetAccountInfo in which encoding param is set to JsonParsed. Nevertheless it still handles different data types.


## Codigo-io/codigo-solana-api   [:link:](https://github.com/Codigo-io/codigo-solana-api)
This repository shared to us (CF) is a personal effort realized by Jaziel to understand the underlying technologies that will be used for Codigo-io's graphql gateway to the solana blockchain.
### Pros
* Project folder organization es very clear.
* Exhaustive [README.md](https://github.com/Codigo-io/codigo-solana-api/blob/develop/README.md) documentation. 
* Comments in graphql schemes provide automatic documentation.
* Proper use of scalar definitions provided by graphql framework.
> Links on how they are used: 
> **[schema](https://github.com/Codigo-io/codigo-solana-api/blob/develop/schemas/base.graphql)**
> **[models](https://github.com/Codigo-io/codigo-solana-api/blob/develop/gqlgen.yml)** in config file
### Cons
* Implementation of solanarpc queries have limited optional parameters or are hardcoded. 

> Example: **[getAccountInfo](https://docs.solana.com/developing/clients/jsonrpc-api#json-rpc-api-reference)** presents a dynamic behaviour returning at least two possible data types depending on which encoding is passed. The given implementation allows for only one encoding option (jsonParsed) which presents two problems. 
> * On the one hand **[ the solana node must have a parser for the owning program](https://docs.solana.com/developing/clients/jsonrpc-api#parsed-responses)**. Therefore only a handful of accounts will be able to be consulted by this method. 
> * On the other when consulting an account for which the node does not have a parser, solanarpc **[documentation](https://docs.solana.com/developing/clients/jsonrpc-api#parameters)** established that the encoding falls back to base64 returning a json that cannot be unmarshaled by the current implementation.

#### Run solana-rpc-api playground 
```shell!
$ export NETWORK=https://api.mainnet-beta.solana.com
$ go run main.go

# execute the following query in the playground. 
query='
{ getAccountInfo(address: "5F7LGsP1LPtaRV7vVKgxwNYX4Vf22xvuzyXjyar7jJqp") {
  lamports
  owner
  data
  executable
  rentEpoch
}
}
'

response='
{
  "data": {
    "getAccountInfo": {
      "lamports": 3591360,
      "owner": "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin",
      "data": null,
      "executable": false,
      "rentEpoch": 360
    }
  }
}
'

```

####  Run query using curl. Compare data field 
```shell!
$ curl $NETWORK -X POST -H "Content-Type: application/json" -d '
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getAccountInfo",
    "params": [
      "5F7LGsP1LPtaRV7vVKgxwNYX4Vf22xvuzyXjyar7jJqp",
      {
        "encoding": "jsonParsed"
      }
    ]
  }
'
response='
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "apiVersion": "1.13.3",
      "slot": 155852414
    },
    "value": {
      "data": [
        "c2VydW0DAAAAAAAAAD8MCftL7WJQXXF4EBcHgy5wOaahK22tiViXfyjpQJ9DAAAAAAAAAABicctxGUdrnc4A2BXI/zFfyL99KEhjPTSUKt/VNfLe/sb6evO+2606PWXzaqvJdDGxu+TC0vbg5HymAgNFL11hNse4IY8IxO6wx8GJLNu2d+f4aDO+BKH9nO6sEY/yXaiANaklnAIAAAAAAAAAAAAAThHsyvoZU5AJtqj8HD3Hqvkcw4f3rfSVeOi+p+eL1FTbGKveFwAAAGWDV0UAAAAAZAAAAAAAAACICB2etxBWyyez2OPMDQ8Wtc6ihewFCMjVJ9hRdOgS9Kl4FxzBmJVLmlwLP4vFMd3KJteRo8jdER2HP8DusZvV+JEdC2NtvSj3gSCm+VmYYy7wtZgO4qdAvwcAPbD3+S2AWmHQ7tXCxvlm7GLpBCQmIMxphc2Fdt/LQGuaCo9GG4CWmAAAAAAAZAAAAAAAAAAAAAAAAAAAAIYyDAcAAAAAcGFkZGluZw==",
        "base64"
      ],
      "executable": false,
      "lamports": 3591360,
      "owner": "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin",
      "rentEpoch": 360
    }
  },
  "id": 1
}
'
```
* Proposed [tests](https://github.com/Codigo-io/codigo-solana-api/compare/develop...test-implementation-research) only exercises code that was generated automatically by graphql [framework](https://github.com/99designs/gqlgen). 
> Filtering fields property in graphql is provided by the framework as is. What the framework does let you do is configure resolvers per field so as to optimize lookups according to fields the user wishes to resolve. In the tutorials section **[don't eagerly fetch the user](https://gqlgen.com/getting-started/#dont-eagerly-fetch-the-user)** this is explained. It must be noted that the tutorial code incorrectly implements the CreateTodo resolver. A correct implementation can be found **[here](https://github.com/vektah/gqlgen-tutorials/blob/master/gettingstarted/graph/schema.resolvers.go)**.      


