shopk v0.0.4

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.

Installation

Recommended: Install via installer (handles dependencies automatically):

wget run https://raw.githubusercontent.com/Twijn/cc-misc/main/util/installer.lua shopk
View on GitHub →

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:

wget https://raw.githubusercontent.com/Twijn/cc-misc/main/util/shopk.lua

Examples

Using with Runtime Installation

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

Usage Examples

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()

Functions

module.on(event, listener)

View source on GitHub

Register an event listener

Parameters:

module.run()

View source on GitHub

Start the WebSocket connection and enter the main event loop This function blocks until the connection is closed

module.close()

View source on GitHub

Close the WebSocket connection and stop reconnecting

module.me(cb?)

View source on GitHub

Get information about the current wallet

Parameters:

module.send(data, cb?)

View source on GitHub

Send a Kromer transaction

Parameters: