b4s36t4 / pyth-plugin

A web3.js plugin to interact with pyth.network oracle.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Web3.js Pyth Network Plugin

This is a web3.js 4.x plugin for interacting with Pyth Network Ethereum contracts.

Prerequisites

Installation

yarn add web3.js-pythnet-plugin

Using this plugin

Installing Version 4.x of web3

When adding the web3 package to your project, make sure to use version 4.x:

  • npm i -S web3@4.0.3
  • yarn add web3@4.0.3

NOTE
If 4.x was already released, you are good to just use web3 without appending anything to it.

To verify you have the correct web3 version installed, after adding the package to your project (the above commands), look at the versions listed in your project's package.json under the dependencies section, it should contain version 4.x similar to:

"dependencies": {
	"web3": "4.0.3"
}

Registering the Plugin with a web3.js Instance

After importing PythNetworkPlugin from web3.js-pythnet-plugin and Web3 from web3, register an instance of PythNetworkPlugin with an instance of Web3 like so:

import { PythNetworkPlugin } from '@chainsafe/web3-plugin-chainlink';
import { Web3 } from 'web3';

const web3 = new Web3('YOUR_PROVIDER_URL');
const plugin = new PythNetworkPlugin({ type: 'stable', contract: 'Arbitrum' });

web3.registerPlugin(plugin);

More information about registering web3.js plugins can be found here.

Plugin Methods

Warning

Not fully documented

About

A web3.js plugin to interact with pyth.network oracle.

License:MIT License


Languages

Language:TypeScript 100.0%