Home

Awesome

Ergo SDK

npm version

This SDK includes:

Usage

This SDK heavily relies on ergo-rust via WASM. So you have to load RustModule before using this SDK:

import React, { useEffect, useState } from 'react';
import { GeistProvider } from '@geist-ui/react';
import { RustModule } from '@ergolabs/ergo-sdk';

export const App: React.FC = () => {
  const [isRustModuleLoaded, setIsRustModuleLoaded] = useState(false);

  useEffect(() => {
    RustModule.load().then(() => setIsRustModuleLoaded(true));
  }, []);

  if (!isRustModuleLoaded) {
    return null;
  }

  return (<GeistProvider>...</GeistProvider>)
}

Ergo data model

Ergo Wallet

Ergo Explorer API

Explorer API methods also rely on the Ergo data model, but most of them return enriched versions of Ergo models marked with Aug* prefix.

Implemented methods:

import {Explorer} from "@ergolabs/ergo-sdk";
const explorer = new Explorer("https://api.ergoplatform.com");
const txId = "18b30e9b40ed7061d2f87590c555d24a712df9c848a8db9dfd4affcc92d3cb02";
explorer.getTx(txId).then(tx => console.log(tx));

Using with create-react-app

CRA does not support WASM. But you can workaround it. You need to override webpack config. Check out - https://stackoverflow.com/questions/59319775/how-to-use-webassembly-wasm-with-create-react-app/59720645#59720645