@uniblock/wagmi v0.0.1-16
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
parameter | type |
---|---|
chains? | number[] |
config? | configObj |
configObj
parameter | type |
---|---|
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
parameter | type |
---|---|
provider | any |
webSocketProvider | any |
chains | any |
connectorList | connector[] |
config? | configObj |
configObj
parameter | type |
---|---|
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
parameter | type |
---|---|
client | Client (wagmi) |
connector | connector 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
parameter | type |
---|---|
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
parameter | type |
---|---|
chainId? | number |
Example
// getting signer for goerli testnet
const signer = await wagmi.getSigner(5);
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago