1.0.77 • Published 11 months ago

@oikos/contracts-interface v1.0.77

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

Contracts Interface to oikos

The official JavaScript library for interacting with oikos protocol contracts.

This library can be used in 2 different environments:

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

Instantiating in node.js or the browser

// For node environments:
const { oikos } = require('@synthetixio/contracts-interface');

// For single page applications:
import { oikos } from '@synthetixio/contracts-interface';

// For browsers you can use a CDN of the minified files
// E.g. <script src="https://cdn.jsdelivr.net/npm/@synthetixio/contracts-interface/build/index.min.js"></script>
// then you can access oikos on the window object:
const { oikos } = window;

// Instantiate the library with or without a provider
const oksjs = oikos({ network: 'mainnet' });

// Note: for typescript applications
import { oikos, Network } from '@synthetixio/contracts-interface';
const oksjs = oikos({ network: Network.Mainnet });

Reading state

const oksjs = oikos({ network: 'mainnet' });

// If you want to interact with a contract, simply follow the convention:
// await oksjs[contractName].methodName(arguments)

const owner = await oksjs.contracts.oikos.owner();

// many arguments require being formatted toBytes32, which we also provide with the library

const { toBytes32 } = oks;

const totalIssuedSynths = await oksjs.contracts.oikos.totalIssuedSynths(toBytes32('oUSD'));

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

formatEther(await oksjs.contracts.SynthoUSD.totalSupply());

formatEther(await oksjs.contracts.ExchangeRates.rateForCurrency(oksjs.toBytes32('oks')));

// Note can optionally pass in a { blockTag: someBlockNumber } to get data from a specific block instead of {}
const oksAtBlock12m = await oksjs.contracts.ExchangeRates.rateForCurrency(oksjs.toBytes32('oks'), {
  blockTag: 12e6,
});

Signing transactions

// any old provider will do
const provider = ethers.providers.getDefaultProvider('kovan');

// create a signer with a provider attached
const signer = new ethers.Wallet(
  // just a dummy kovan wallet with a little keth from the faucet
  '0xa0d951c494421559c63089093b020cf2f7aac003c916967dc36e989bc695222e',
  provider
);

// and then instantiate oikos with the signer
const oksjs = oikos({ network: 'mainnet', signer });

// mint 0.01 sETH via the NativeEtherWrapper
const response = await oksjs.contracts.NativeEtherWrapper.mint({
  value: parseEther('0.01'),
  gasPrice: parseUnits('5', 'gwei'),
  gasLimit: 500e3,
});
console.log('Submitted', response.hash);
await response.wait();
console.log('Mined', `https://etherscan.io/tx/${response.hash}`);

See the examples folder for more usage details.

1.0.66

11 months ago

1.0.64

11 months ago

1.0.63

11 months ago

1.0.69

11 months ago

1.0.68

11 months ago

1.0.67

11 months ago

1.0.73

11 months ago

1.0.72

11 months ago

1.0.71

11 months ago

1.0.70

11 months ago

1.0.77

11 months ago

1.0.76

11 months ago

1.0.75

11 months ago

1.0.74

11 months ago

1.0.62

2 years ago

1.0.61

2 years ago

1.0.60

2 years ago

1.0.59

2 years ago

1.0.58

2 years ago

1.0.19

2 years ago

1.0.2

2 years ago

1.0.18

2 years ago

1.0.1

2 years ago

1.0.17

2 years ago

1.0.0

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.49

2 years ago

1.0.51

2 years ago

1.0.50

2 years ago

1.0.55

2 years ago

1.0.11

2 years ago

1.0.54

2 years ago

1.0.10

2 years ago

1.0.53

2 years ago

1.0.52

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.56

2 years ago

1.0.12

2 years ago

2.26.30

2 years ago

2.26.28

2 years ago

2.26.26

2 years ago

2.26.24

2 years ago

2.26.23

2 years ago

2.26.22

2 years ago

2.26.21

2 years ago

2.26.20

2 years ago

2.26.19

2 years ago

2.26.18

2 years ago

2.26.17

2 years ago

2.26.16

2 years ago

2.26.15

2 years ago

2.26.14

2 years ago

2.26.9

2 years ago

2.26.7

2 years ago

2.63.5

2 years ago

2.63.4

2 years ago

2.63.3

2 years ago