@seda-protocol/as-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-rc.2 • Public • Published

AssemblyScript SDK

SDK for creating Oracle Programs on the SEDA chain.

For guides an examples on how to use this SDK see our documentation: <LINK_HERE>

Preview

import { Process, httpFetch, Bytes, OracleProgram, Console, JSON } from "@seda-protocol/as-sdk/assembly";

@json
class SwPlanet {
  name!: string;
}

class PlanetProgram extends OracleProgram {
  execute(): void {
    const response = httpFetch("https://swapi.dev/api/planets/1/");

    if (response.ok) {
      const planet = response.bytes.toJSON<SwPlanet>();

      Console.log(planet);

      Process.success(Bytes.fromUtf8String(planet.name));
    } else {
      Process.error(Bytes.fromUtf8String("Error while fetching"));
    }
  }
}

new PlanetProgram().run();

Readme

Keywords

none

Package Sidebar

Install

npm i @seda-protocol/as-sdk

Weekly Downloads

49

Version

1.0.0-rc.2

License

none

Unpacked Size

50.8 kB

Total Files

21

Last publish

Collaborators

  • franklin-waller
  • thomasvdam
  • mariocao