All Projects → ergolabs → ergo-sdk-js

ergolabs / ergo-sdk-js

Licence: CC0-1.0 license
Ergo JS SDK

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to ergo-sdk-js

rube
A multi-chain DeFi development toolkit for Elixir
Stars: ✭ 27 (+80%)
Mutual labels:  defi
reef-chain
EVM compatible chain with NPoS/PoC consensus
Stars: ✭ 142 (+846.67%)
Mutual labels:  defi
derione-v1
No description or website provided.
Stars: ✭ 14 (-6.67%)
Mutual labels:  defi
awesome-defi
Curated list of awesome DeFi protocols, dapps, wallets and other resources
Stars: ✭ 36 (+140%)
Mutual labels:  defi
quipuswap-core
🧙‍♂️ Repository containing QuipuSwap liquidity protocol smart-contracts written in Ligo language
Stars: ✭ 48 (+220%)
Mutual labels:  defi
SIPs
The Synthetix Improvement Proposal repository
Stars: ✭ 73 (+386.67%)
Mutual labels:  defi
NFT-Dapp-Boilerplate
A highly scalable NFT and DEFI boilerplate with pre added web3 and different wallets with a focus on performance and best practices
Stars: ✭ 51 (+240%)
Mutual labels:  defi
PancakeSwapPredictionBot
PancakeSwap V2 Prediction Bot With Machine Learning | Automated Strategy, Auto Betting, Auto Claim
Stars: ✭ 21 (+40%)
Mutual labels:  defi
mStable-contracts
📃 Smart Contracts that make up the core of the mStable protocol
Stars: ✭ 277 (+1746.67%)
Mutual labels:  defi
challenges
Ce dépôt contient tous les sujets des défis ainsi que les solutions proposées par les participants.
Stars: ✭ 18 (+20%)
Mutual labels:  defi
market
🧜‍♀️ THE Data Market
Stars: ✭ 149 (+893.33%)
Mutual labels:  defi
Poolz-Back
smart contracts using solidity for erc20 tokens to eth and erc20 to erc20
Stars: ✭ 15 (+0%)
Mutual labels:  defi
Solnet
Solana's .NET SDK and integration library.
Stars: ✭ 252 (+1580%)
Mutual labels:  defi
pali-wallet
The Official Syscoin browser wallet. Open source, easy to use & multichain.
Stars: ✭ 30 (+100%)
Mutual labels:  defi
flow-protocol-ethereum
Flow Protocols powering synthetic asset and margin trading
Stars: ✭ 18 (+20%)
Mutual labels:  defi
defi
Tools for use in DeFi. Impermanent Loss calculations, staking and farming strategies, coingecko and pancakeswap API queries, liquidity pools and more
Stars: ✭ 464 (+2993.33%)
Mutual labels:  defi
DeFi-Map
List of decentralized finance projects on Ethereum.
Stars: ✭ 49 (+226.67%)
Mutual labels:  defi
prb-math
Solidity library for advanced fixed-point math
Stars: ✭ 404 (+2593.33%)
Mutual labels:  defi
go-compound
Golang client for compound.finace api and smart contracts
Stars: ✭ 23 (+53.33%)
Mutual labels:  defi
stock-dex
As a response to the restrictions many have faced due to the $GME short squeeze mania, many have called for the creation of a decentralized stock exchange. This is what we are going to provide
Stars: ✭ 26 (+73.33%)
Mutual labels:  defi

Ergo SDK

npm version

This SDK includes:

  • Ergo protocol data model
  • Ergo wallet
  • Ergo Blockchain Explorer API wrapper

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

  • Address
  • ErgoTree
  • ErgoTreeTemplate
  • ErgoBox
  • ErgoBoxCandidate
  • Input
  • DataInput
  • UnsignedInput
  • ErgoTx
  • UnsignedErgoTx
  • AssetAmount
  • AssetInfo
  • TokenAmount
  • Constant
  • ContextExtension
  • NetworkContext
  • ProverResult
  • PublicKey
  • Registers
  • SigmaType

Ergo Wallet

  • BoxSelector - Selects inputs satisfying a given target balance and tokens.
  • Prover - An interface of an abstract prover capable of signing transactions. Should be implemented using wallet integration (e.g. Yoroi).
  • TxAssembler - A service for simplified TX assembly.

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:

  • getTx(id: TxId): Promise<AugErgoTx | undefined> - Get confirmed transaction by id.
  • getOutput(id: BoxId): Promise<AugErgoBox | undefined> - Get confirmed output by id.
  • getTxsByAddress(address: Address, paging: Paging): Promise<[AugErgoTx[], number]> - Get transactions by address.
  • getUTxsByAddress(address: Address, paging: Paging): Promise<[AugErgoTx[], number]> - Get unconfirmed transactions by address.
  • getUnspentByErgoTree(tree: ErgoTree, paging: Paging): Promise<[AugErgoBox[], number]> - Get unspent boxes with a given ergoTree.
  • getUnspentByErgoTreeTemplate(hash: HexString, paging: Paging): Promise<AugErgoBox[]> - Get unspent boxes with scripts matching a given hash of ErgoTree template.
  • getUnspentByTokenId(tokenId: TokenId, paging: Paging, sort?: Sorting): Promise<AugErgoBox[]> - Get unspent boxes containing a token with a given id.
  • getByTokenId(tokenId: TokenId, paging: Paging, sort?: Sorting): Promise<AugErgoBox[]> - Get boxes containing a token with a given id.
  • getUnspentByErgoTreeTemplateHash(hash: HexString, paging: Paging): Promise<[AugErgoBox[], number]> - Get unspent boxes by a given hash of ErgoTree template.
  • searchUnspentBoxes(req: BoxSearch, paging: Paging): Promise<[AugErgoBox[], number]> - Detailed search among unspent boxes.
  • searchUnspentBoxesByTokensUnion(req: BoxAssetsSearch, paging: Paging): Promise<[AugErgoBox[], number]> - Search among unspent boxes by ergoTreeTemplateHash and tokens.
  • getFullTokenInfo(tokenId: TokenId): Promise<AugAssetInfo | undefined> - Get a token info by id.
  • getTokens(paging: Paging): Promise<[AugAssetInfo[], number]> - Get all available tokens.
  • getNetworkContext(): Promise<NetworkContext> - Get current network context.
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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].