Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@web3-onboard/wagmi
Advanced tools
Module to configure, connect and return web3-onboard wallets as wagmi wallets and wagmi-config to be used with wagmi-core methods
NPM
npm i @web3-onboard/wagmi
Yarn
yarn add @web3-onboard/wagmi
This example assumes you have already setup web3-onboard to connect wallets to your dapp. For more information see web3-onboard docs.
import Onboard from '@web3-onboard/core'
import injectedModule from '@web3-onboard/injected-wallets'
import wagmi from '@web3-onboard/wagmi'
import { parseEther } from 'viem'
import {
sendTransaction as wagmiSendTransaction,
switchChain,
disconnect,
getConnectors
} from '@wagmi/core'
import { parseEther, isHex, fromHex } from 'viem'
const injected = injectedModule()
const onboard = Onboard({
wagmi,
wallets: [injected],
chains: [
{
id: '0x1',
token: 'ETH',
label: 'Ethereum',
rpcUrl: 'https://mainnet.infura.io/v3/17c1e1500e384acfb6a72c5d2e67742e'
}
]
// ... other Onboard options
})
const sendTransaction = async provider => {
// current primary wallet - as multiple wallets can connect this value is the currently active
const [currentPrimaryWallet] = onboard.state.get().wallets
const wagmiConfig = onboard.state.get().wagmiConfig
const result = await wagmiSendTransaction(wagmiConfig, {
to: toAddress,
// desired connector to send txn from
account: currentPrimaryWallet.accounts[0],
value: parseEther('0.001')
})
console.log(result)
}
async function switchWagmiChain(chainId) {
let chainAsNumber
if (isHex(chainId)) {
chainAsNumber = fromHex(chainId, 'number')
} else if (!isHex(chainId) && typeof chainId === 'number') {
chainAsNumber = chainId
} else {
throw new Error('Invalid chainId')
}
const wagmiConfig = onboard.state.get().wagmiConfig
await switchChain(wagmiConfig, { chainId: chainAsNumber })
}
async function disconnectWallet() {
const wagmiConfig = onboard.state.get().wagmiConfig
const disconnectThisWallet = getConnectors(wagmiConfig).find(
connector => connector.name === label
)
disconnect(wagmiConfig, { connector: disconnectThisWallet })
}
FAQs
Module to configure, connect and return web3-onboard wallets as wagmi wallets and wagmi-config to be used with wagmi-core methods
The npm package @web3-onboard/wagmi receives a total of 58 weekly downloads. As such, @web3-onboard/wagmi popularity was classified as not popular.
We found that @web3-onboard/wagmi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.