Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ryze-blockchain/ethereum

Package Overview
Dependencies
Maintainers
0
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ryze-blockchain/ethereum

Helpers for interacting with EVM based blockchains

  • 2.0.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Ethereum

An opinionated wrapper to simplify the integration with ethers, a popular Ethereum library.

Installation

npm i @ryze-blockchain/ethereum

Usage

  1. Initialize
// ethereum.ts
import { Ethereum, ChainId, WalletInfo } from '@ryze-blockchain/ethereum'

export const ethereum = new Ethereum({
    defaultChainId: ChainId.AVAX_TESTNET,
    availableChainIds: [ChainId.AVAX_TESTNET],
    chainToRpcMap: {
        [ChainId.AVAX_TESTNET]: ['https://api.avax-test.network/ext/bc/C/rpc'],
    },
    onWalletUpdate: (walletInfo: WalletInfo | null) => {
        // set walletInfo in your state management plugin
    },
})
  1. Connect to a wallet provider
// your wallet component
import { isEthersError, isProviderError, ProviderErrorCode, WalletApplication } from '@ryze-blockchain/ethereum'
import { ethereum } from './ethereum.ts'

// You can use any one of the available WalletApplications
const connectWallet = async (walletApplication: WalletApplication) => {
    return await ethereum.walletManager.connect(walletApplication, {
        onReject: () => { throw new Error('User rejected wallet connection') },
        onRequestAlreadyPending: () => { throw new Error('Wallet connection already pending') },
        onProviderUnavailable: () => { throw new Error('Wallet provider not available') },
    })
}
  1. Request to set a chain in the user's wallet
// your chain component
import { isEthersError, isProviderError, ProviderErrorCode, ChainId } from '@ryze-blockchain/ethereum'
import { ethereum } from './ethereum.ts'

const setChain = async (chainId: ChainId) => {
    return await ethereum.walletManager.setChain(chainId, {
        onReject: () => { throw new Error('Request rejected by the user') },
        onRequestAlreadyPending: () => { throw new Error('Request to switch chain already pending') },
    })
}

FAQs

Package last updated on 22 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc