8.10.0 • Published 2 months ago

@synthetixio/v3-contracts v8.10.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

v3-contracts

ABI and Adresses for Synthetix v3 contract deployments

Install the package:

npm install @synthetixio/v3-contracts

or

yarn add @synthetixio/v3-contracts

Usage

Get ethers-v5 Contract instance for CoreProxy deployed to the Mainnet:

const {ethers} = require('ethers');
const meta = require('@synthetixio/v3-contracts/1-main/meta.json');
const abi = require('@synthetixio/v3-contracts/1-main/CoreProxy.readable.json');

const provider = new ethers.providers.JsonRpcProvider(
  process.env.RPC_URL || 'http://127.0.0.1:8545'
);

const CoreProxy = new ethers.Contract(meta.contracts.CoreProxy, abi, provider);

const accountId = 1;
CoreProxy.getAccountOwner(accountId).then(console.log);

Dynamically load CoreProxy contract for a given chain and preset.

import {ethers} from 'ethers';

export async function importCoreProxy(chainId: number, preset: string = 'main') {
  switch (`${chainId}-${preset}`) {
    case '1-main':
      const [meta, abi] = await Promise.all([
        import('@synthetixio/v3-contracts/1-main/meta.json'),
        import('@synthetixio/v3-contracts/1-main/CoreProxy.readable.json')
      ]);
      return new ethers.Contract(meta.contracts.CoreProxy, abi, provider);

    case '10-main':
      const [meta, abi] = await Promise.all([
        import('@synthetixio/v3-contracts/10-main/meta.json'),
        import('@synthetixio/v3-contracts/10-main/CoreProxy.readable.json')
      ]);
      return new ethers.Contract(meta.contracts.CoreProxy, abi, provider);

    case '8453-andromeda':
      const [meta, abi] = await Promise.all([
        import('@synthetixio/v3-contracts/8453-andromeda/meta.json'),
        import('@synthetixio/v3-contracts/8453-andromeda/CoreProxy.readable.json')
      ]);
      return new ethers.Contract(meta.contracts.CoreProxy, abi, provider);

    default:
      throw new Error(`Unsupported chain ${chainId} for CoreProxy`);
  }
}

importCoreProxy(1, 'main')
  .then(async CoreProxy => {
    const accountId = 1;
    const address = await CoreProxy.getAccountOwner(accountId);
    console.log(address)
  })
8.8.0

3 months ago

8.10.0

2 months ago

8.9.0

2 months ago

8.7.0

4 months ago

8.6.0

5 months ago

8.5.0

6 months ago

8.4.0

6 months ago

8.1.0

6 months ago

8.3.0

6 months ago

8.0.0

6 months ago

8.2.0

6 months ago

7.19.0

6 months ago

7.18.0

7 months ago

7.8.0

9 months ago

7.6.0

9 months ago

7.17.0

7 months ago

7.15.0

8 months ago

7.13.0

8 months ago

7.11.0

8 months ago

7.7.0

9 months ago

7.9.0

9 months ago

7.14.0

8 months ago

7.12.0

8 months ago

7.10.0

8 months ago

7.5.0

9 months ago

7.4.0

9 months ago

7.3.0

10 months ago

7.2.0

10 months ago

7.0.0

10 months ago

7.1.0

10 months ago

6.12.0

10 months ago

6.11.0

10 months ago

6.14.0

10 months ago

6.13.0

10 months ago

5.6.0

1 year ago

5.5.0

1 year ago

5.4.0

1 year ago

5.3.0

1 year ago

6.1.0

1 year ago

6.0.0

1 year ago

6.3.0

1 year ago

6.2.1

1 year ago

6.2.0

1 year ago

6.5.0

12 months ago

6.4.0

1 year ago

6.10.0

10 months ago

6.7.0

11 months ago

6.6.1

11 months ago

6.6.0

11 months ago

6.9.0

11 months ago

6.8.0

11 months ago

5.2.2

1 year ago

5.2.1

1 year ago

5.2.0

1 year ago

5.1.0

1 year ago

5.0.0

1 year ago

4.0.0

2 years ago

3.1.0

2 years ago

3.0.2

2 years ago

3.0.0

2 years ago

3.0.0-alpha.8

2 years ago

3.0.0-alpha.5

3 years ago