-
Notifications
You must be signed in to change notification settings - Fork 619
[Playground] Add Engine user transactions example to playground #7470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
joaquim-verges
merged 1 commit into
main
from
Add_Engine_user_transactions_example_to_playground
Sep 5, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@thirdweb-dev/api": patch | ||
| --- | ||
|
|
||
| Update to latest API | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
apps/playground-web/src/app/transactions/users/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import { User2Icon } from "lucide-react"; | ||
| import type { Metadata } from "next"; | ||
| import { GatewayPreview } from "@/components/account-abstraction/gateway"; | ||
| import { PageLayout } from "@/components/blocks/APIHeader"; | ||
| import { CodeExample } from "@/components/code/code-example"; | ||
| import ThirdwebProvider from "@/components/thirdweb-provider"; | ||
| import { metadataBase } from "@/lib/constants"; | ||
|
|
||
| export const metadata: Metadata = { | ||
| description: "Transactions from user wallets with monitoring and retries", | ||
| metadataBase, | ||
| title: "User Transactions | thirdweb", | ||
| }; | ||
|
|
||
| export default function Page() { | ||
| return ( | ||
| <ThirdwebProvider> | ||
| <PageLayout | ||
| icon={User2Icon} | ||
| description={ | ||
| <>Transactions from user wallets with monitoring and retries.</> | ||
| } | ||
| docsLink="https://portal.thirdweb.com/transactions?utm_source=playground" | ||
| title="User Transactions" | ||
| > | ||
| <UserTransactions /> | ||
| </PageLayout> | ||
| </ThirdwebProvider> | ||
| ); | ||
| } | ||
|
|
||
| function UserTransactions() { | ||
| return ( | ||
| <> | ||
| <CodeExample | ||
| code={`\ | ||
| import { inAppWallet } from "thirdweb/wallets/in-app"; | ||
| import { ConnectButton, useActiveWallet } from "thirdweb/react"; | ||
|
|
||
| const wallet = inAppWallet(); | ||
|
|
||
| function App() { | ||
| const activeWallet = useActiveWallet(); | ||
|
|
||
| const handleClick = async () => { | ||
| const walletAddress = activeWallet?.getAccount()?.address; | ||
| const authToken = activeWallet?.getAuthToken?.(); | ||
| // transactions are a simple POST request to the thirdweb API | ||
| // or use the @thirdweb-dev/api type-safe JS SDK | ||
| const response = await fetch( | ||
| "https://api.thirdweb.com/v1/contract/write", | ||
| { | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| "x-client-id": "<your-project-client-id>", | ||
| // uses the in-app wallet's auth token to authenticate the request | ||
| "Authorization": "Bearer " + authToken, | ||
| }, | ||
| body: JSON.stringify({ | ||
| from: walletAddress, | ||
| chainId: "84532", | ||
| calls: [ | ||
| { | ||
| contractAddress: "0x...", | ||
| method: "function claim(address to, uint256 amount)", | ||
| params: [walletAddress, "1"], | ||
| }, | ||
| ], | ||
| }), | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <ConnectButton | ||
| client={client} | ||
| wallet={[wallet]} | ||
| connectButton={{ | ||
| label: "Login to mint!", | ||
| }} | ||
| /> | ||
| <Button | ||
| onClick={handleClick} | ||
| > | ||
| Mint | ||
| </Button> | ||
| </> | ||
| ); | ||
| }`} | ||
| header={{ | ||
| description: | ||
| "Queue, monitor, and retry transactions from your users in-app wallets. All transactions and analytics will be displayed in your developer dashboard.", | ||
| title: "Transactions from User Wallets", | ||
| }} | ||
| lang="tsx" | ||
| preview={<GatewayPreview />} | ||
| /> | ||
| </> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.