Skip to content

codius-deprecated/codius-host-mvp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codius Host MVP

Minimal implementation of a Codius host

Running Codius Host MVP allows you to experiment with Codius on your machine. It's updated to use Interledger payments with HTTP-ILP.

For a complete explanation of Codius, go to codius.org.

Usage

Use ILP Curl to pay a Codius host to run your code. The following code assumes that you're running Codius host on port 8002. It uses the example_manifest.json file in the root of this repository.

npm install -g ilp-curl
ilp-curl -X POST local.codius.org:8002/start --json --data @example_manifest.json

You'll get the following response:

{
  "expiry": "2017-11-11T01:27:59.876Z",
  "expiryHuman": "in an hour",
  "manifestHash": "ced14b8b019f2f548bbe2c309d5dd9edc45346a6f4e3f260e2a3ef38f14c9ee2",
  "url": "http://z3iuxcybt4xvjc56fqyj2xoz5xcfgrvg6tr7eyhcupxtr4kmt3ra.local.codius.org:8002/"
}

Now go to the URL that was given. example_manifest.json uploads an empty nginx server, so you'll see the nginx welcome page.

open "http://z3iuxcybt4xvjc56fqyj2xoz5xcfgrvg6tr7eyhcupxtr4kmt3ra.local.codius.org:8002/"

You've just deployed your first codius smart contract!

Setup

Get some credentials from the XRP testnet (Other ledgers are available).

export CODIUS_ILP_PLUGIN=ilp-plugin-xrp-escrow
export CODIUS_ILP_CREDENTIALS='{"server":"wss://s.altnet.rippletest.net:51233","secret":"s...."}'
export CODIUS_PORT=8002
export DEBUG=ilp*,koa*
node index.js

Manifest

The manifest file format specifies how to deploy a contract to codius.

{
  "manifest": {
    "environment": {
      "HELLO": "world"
    },
    "port": 8080,
    "image": "ubuntu",
    "command": [ "bash", "-c", "echo $HELLO" ]
  }
}
  • manifest - contains all the relevant details to deploy this contract. The fields are hashed together with canonical JSON so anyone can verify what code is running.

  • environment - a map of environment variables to be passed into this contract

  • port - a subdomain derived from the manifest hash is proxied to this port.

  • image - docker image to run as the codius contract

  • command - (optional) command to be run in place of the docker image's usual command.

Example Contracts

Feel free to submit pull requests to this section, showing off any Codius contracts you've written!

  • Crontract, A Codius service that auto-deploys your task to Codius, on a repeat.
  • Twittius, A service accepts payment to tweet a message of your choosing.
  • Twilius, A service that accepts payment to send an SMS with Twilio

About

MVP for a next-gen Codius host

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published