-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFirst-Get-Request.lua
41 lines (36 loc) · 1.17 KB
/
First-Get-Request.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
local json = require("json")
_0RBIT = "BaMK1dfayo75s3q1ow6AO64UDpD9SEFbeE8xYrY2fyQ"
_0RBT_TOKEN = "BUhZLMwQ6yZHguLtJYA5lLUa9LQzLXMXRfaq9FVcPJc"
FEE_AMOUNT = "1000000000000" -- 1 $0RBT
BASE_URL = "https://api.diadata.org/v1/assetQuotation/Arweave/0x0000000000000000000000000000000000000000"
ReceivedData = ReceivedData or {}
--[[
Handler to send 1 $0RBT and a GET request to the `0rbit` process.
]]
Handlers.add(
"Get-Request",
Handlers.utils.hasMatchingTag("Action", "First-Get-Request"),
function(msg)
Send({
Target = _0RBT_TOKEN,
Action = "Transfer",
Recipient = _0RBIT,
Quantity = FEE_AMOUNT,
["X-Url"] = BASE_URL,
["X-Action"] = "Get-Real-Data"
})
print(Colors.green .. "You have sent a GET Request to the 0rbit process.")
end
)
--[[
Handler to receive the data from the `0rbit` process.
]]
Handlers.add(
"Receive-Data",
Handlers.utils.hasMatchingTag("Action", "Receive-Response"),
function(msg)
local res = json.decode(msg.Data)
ReceivedData = res
print(Colors.green .. "You have received the data from the 0rbit process.")
end
)