2.41.0 • Published 3 years ago

@synthetixio/js v2.41.0

Weekly downloads
645
License
MIT
Repository
github
Last release
3 years ago

Synthetix JS

Synthetixio

:warning: This library is still under construction and in BETA, please use with caution.

The official Javascript library for interacting with Synthetix protocol contracts.

This library can be used in 2 different environments:

  1. Common-js module for node environments
  2. UMD module for browser environments

Installation

// For node environments:
const { synthetix } = require('@synthetixio/js');

// For single page applications:
import { synthetix } from '@synthetixio/js';

// For browser environments:
// after running npm build take the index.browser.js file and put it in a script tag
// then you can access synthetix on the window object:
const { synthetix } = window;


const snxjs = synthetix({ network: 'mainnet' });


// Note for typescript applications:
import { synthetix, Network } from '@synthetixio/js';
const snxjs = synthetix({ network: Network.Mainnet });

Usage

// this instance exposes props for the given network: synths, sources, targets, users, etc... as well as helper function toBytes32 - as per synthetix: https://github.com/Synthetixio/synthetix/blob/develop/index.js#L199.
const snxjs = synthetix({ network: 'mainnet' });

// If you want to interact with a contract, simply follow the convention:
// await snxjs[contractName].methodName(arguments)
// many arguments require being formatted toBytes32, which we also provide with the library
// Note can optionally pass in a { blockTag: someBlockNumber } to get data from a specific block instead of {}
E.g:
const unformattedSnxPrice = await snxjs.contracts.ExchangeRates.rateForCurrency(snxjs.toBytes32('SNX'), {});
const unformattedTotalSupply = await snxjs.contracts.SynthsUSD.totalSupply({});

// We also expose ethers utils which provides handy methods for formatting responses to queries.
const { formatEther } = snxjs.utils;

const snxPrice = formatEther(unformattedSnxPrice);
const totalSupply = formatEther(unformattedTotalSupply);

See the examples folder for more usage details

2.41.0

3 years ago

2.41.2-alpha

3 years ago

2.41.1-alpha

3 years ago

2.41.0-alpha

3 years ago

2.40.1-alpha

3 years ago

2.40.0-alpha

3 years ago

2.39.3

3 years ago

2.39.2

3 years ago

2.39.1

3 years ago

2.39.0

3 years ago

2.39.0-alpha

3 years ago

2.38.0

3 years ago

2.38.0-alpha

3 years ago

2.37.2

3 years ago

2.37.1

3 years ago

2.37.0

3 years ago

2.36.1

3 years ago

2.36.0-alpha

3 years ago

2.36.0

3 years ago

2.35.6

3 years ago

2.35.5

3 years ago

2.35.4

3 years ago

2.35.3

3 years ago

2.35.2

3 years ago

2.35.2-beta

3 years ago

2.35.1-beta

3 years ago

2.35.1-alpha

3 years ago

2.35.0-ovm

3 years ago

2.34.2

3 years ago

2.34.1-ovm

3 years ago

2.34.0

3 years ago

2.33.0

3 years ago

2.33.2

3 years ago

2.33.1

3 years ago

2.33.0-ovm

3 years ago

2.32.3

3 years ago

2.32.2

3 years ago

2.32.1-beta

3 years ago

2.31.1

3 years ago

2.31.1-beta

3 years ago

2.31.0-beta

3 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago