@dexterai/x402 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,18 +81,32 @@ const client = createX402Client({
|
|
|
81
81
|
|
|
82
82
|
### React
|
|
83
83
|
|
|
84
|
+
Works with [`@solana/wallet-adapter-react`](https://github.com/anza-xyz/wallet-adapter) and [`wagmi`](https://wagmi.sh/) out of the box:
|
|
85
|
+
|
|
84
86
|
```tsx
|
|
85
87
|
import { useX402Payment } from '@dexterai/x402/react';
|
|
88
|
+
import { useWallet } from '@solana/wallet-adapter-react'; // Solana
|
|
89
|
+
import { useAccount } from 'wagmi'; // EVM (Base)
|
|
86
90
|
|
|
87
91
|
function PayButton() {
|
|
92
|
+
// Get wallets from your existing providers
|
|
93
|
+
const solanaWallet = useWallet();
|
|
94
|
+
const evmWallet = useAccount();
|
|
95
|
+
|
|
88
96
|
const { fetch, isLoading, balances, transactionUrl } = useX402Payment({
|
|
89
|
-
wallets: {
|
|
97
|
+
wallets: {
|
|
98
|
+
solana: solanaWallet, // Pass directly - SDK handles the interface
|
|
99
|
+
evm: evmWallet,
|
|
100
|
+
},
|
|
90
101
|
});
|
|
91
102
|
|
|
92
103
|
return (
|
|
93
104
|
<div>
|
|
94
105
|
<p>Balance: ${balances[0]?.balance.toFixed(2)}</p>
|
|
95
|
-
<button
|
|
106
|
+
<button
|
|
107
|
+
onClick={() => fetch('/api/protected')}
|
|
108
|
+
disabled={isLoading || !solanaWallet.connected}
|
|
109
|
+
>
|
|
96
110
|
{isLoading ? 'Paying...' : 'Pay'}
|
|
97
111
|
</button>
|
|
98
112
|
{transactionUrl && <a href={transactionUrl}>View Transaction</a>}
|