Create a Program

Register a program to run on Aleph.im virtual machines.

Returns

A Program message object that is being sent to the network.

Usage & Example

import { program } from 'aleph-sdk-ts'
import { ItemType } from "aleph-sdk-ts/messages/message"

(async() => {
  const file = new File(<Your Program Here>);
      
  program.publish({
    account: account,
    channel: "TEST",
    storageEngine: ItemType.storage, 
    inlineRequested: false,
    APIServer: "https://api2.aleph.im",
    file: file,
    entrypoint: "main:app"
  })
})

Required Parameters

account - Account

Account to use for signing.

channel - string

Channel of the message. Ideally, an application would decide and use one channel.

storageEngine - ItemType

The storage engine to use when storing the object (IPFS or ALeph)

inlineRequested - boolean

Will the message be inlined ?

APIServer - string

The API server endpoint used to carry the request to the Aleph's network.

file - Buffer or Blob

File with the program to run on a VM

entrypoint - string

The entrypoint is composed of two values:

• The name of the main file that is running the program

• The name of the object in the program that inits FastApi Ex: "mainFile:FastApiObject". Learn more about FastApi here.

Optional Parameters

  • subscription - Record<string, unknown>[] DEFAULT: { http: true } Signals that trigger an execution of the VM, by default it's triggered by HTTP, but it can be by an Aleph Message. Ex: Record<"message", [{"sender: "0x...", "channel": "TEST"}]>

  • memory - number DEFAULT: 128 The memory you give to your VM, this param is contained in the MachineResources struct.

  • runtime - string DEFAULT: "bd79839bf96e595a06da5ac0b6ba51dea6f7e2591bb913deccded04d831d29f4" This param refers to the root filesystem used by the Aleph VM and this param is a path to them, you can find the official Aleph runtimes here

  • volumes - array of MachineVolume DEFAULT: [] MachineVolume can either be: ImmutableVolume | EphemeralVolume | PersistentVolume. Explanation of those types are here: https://github.com/aleph-im/aleph-vm/blob/main/tutorials/ADVANCED.md#volumes You can also find their definition here: https://github.com/aleph-im/aleph-sdk-ts/blob/main/src/messages/program/programModel.ts

Last updated