Skip to content

Javascript SDK Documentation

Ezra Weller edited this page Nov 10, 2019 · 4 revisions

Version: Pre-alpha

High-level functionality

The Squad SDK aims to enable game developers to build games incorporating community-created and curated components, formats, and other game elements. Using the SDK, a game's community can

  1. submit game elements,
  2. buy them,
  3. curate them (via curation markets), and
  4. license and profit off their contributions.

(All of this functionality also applies to games themselves.)

The SDK is also being used to build squad.games, a game store and launcher for games submitted in the squad ecosystem (games submitted to the metastore and curation market).

The SDK is currently implemented only in Javascript (as we are starting with web games), but we hope to implement it in many environments in the future.

API

runGame(definition)

Run a game by inputting a game's metadata into the runner associated with the game definition.

Inputs:

registerRunner(type_, runner)

Register a new game runner (e.g. code that takes in game metadata and launches the game).

Inputs:

  • type_: string (the game type it will run)
  • runner: function (the runner)

metastore

The metastore API: used to store and pass around metadata for games and game elements in a p2p manner. Built on Holochain.

curation

The curation API: used to create automated token markets for games and game elements (curved bonds), associated with metadata in the metastore. Also includes "curation market" features (discoverability powered by market activity). Built on Ethereum and requires a connection to Web3.

newDefinitionWithBond(definition, addressOfCurve, initialBuyUnits, opts)

Function combining metastore and curation APIs: for a new game element, creates a new metadata entry in the metastore and a new curved bond (token market) in the curation market.

Inputs:

  • definition: definition
  • addressOfCurve: string (Ethereum smart contract address, this is a parameter for creating the automatic token market)
  • initialBuyUnits: positive integer (number of tokens the submitter would like to buy initially)
  • opts: web3 transaction object (this includes the tokens used to buy the initialBuyUnits)

Returns:

  • Holochain address (the address of the newly created metastore entry, which is also the effective address of the curation market)