@streambird/rpc-provider
v0.0.75
Published
Streambird RPC Provider
Downloads
67
Readme
Streambird RPC provider
Installation
Yarn
$ yarn add @streambird/rpc-provider
npm
$ npm install @streambird/rpc-provider
Initializing Provider
ES Modules/TypeScript
import { StreambirdRPCProvider } from '@streambird/rpc-provider'
import Web3 from 'web3'
const rpcProvider = new StreambirdRPCProvider({
// Streambird server url
endpoint: process.env.SECURED_STREAMBIRD_URL,
// Node url e.g: https://rinkeby.infura.io/v3/<API_KEY>
network: process.env.NODE_URL,
privateKey: process.env.PRIVATE_KEY,
})
const web3 = new Web3(rpcProvider)
CommonJS
const { StreambirdRPCProvider } = require('@streambird/rpc-provider')
const Web3 = require('web3')
const rpcProvider = new StreambirdRPCProvider({
// Streambird server url
endpoint: process.env.SECURED_STREAMBIRD_URL,
// Node url e.g: https://rinkeby.infura.io/v3/<API_KEY>
network: process.env.NODE_URL,
privateKey: process.env.PRIVATE_KEY,
})
const web3 = new Web3(rpcProvider)
Get User Info
const address = (await web3.eth.getAccounts())[0]
const balance = web3.utils.fromWei(await web3.eth.getBalance(address))