0.0.1-16 • Published 2 years ago

@uniblock/wagmi v0.0.1-16

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

uniblock-sdk wagmi

This package allows developers to access functionalities of Wagmi that can be used to connect wallets and access providers/signers.

Setup

yarn add @uniblock/wagmi or npm install @uniblock/wagmi

Quick Start

Creating Wagmi Instance

To access the functionalities of @uniblock/wagmi you must first create an instance of the Wagmi class. This is done through our initializeWagmi function that takes in your Uniblock API key and returns an instance of the Wagmi class. Now using the object you may access the SDK's functions.

import { initializeWagmi } from '@uniblock/wagmi';

const wagmi = await initializeWagmi(uniblockApiKey);

configureChains

This function configures the chains and providers that will be used to pass into createClient when creating a client instance.

Params

parametertype
chains?number[]
config?configObj
configObj
parametertype
alchemyApiKey?string
infuraApiKey?string

Example

// configures for goerli testnet with an infura api key
const { chains, provider, webSocketProvider } = wagmi.configureChains([5], {
  infuraApiKey: infuraApiKey,
});

createClient

This function creates and returns a Client instance.

Params

parametertype
providerany
webSocketProviderany
chainsany
connectorListconnector[]
config?configObj
configObj
parametertype
autoConnect?boolean
magicApiKey?string
magicChainId?number
walletConnectQrcode?boolean
rainbowKitAppName?string

Example

import { connector } from '@uniblock/wagmi';

const client = wagmi.createClient(provider, webSocketProvider, chains, [
  connector.INJECTED_CONNECTOR,
  connector.WALLETCONNECT_CONNECTOR,
  connector.METAMASK_CONNECTOR,
]);

connectWallet

This function connects a wallet to the application.

Params

parametertype
clientClient (wagmi)
connectorconnector or Connector (wagmi)
chainId?number

Example

await wagmi.connectWallet(client, connector.INJECTED_CONNECTOR);
// or
await wagmi.connectWallet(client, new InjectedConnector({ chains }));

getProvider

This function retrieves the provider of the connected wallet.

Params

parametertype
chainId?number

Example

// getting provider for goerli testnet
const provider = await wagmi.getProvider(5);

getSigner

This function retrieves the signer of the connected wallet.

Params

parametertype
chainId?number

Example

// getting signer for goerli testnet
const signer = await wagmi.getSigner(5);
0.0.1-16

2 years ago

0.0.1-15

2 years ago

0.0.1-3

2 years ago

0.0.1-7

2 years ago

0.0.1-6

2 years ago

0.0.1-5

2 years ago

0.0.1-4

2 years ago

0.0.1-10

2 years ago

0.0.1-12

2 years ago

0.0.1-11

2 years ago

0.0.1-14

2 years ago

0.0.1-9

2 years ago

0.0.1-13

2 years ago

0.0.1-8

2 years ago

0.0.1-2

2 years ago

0.0.1-1

2 years ago

0.0.1-0

2 years ago