@web3-onboard/react
Advanced tools
Comparing version 2.9.0-alpha.6 to 2.9.0-alpha.7
{ | ||
"name": "@web3-onboard/react", | ||
"version": "2.9.0-alpha.6", | ||
"version": "2.9.0-alpha.7", | ||
"description": "A collection of React hooks for integrating Web3-Onboard in to React and Next.js projects. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.", | ||
@@ -64,3 +64,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@web3-onboard/core": "^2.22.0-alpha.6", | ||
"@web3-onboard/core": "^2.22.0-alpha.7", | ||
"@web3-onboard/common": "^2.4.0-alpha.2", | ||
@@ -67,0 +67,0 @@ "use-sync-external-store": "1.0.0" |
@@ -456,20 +456,39 @@ <a href="https://onboard.blocknative.com/"> | ||
```typescript | ||
import { sendTransaction as wagmiSendTransaction } from '@web3-onboard/wagmi' | ||
import { parseEther } from 'viem' | ||
import { useWagmiConfig, wallets } from '@web3-onboard/react' | ||
import type { WagmiConfig } from '@web3-onboard/core' | ||
```ts | ||
import Onboard from '@web3-onboard/core' | ||
import injectedModule from '@web3-onboard/injected-wallets' | ||
import wagmi from '@web3-onboard/wagmi' | ||
import { | ||
sendTransaction as wagmiSendTransaction, | ||
switchChain, | ||
disconnect, | ||
getConnectors | ||
} from '@web3-onboard/wagmi' | ||
import { parseEther, isHex, fromHex } from 'viem' | ||
type useWagmiConfig = (): WagmiConfig | ||
const injected = injectedModule() | ||
const wagmiConfig = useWagmiConfig() | ||
const w3OWallets = useWallets() | ||
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 () => { | ||
// current primary wallet - as multiple wallets can connect this value is the currently active | ||
const [currentPrimaryWallet] = w3OWallets | ||
const [activeWallet] = onboard.state.get().wallets | ||
const { wagmiConnector } = activeWallet | ||
const wagmiConfig = onboard.state.get().wagmiConfig | ||
const result = await wagmiSendTransaction(wagmiConfig, { | ||
to: toAddress, | ||
// desired connector to send txn from | ||
account: currentPrimaryWallet.accounts[0], | ||
connector: wagmiConnector, | ||
value: parseEther('0.001') | ||
@@ -479,2 +498,12 @@ }) | ||
} | ||
async function signMessage(chainId) { | ||
// current primary wallet - as multiple wallets can connect this value is the currently active | ||
const [activeWallet] = onboard.state.get().wallets | ||
const wagmiConfig = onboard.state.get().wagmiConfig | ||
await wagmiSignMessage(wagmiConfig, { | ||
message: 'This is my message to you', | ||
connector: activeWallet.wagmiConnector | ||
}) | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26810
508