> For the complete documentation index, see [llms.txt](https://future-ai-1.gitbook.io/future-ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://future-ai-1.gitbook.io/future-ai/overview-future-ai/future-ai-executors/script-developer.md).

# Script Developer

### A brief description of how to develop an oracle script on Future-AI:

*Future-AI currently only supports scripts written in shell script*

For an script, the number of input arguments must be at least two. The first one: ***$1*** is reserved for execution type of the script. For now, the validators only accept three execution types: ***aiDataSource***, ***testcase***, and ***aggregation***. Other types will not be read, and unexpected behaviours may happen. The first type collects all the AI data source names that the oracle wants to execute, while the second type gets all the test cases it prefers. The last type, on the other hand, is the business logic of the oracle script, which is responsible for processing all the results retrieved from the data sources. Indeed, all the results are put in a string passed to the second argument ***$2*** with a delimiter, which is ***-***, and it is the oracle script's job to process these values to come up with a final result to be returned back to Future-AI. An example of an oracle script that is syntaxtically correct is below:

```
#!/bin/bash

# the number of parameters are fixed depending on the total data sources run
route() {
  if [[ $1 = "aiDataSource" ]]
  then 
    echo "crypto_compare_btc coindesk_btc coingecko_btc" # return names of the data sources
  elif [[ $1 = "testcase" ]] # return names of the test cases
  then
    echo "testcase_price"
  elif [[ $1 = "aggregation" ]] # $2 is true output, $3 is expected output
  then
    # collect input string with a delimiter of each data source value separated with a '-' delimiter
    IFS='-' read -ra array <<< "$2"
    aggregation_result=0
    size=0
    # here is the algorithm for each oracle script. This should be different based on the oscript
    for i in "${array[@]}"; do
      let "size+=1"
      # process "$i"
      aggregation_result=`echo $aggregation_result + $i | bc`
      #$aggregation_result = $aggregation_result + $i
    done
    temp=$aggregation_result
    # scale=2 allows division with floating points (two decimals)
    aggregation_result=$(echo "scale=2; ($temp) / $size" |bc) # |bc allows adding two floating point numbers
    echo "$aggregation_result"
  else
    echo 0
  fi
}

route_name="$(route $1 $2 $3 $4)"
echo $route_name
```

#### Note:

#### *-> In order to deploy an oracle script on Future-AI, all sufficient data sources and test cases provided in the script need to be on the network already.*

*->If a data source or a test case change its name, the oracle script deployer must manually edit his script. Otherwise, the script will not run properly because it cannot find the correct data source or test case.*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://future-ai-1.gitbook.io/future-ai/overview-future-ai/future-ai-executors/script-developer.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
