Orbit Quests Guide
Updating the Systemβ
apt update && apt upgrade -y
NodeJS and NVMβ
Installing NodeJSβ
curl -sL https://deb.nodesource.com/setup_21.x | sudo -E bash -
apt-get install -y nodejs
apt update -y && apt upgrade -y
Installing NVMβ
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install 22
nvm use v22.2.0
npm install -g npm@latest
Installing the AOβ
npm i -g https://get_ao.g8way.io
Quests
Price Feed Botβ
Learning Process IDβ
aos orbit --cron 30-seconds
Creating 0rbit-Price-Feed.lua Fileβ
Write the Process ID (PID) and GITHUB username in the values ββbelow.
PID=YOUR_PROCESS_ID
GITHUB=YOUR_GIHUB_HANDLE
tee $HOME/0rbit-Price-Feed.lua > /dev/null << EOF
-- PID $PID
local json = require("json")
_ORBIT = "WSXUI2JjYUldJ7CKq9wE1MGwXs-ldzlUlHOQszwQe0s"
function handleError(msg, errorMessage)
    ao.send({
        Target = msg.From,
        Tags = {
            Action = "Error",
            ["Message-Id"] = msg.Id,
            Error = errorMessage
        }
    })
end
Handlers.add("$GITHUB",
    Handlers.utils.hasMatchingTag("Action", "Sponsored-Get-Request"),
    function(msg)
        local token = msg.Tags.Token
        if not token then
            handleError(msg, "Token not provided")
            return
        end
        
        local url = "https://api.coingecko.com/api/v3/simple/price?ids=" .. token .. "&vs_currencies=usd"
        ao.send({
            Target = _ORBIT,
            Action = "Get-Real-Data",
            Url = url
        })
        print("Pricefetch request sent for " .. token)
    end
)
Handlers.add("ReceiveData",
    Handlers.utils.hasMatchingTag("Action", "Receive-Response"),
    function(msg)
        print("Received data: " .. msg.Data)
        local res = json.decode(msg.Data)
        local token = msg.Tags.Token
        if res[token] and res[token].usd then
            ao.send({
                Target = msg.From,
                Tags = {
                    Action = "Price-Response",
                    ["Message-Id"] = msg.Id,
                    Price = res[token].usd
                }
            })
            print("Price of " .. token .. " is " .. res[token].usd)
        else
            handleError(msg, "Failed to fetch price")
        end
    end
)
EOF
Running the AOSβ
aos orbit --cron 30-seconds
Loading the Processβ
.load 0rbit-Price-Feed.lua
Running the Monitorβ
.monitor
Checking the ETH Priceβ
Send({ Target = ao.id, Action="Sponsored-Get-Request", Tags = { Token = "ethereum" }})
Cloning The Repoβ
After cloning the repo, create a folder named price-feed-bot-GithubUsername, add the image of the output of the last code and your 0rbit-Price-Feed.lua file.
NEWS Feed Botβ
Learning Process IDβ
aos 0rbitNewsFeed --cron 30-seconds
Creating 0rbit-News-Feed.lua Fileβ
Write the Process ID (PID) in the values ββbelow.
PID=YOUR_PROCESS_ID
tee $HOME/0rbit-News-Feed.lua > /dev/null << EOF
-- ao.id $PID
local json = require("json")
local _0RBIT = "WSXUI2JjYUldJ7CKq9wE1MGwXs-ldzlUlHOQszwQe0s"
local URL = "https://api.theblockbeats.news/v1/open-api/open-flash?size=5&page=1&type=push"
ReceivedData = ReceivedData or {}
Handlers.add(
    "Get-Request",
    Handlers.utils.hasMatchingTag("Action", "Sponsored-Get-Request"),
    function(msg)
         Send({
             Target = _0RBIT,
             Action = "Get-Real-Data",
             Url = URL
        })
        print("GET Request sent to the 0rbit process.")
    end
)
Handlers.add(
    "Receive-Data",
    Handlers.utils.hasMatchingTag("Action", "Receive-Response"),
    function(msg)
        if not msg.Data then
            print("No data received.")
            return
        end
        local res = json.decode(msg.Data)
        ReceivedData1 = res.data.data
        local extractedData = {}
        for k, v in ipairs(ReceivedData1) do
                table.insert(extractedData, {
                    title = v.title,
                    description = v.content
                })
            ReceivedData = extractedData
        end
        print("Processed data: " .. json.encode(ReceivedData1))
    end
)
local function getLatestData(msg)
    local data = json.encode(ReceivedData)
    Handlers.utils.reply(data)(msg)
    print("Latest data sent: " .. data)
end
Handlers.add(
    "GetLatestData",
    Handlers.utils.hasMatchingTag("Action", "Get-Latest-Data"),
    getLatestData
)
local function fetchNewsPeriodically()
     Send({
         Target = _0RBIT,
         Action = "Get-Real-Data",
         Url = URL
     })
    print("Periodic GET Request sent to the 0rbit process.")
end
Handlers.add(
    "CronTick",
    Handlers.utils.hasMatchingTag("Action", "Cron"),
    fetchNewsPeriodically
)
EOF
Running the AOSβ
aos orbit --cron 30-seconds
Loading the Processβ
.load 0rbit-News-Feed.lua
Running the Monitorβ
.monitor
Checking the News Feedβ
Send({ Target = ao.id, Action="Sponsored-Get-Request"})
Send PR the Repoβ
After cloning the repo, create a folder named news-feed-bot-GithubUsername, add the image of the output of the last code and your 0rbit-Price-Feed.lua file, and then send a PR.
In the repo cloned in the first task, create a folder named news-feed-bot-GithubUsername and add the image of the output of the last code and your 0rbit-News-Feed.lua file.
Finally, send PR.