promotional bannermobile promotional banner

OpenComputers: Crypto Mining Addon

Tier 1-3 mining cards for OpenComputers: Rebooted that hash for ForgeCoin (FRG), an in-game only currency with no real-world value, plus the ADB Light, a colored lamp you control from Lua.
Mining room with ADB Lights

Mining room with ADB Lights

Description

OpenComputers: Crypto Mining Addon (OC:CMA)

OpenComputers: Crypto Mining Addon adds Tier 1-3 mining cards: SHA-256 hashing hardware for your OpenComputers computers, built for ForgeCoin (FRG), an in-game blockchain. ForgeCoin is an in-game currency only and has no real-world value. This mod does not mine any real cryptocurrency and does not connect to any external network. All hashing happens inside your Minecraft world, for programs and economies you build in game.

This version provides the mining hardware only. A ForgeCoin floppy disk with ready-to-use blockchain, pool and miner software is coming in a future update.

It also adds the ADB Light, a full-block lamp that computers can control.

Requirements

  • Minecraft 1.21.1
  • NeoForge 21.1.266 or newer
  • Java 21
  • OpenComputers: Rebooted 1.9.4-5 or newer (required)
  • OpenComputers: Driver Addon (OC:DA) 0.3.0 or newer (required)

Mining cards

Card Hashes per second Energy per hash Recipe
Tier 1 30 83.3 FE 2 gold nuggets, microchip (tier 2), data card (tier 1)
Tier 2 75 66.7 FE 2 gold ingots, CPU (tier 1), 2 microchips (tier 3), data card (tier 2)
Tier 3 150 50 FE 2 diamond chips, CPU (tier 3), 2 microchips (tier 3), data card (tier 3)

Each card can save up at most one second of hashes and starts with an empty budget. All cards on a server share a global budget (30000 hashes per second by default), so mining cannot overload a server. A single mine call does at most 8 hashes.

All values can be changed in config/opencomputers-crypto-mining-addon-common.toml.

The in-game OpenComputers manual has a page for the cards (open it from the card, or from the mining card tab).

Lua API: mining

Method Description
mine(prefix, count, difficulty) Hashes prefix .. nonce for up to count nonces, starting at a random nonce. On a hit returns nonce, hashHex, hashesDone, signatureHex; otherwise nil, nil, hashesDone. hashesDone == 0 means the budget is used up: sleep for a tick and retry. Unused hashes are returned to the budget and refunded in energy.
verify(prefix, nonce, sig) true if sig is a signature returned by mine on any mining card in this world. Costs no budget and no energy.
hash(data) Single SHA-256 of data as lowercase hex. Costs one hash. Returns nil when the budget is used up.
getBudget() Hashes available right now, and the card's hashes per second.
getInfo() Table with tier, hashesPerSecond, maxPerCall, energyPerHashFE, energyPerHash.

Details:

  • The hash is sha256(prefix .. tostring(nonce)); difficulty is the number of leading zero bits of the raw digest (0-256).
  • Signatures use a secret key per world that Lua programs can never read, so a found block can be proven with verify but not forged.
  • prefix may be at most 1024 bytes and data at most 1044 bytes.
  • Without enough energy for a single hash, mine and hash return nil, "not enough energy".

ADB Light

A full-block lamp that is an OpenComputers component itself: connect it to a computer with cables or place it next to one (no Adapter needed). Its color is shown as the block's tint, and its light level follows the brightness. Blinking lights all switch in sync, about once per second.

Recipe (shaped):

i G i      i = iron ingot, G = glowstone dust
G M G      M = microchip (tier 1)
i C i      C = cable

It is in the OpenComputers creative tab.

Lua API: adb_light

Method Description
setColor(rgb) Set the color as 0xRRGGBB.
getColor() Get the color as 0xRRGGBB. Default 0xFFFFFF.
setBrightness(level) Set the brightness from 0 (off) to 15.
getBrightness() Get the brightness. Default 15.
setBlink(enabled) Enable or disable blinking.
isBlinking() Whether the light is blinking.

Example

Mine for a hash with 16 leading zero bits and light the lamp green when one is found:

local component = require("component")
local miner = component.mining
local light = component.adb_light

light.setColor(0xFF0000)
while true do
  local nonce, hash, done, sig = miner.mine("block42:", 8, 16)
  if nonce then
    print("Found nonce " .. nonce .. ": " .. hash)
    light.setColor(0x00FF00)
    break
  elseif done == 0 then
    os.sleep(0.05) -- budget used up, wait a tick
  end
end

For pack makers

  • Server and client both need the mod.
  • The global hash budget keeps mining cheap for the server; tune it in the config file.

License

Code: MIT. The mining card textures are in the public domain (CC0 1.0).

OpenComputers: Crypto Mining Addon Team

profile avatar
  • 6
    Projects
  • 2.7K
    Downloads

More from AdamDeBeersView all