@credenza3/core-web-evm-ext
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

CREDENZA WEB SDK EvmExtension

Installation

npm i @credenza3/core-web-evm-ext

import { EvmExtension } from '@credenza3/core-web-evm-ext'

Usage

Define chain config

const chainConfig = {
  chainId: '0x13881',
  rpcUrl: 'https://polygon-mumbai-bor.publicnode.com',
  displayName: 'Mumbai',
  blockExplorer: 'https://mumbai.polygonscan.com/',
  nativeCurrency: {
    name: 'MATIC',
    symbol: 'MATIC',
    decimals?: 18, // defaults to 18
  },
} // chain specific config

Create the SDK instance

const sdk = new CredenzaSDK({
  extensions: [
    new EvmExtension({
      chainConfig,
      extensions: [
        new MetamaskExtension(),
      ],
    })
  ],
})

Switch Chain. Calls different switch chain implementations depending on LoginProvider (metamask | ouath)

await sdk.evm.switchChain(chainConfig)

Get current chain config.

const config = await sdk.evm.getChainConfig()

Get provider

const evmProvider = await sdk.evm.getProvider()

Get ethers provider

// wraps evmProvider with new ethers.BrowserProvider()
const provider = await sdk.evm.getEthersProvider()

Credenza EVM provider

In case you need the only credenza evm provider

import { CredenzaProvider } from '@credenza3/core-web-evm-ext'

Ethers js

https://www.npmjs.com/package/ethers

If you prefer to use ethers.js you can import it from the evm extension

import { ethers } from '@credenza3/core-web-evm-ext'

Events

const event = EvmExtension.EVM_EVENT.<EVENT_NAME>
const unsubscribe = sdk.evm.on(event, (data) => {})
sdk.once(event, (data) => {})

Readme

Keywords

none

Package Sidebar

Install

npm i @credenza3/core-web-evm-ext

Weekly Downloads

50

Version

0.0.8

License

MIT

Unpacked Size

1.01 MB

Total Files

10

Last publish

Collaborators

  • mike.avvad
  • credenza
  • fokindmitr