# @synthetixio/js

> A library for interacting with Synthetix smart contracts

Latest version **2.41.0** (published 2021-03-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @synthetixio/js
pnpm add @synthetixio/js
yarn add @synthetixio/js
bun add @synthetixio/js
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.41.0 |
| Published | 2021-03-24 |
| First published | 2020-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 10.6 MB |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Synthetix |
| Maintainers | justinjmoses, clementbalestrat, wompwomp, synthetixio-team, whacko_jacko, evgenyboxer, dvdschwrtz |

## Links

- npm: https://www.npmjs.com/package/@synthetixio/js
- Repository: https://github.com/Synthetixio/js
- Homepage: https://github.com/Synthetixio/js#readme
- Issues: https://github.com/Synthetixio/js/issues
- npm.io page: https://npm.io/package/@synthetixio/js

## Dependencies (4)

- [ethers](https://npm.io/package/ethers.md) 5.0.7
- [lodash](https://npm.io/package/lodash.md) 4.17.19
- [synthetix](https://npm.io/package/synthetix.md) 2.41.0
- [web3-utils](https://npm.io/package/web3-utils.md) 1.2.11

## Recent versions

- 2.41.0 (latest) — 2021-03-24
- 2.41.2-alpha — 2021-03-23
- 2.41.1-alpha — 2021-03-23
- 2.41.0-alpha — 2021-03-23
- 2.40.1-alpha — 2021-03-12
- 2.40.0-alpha — 2021-03-12
- 2.39.3 — 2021-02-19
- 2.39.2 — 2021-02-17
- 2.39.1 — 2021-02-11
- 2.39.0 — 2021-02-11
- 2.39.0-alpha — 2021-02-11
- 2.38.0-sccp-77-defi-rebalance — 2021-02-10
- 2.38.0 — 2021-02-04
- 2.38.0-alpha — 2021-02-04
- 2.37.2 — 2021-02-03
- … 38 more at https://npm.io/package/@synthetixio/js/versions

## README

# Synthetix JS

[![Synthetixio](https://circleci.com/gh/Synthetixio/js.svg?style=svg)](https://github.com/Synthetixio/js)

: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

---
_Source: https://npm.io/package/@synthetixio/js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
