2.0.8 • Published 5 days ago

@ryze-blockchain/ethereum v2.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
5 days ago

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') },
    })
}
2.0.8

5 days ago

2.0.7

6 days ago

2.0.6

21 days ago

2.0.5

3 months ago

2.0.4

3 months ago

2.0.3

3 months ago

2.0.2

3 months ago

2.0.1

3 months ago

2.0.0

3 months ago

1.3.0

3 months ago

1.2.3

4 months ago

1.2.2

4 months ago

1.2.0

7 months ago

1.2.1

7 months ago

1.0.8-beta-8

10 months ago

1.0.8-beta-7

10 months ago

1.0.8-beta-9

10 months ago

1.1.1

9 months ago

1.0.8-beta-17

10 months ago

1.1.0

9 months ago

1.0.8-beta-16

10 months ago

1.0.8-beta-15

10 months ago

1.0.8-beta-14

10 months ago

1.1.8

7 months ago

1.1.7

8 months ago

1.1.6

8 months ago

1.1.5

8 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.0.8-beta-13

10 months ago

1.0.8-beta-12

10 months ago

1.0.8-beta-11

10 months ago

1.0.8-beta-10

10 months ago

1.0.8-beta-6

11 months ago

1.0.8-beta-5

11 months ago

1.0.8-beta-4

11 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago

1.0.8

11 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.6-beta.1

12 months ago

1.0.6-beta.0

12 months ago

1.0.6-beta-4

11 months ago

1.0.6-beta-3

11 months ago

1.0.6-beta-6

11 months ago

1.0.6-beta-5

11 months ago

1.0.8-beta-0

11 months ago

0.0.8

12 months ago

1.0.6-beta-2

12 months ago

0.0.5

12 months ago

1.0.8-beta-3

11 months ago

1.0.8-beta-2

11 months ago

0.0.7

12 months ago

1.0.8-beta-1

11 months ago

0.0.6

12 months ago

0.0.3

1 year ago

0.0.4

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago