Home

Awesome

Modern Simple Krist Shop

This is a simple Krist shop that supports many different wallets and configurations.

To install run wget run https://raw.githubusercontent.com/MasonGulu/msks/main/install.lua and edit the configuration files, then set this as your startup program.

Configuration

Setup for the shop is split between two serialized table files

config

This file is where you'll configure the settings for the shop.

Required settings

Optional settings

listings

This file is where you'll configure the items you're selling in your shop

It is a serialized table of listing entries, each entry contains the following values:

* These follow a set of rules for inheriting the defaults. If the entry is set to nil, it will inherit the default setting from config.lua (if applicable). If the entry is set to the empty string "", it will overwrite the default by removing this option. Otherwise this entry will be used as the setting for the field.

Example listings

Listing iron ingots for sale at the default address and name, but custom metaname

  {
    label = "Iron", -- Friendly label
    id = "minecraft:iron_ingot", -- Name of internal item name
    price = 0.25, -- price in KST / Item
    address = nil, -- address for overriding defaultAddress
    name = nil, -- space for overriding name for this item
    metaname = "iron", -- metaname like "iron" of iron@aname.kst 
  },

Listing iron ingots for sale at a custom address, with no name

  {
    label = "Iron",
    id = "minecraft:iron_ingot",
    price = 0.2,
    address = "insertKristAddress",
    name = "",
    metaname = "",
  }

Behavior

The shop will display the name of your shop and who operates the shop at the top of the monitor specified.

Underneath this will be listings, alternating in color, each listing will follow this format:

Count Name        Sendto         KST/Item
100   Cobblestone an@address.kst 0.02

When you send krist to a given address, the shop will handle the transaction by:

Shop Errors

This shop will error safely.

Krist Transaction Websocket Library

This is a library to make transaction tracking easy!

To install this library you'll need ktwsl.lua.

Quickstart

Require the library local ktwsl = require("ktwsl")

Create a krist manager object by calling the function returned (passing in the desired endpoint and your privatekey), local krist = ktwsl("https://krist.dev", privatekey)

Add any addresses you want to listen for transactions from via krist.subscribeAddress("anAddressOrNameHere"). This supports addresses AND names, so aname@alt.kst is as valid as kziwwr5hm9. You can subscribe or unsubscribe from addresses at any time, including while the krist manager is running, without any additional effort.

Once you want your krist manager to start throwing events for transactions simply call krist.start() in parallel with other code you'd like to run.

There are two events to listen for

Some notes

Example

local krist = require("ktwsl")("https://krist.dev", "aprivatekeylol")
krist.subscribeAddress("iron@alt.kst")

local function transactionHandler()
  while true do
    local event, to, from, value, transaction = os.pullEventRaw()
    if event == "terminate" then
      krist.stop()
      error("Terminated")
    elseif event == "krist_stop" then
      krist.stop()
      error("Websocket died: "..to)
    elseif event == "krist_transaction" then
      print(value.."kst was sent to "..to.." from "..from)
    end
  end
end

parallel.waitForAny(krist.start, transactionHandler)

krist.stop()

Advanced Use

You can choose to replace the event handler called for websocket events.

The default event handler takes a websocket event, checks if it's a transaction, and then queues the events documented above for the end user's use.

To replace the event handler use krist.setEventHandler