A Kromer cryptocurrency API client for ComputerCraft that provides real-time transaction monitoring and wallet operations through WebSocket connections. Features: Real-time transaction monitoring via WebSocket, automatic reconnection on connection loss, transaction sending with metadata support, wallet information retrieval, metadata parsing for structured data, and event-driven architecture.
Recommended: Install via installer (handles dependencies automatically):
This pattern downloads and runs libraries at runtime, automatically installing any that are missing:
-- Auto-install and require libraries
local libs = {"shopk"} -- Add more libraries as needed
local libDir = (fs.exists("disk") and "disk/lib/" or "/lib/")
local allExist = true
for _, lib in ipairs(libs) do
if not fs.exists(libDir .. lib .. ".lua") then
allExist = false
break
end
end
if not allExist then
shell.run("wget", "run", "https://raw.githubusercontent.com/Twijn/cc-misc/main/util/installer.lua", table.unpack(libs))
end
local shopk = require(libDir .. "shopk")
-- Use the library
-- (your code here)
Alternative: Direct download via wget:
This example shows how to download and use libraries with automatic installation:
-- Auto-install and require libraries
local libs = {"shopk"} -- Add more libraries as needed
local libDir = (fs.exists("disk") and "disk/lib/" or "/lib/")
local allExist = true
for _, lib in ipairs(libs) do
if not fs.exists(libDir .. lib .. ".lua") then
allExist = false
break
end
end
if not allExist then
shell.run("wget", "run", "https://raw.githubusercontent.com/Twijn/cc-misc/main/util/installer.lua", table.unpack(libs))
end
local shopk = require(libDir .. "shopk")
-- Use the library
local shopk = require("shopk")
local client = shopk({ privatekey = "your_key" })
client.on("ready", function()
print("Connected!")
client.me(function(data)
print("Balance:", data.balance)
end)
end)
client.on("transaction", function(tx)
print("Received:", tx.value, "from", tx.from)
end)
client.run()
module.on(event, listener)Register an event listener
event ("ready"|"transaction"|"transactions"): Event type to listen forlistener (function): Function to call when event occursmodule.run()Start the WebSocket connection and enter the main event loop This function blocks until the connection is closed
module.me(cb?)Get information about the current wallet
cb? (function): Optional callback to receive wallet datamodule.send(data, cb?)Send a Kromer transaction
data (ShopkSendData): Transaction detailscb? (function): Optional callback to receive transaction result