https://github.com/thirdweb-example/eip5792-demo
https://github.com/thirdweb-example/eip5792-demo
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/thirdweb-example/eip5792-demo
- Owner: thirdweb-example
- Created: 2024-05-16T01:53:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-13T18:50:57.000Z (over 1 year ago)
- Last Synced: 2025-07-15T00:29:50.064Z (7 months ago)
- Language: TypeScript
- Homepage: https://eip5792-demo.thirdweb-preview.com
- Size: 1.05 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# EIP-5792 with thirdweb
## Example Usage
### `getCapabilities`
Returns the capabilities of the wallet according to EIP-5792.
```ts
import { getCapabilities } from "thirdweb/wallets/eip5792";
const capabilities = await getCapabilities({ wallet });
```
### `sendCalls`
Sends the given calls to the wallet for execution, and attempts to fallback to normal execution if the wallet does not support EIP-5792.
```ts
import { sendCalls } from "thirdweb/wallets/eip5792";
const transfer1 = transfer({
contract: USDC_CONTRACT,
amount: 5000,
to: "0x33d9B8BEfE81027E2C859EDc84F5636cbb202Ed6",
});
const transfer2 = transfer({
contract: USDT_CONTRACT,
amount: 1000,
to: "0x33d9B8BEfE81027E2C859EDc84F5636cbb202Ed6",
});
const bundleId = await sendCalls({
wallet,
client,
calls: [transfer1, transfer2],
});
```
### `getCallsStatus`
Returns the status of the given bundle ID and the transaction receipts if completed.
```ts
import { getCallsStatus } from "thirdweb/wallets/eip5792";
const status = await getCallsStatus({ wallet, bundleId });
```
### `useSendCalls`
`useSendCalls` will automatically revalidate all reads from contracts that are interacted with.
```ts
import { useSendCalls } from "thirdweb/react";
const sendTx1 = approve({
contract: USDT_CONTRACT,
amount: 100,
spender: "0x33d9B8BEfE81027E2C859EDc84F5636cbb202Ed6",
});
const sendTx2 = approve({
contract: USDT_CONTRACT,
amount: 100,
spender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
});
const { mutate: sendCalls, data: bundleId } = useSendCalls({ client });
await sendCalls({
wallet,
client,
calls: [sendTx1, sendTx2],
});
```
Await the bundle's full confirmation:
```ts
const { mutate: sendCalls, data: bundleId } = useSendCalls({
client,
waitForResult: true,
});
await sendCalls({
wallet,
client,
calls: [sendTx1, sendTx2],
});
```
Sponsor transactions with a paymaster:
```ts
const { mutate: sendCalls, data: bundleId } = useSendCalls();
await sendCalls({
client,
calls: [sendTx1, sendTx2],
capabilities: {
paymasterService: {
url: `https://${CHAIN.id}.bundler.thirdweb.com/${client.clientId}`,
},
},
});
```
> [!NOTE]
> It's recommended to setup a proxy route for your thirdweb paymaster url (shown above) so you can properly restrict the domains that utilize it.
### `useCapabilities`
```ts
import { useCapabilities } from "thirdweb/react";
const { data: capabilities, isLoading } = useCapabilities();
```
### `useCallsStatus`
```ts
import { useCallsStatus } from "thirdweb/react";
const { data: status, isLoading } = useCallsStatus({ bundleId, client });
```