Skip to content

Commit 95c4151

Browse files
Update playground pages (thirdweb-dev#3224)
1 parent 5d47e50 commit 95c4151

File tree

22 files changed

+840
-208
lines changed

22 files changed

+840
-208
lines changed
551 KB
Loading
112 KB
Loading
32.9 KB
Loading

apps/playground-web/public/pay.png

32.8 KB
Loading
Lines changed: 102 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import { CodeExample } from "@/components/code/code-example";
2-
import { StyledConnectButton } from "@/components/styled-connect-button";
31
import { Button } from "@/components/ui/button";
42
import { metadataBase } from "@/lib/constants";
53
import type { Metadata } from "next";
4+
import Image from "next/image";
65
import Link from "next/link";
7-
import { chain } from "../../../components/account-abstraction/constants";
8-
import { SponsoredTx } from "../../../components/account-abstraction/sponsored-tx";
6+
import {
7+
ConnectSmartAccountCustomPreview,
8+
ConnectSmartAccountPreview,
9+
} from "../../../components/account-abstraction/connect-smart-account";
10+
import { SponsoredTxPreview } from "../../../components/account-abstraction/sponsored-tx";
11+
import { CodeExample } from "../../../components/code/code-example";
912

1013
export const metadata: Metadata = {
1114
metadataBase,
@@ -16,13 +19,13 @@ export const metadata: Metadata = {
1619

1720
export default function Page() {
1821
return (
19-
<main className="flex-1 content-center relative py-12 md:py-24 lg:py-32 xl:py-48 space-y-12 md:space-y-24 lg:space-y-32 xl:space-y-48">
22+
<main className="flex-1 content-center relative py-12 md:py-24 lg:py-32 xl:py-48 space-y-12 md:space-y-24">
2023
<section className="container px-4 md:px-6">
2124
<div className="grid gap-10 lg:grid-cols-[1fr_400px] lg:gap-12 xl:grid-cols-[1fr_600px]">
2225
<div className="flex flex-col justify-center space-y-4 min-h-[100%]">
2326
<div className="space-y-2">
24-
<h1 className="text-3xl font-bold tracking-tighter sm:text-5xl xl:text-6xl/none font-inter mb-6 text-balance">
25-
Account abstraction made easy
27+
<h1 className="text-4xl font-bold tracking-tighter sm:text-5xl xl:text-6xl/none font-inter mb-6 text-balance">
28+
Account abstraction
2629
</h1>
2730
<p className="max-w-[600px] text-gray-500 md:text-xl dark:text-gray-300 mb-6 font-inter">
2831
Let users connect to their smart accounts with any wallet and
@@ -46,52 +49,110 @@ export default function Page() {
4649
</Button>
4750
</div>
4851
</div>
49-
<div className="w-full mx-auto my-auto sm:w-full lg:order-last relative flex flex-col space-y-2">
50-
<div className="mx-auto">
51-
<StyledConnectButton
52-
accountAbstraction={{
53-
chain,
54-
sponsorGas: true,
55-
}}
52+
<div className="w-full mx-auto my-auto sm:w-full order-first lg:order-last relative flex flex-col space-y-2">
53+
<div className="max-w-full sm:max-w-[500px] p-8">
54+
<Image
55+
src={"/account-abstraction.png"}
56+
width={600}
57+
height={400}
58+
objectFit={"contain"}
59+
alt=""
60+
priority={true}
5661
/>
5762
</div>
58-
59-
<p className="md:text-xl text-center text-muted-foreground">
60-
<small>👆 Connect to your smart account 👆</small>
61-
</p>
6263
</div>
6364
</div>
6465
</section>
6566

6667
<section className="container px-4 md:px-6 space-y-8">
67-
<div className="space-y-2">
68-
<h2 className="text-4xl font-semibold tracking-tight">
69-
Sponsored Transactions
70-
</h2>
71-
<p className="max-w-[600px]">
72-
One simple flag to enable transactions for your users.
73-
<br />
74-
Free on testnets, billed at the end of the month on mainnets.
75-
</p>
76-
</div>
68+
<ConnectSmartAccount />
69+
</section>
70+
71+
<section className="container px-4 md:px-6 space-y-8">
72+
<SponsoredTx />
73+
</section>
74+
</main>
75+
);
76+
}
77+
78+
function ConnectSmartAccount() {
79+
return (
80+
<>
81+
<div className="space-y-2">
82+
<h2 className="text-2xl sm:text-3xl font-semibold tracking-tight">
83+
Connect smart accounts
84+
</h2>
85+
<p className="max-w-[600px]">
86+
Enable smart accounts on the UI components or build your own UI.
87+
</p>
88+
</div>
89+
<CodeExample
90+
preview={<ConnectSmartAccountPreview />}
91+
code={`// Using UI components
92+
import { ConnectButton } from "thirdweb/react";
7793
78-
<CodeExample
79-
preview={<SponsoredTx />}
80-
code={`import { claimTo } from "thirdweb/extensions/erc1155";
81-
import { ConnectButton, TransactionButton } from "thirdweb/react";
94+
function App(){
95+
return (<>
96+
<ConnectButton client={client}
97+
// account abstraction options
98+
accountAbstraction={{ chain, sponsorGas: true }} />
99+
</>);
100+
};`}
101+
lang="tsx"
102+
/>
103+
<CodeExample
104+
preview={<ConnectSmartAccountCustomPreview />}
105+
code={`// Using your own UI
106+
import { useConnect } from "thirdweb/react";
107+
import { createWallet } from "thirdweb/wallets";
82108
83-
function App(){
84-
return (<>
85-
{/* converts any wallet to a smart account */}
86-
<ConnectButton client={client} accountAbstraction={{ chain, sponsorGas: true }} />
109+
function App(){
110+
const { connect } = useConnect({ client,
111+
// account abstraction options
112+
accountAbstraction: { chain, sponsorGas: true }});
87113
88-
{/* all transactions will be sponsored */}
114+
return (<>
115+
<button onClick={() => connect(async () => {
116+
// any wallet connected here will be
117+
// converted to a smart account
118+
const adminWallet = createWallet("io.metamask");
119+
await adminWallet.connect({ client });
120+
return adminWallet;
121+
})}>Connect (metamask)</button>
122+
</>);
123+
};`}
124+
lang="tsx"
125+
/>
126+
</>
127+
);
128+
}
129+
130+
function SponsoredTx() {
131+
return (
132+
<>
133+
<div className="space-y-2">
134+
<h2 className="text-2xl sm:text-3xl font-semibold tracking-tight">
135+
Sponsored transactions
136+
</h2>
137+
<p className="max-w-[600px]">
138+
Set `sponsorGas: true` to enable gas-free transactions for your users.
139+
<br />
140+
Free on testnets, billed at the end of the month on mainnets.
141+
</p>
142+
</div>
143+
<CodeExample
144+
preview={<SponsoredTxPreview />}
145+
code={`import { claimTo } from "thirdweb/extensions/erc1155";
146+
import { TransactionButton } from "thirdweb/react";
147+
148+
function App(){
149+
return (<>
150+
{/* transactions will be sponsored */}
89151
<TransactionButton transaction={() => claimTo({ contract, to: "0x123...", tokenId: 0n, quantity: 1n })}>Mint</TransactionButton>
90152
</>);
91153
};`}
92-
lang="tsx"
93-
/>
94-
</section>
95-
</main>
154+
lang="tsx"
155+
/>
156+
</>
96157
);
97158
}
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
import { CodeExample } from "@/components/code/code-example";
2+
import { Button } from "@/components/ui/button";
3+
import { metadataBase } from "@/lib/constants";
4+
import type { Metadata } from "next";
5+
import Image from "next/image";
6+
import Link from "next/link";
7+
import { SponsoredInAppTxPreview } from "../../../components/in-app-wallet/sponsored-tx";
8+
import { StyledConnectEmbed } from "../../../components/styled-connect-embed";
9+
10+
export const metadata: Metadata = {
11+
metadataBase,
12+
title: "Sign In, Account Abstraction and SIWE Auth | thirdweb Connect",
13+
description:
14+
"Let users sign up with their email, phone number, social media accounts or directly with a wallet. Seemlessly integrate account abstraction and SIWE auth.",
15+
};
16+
17+
export default function Page() {
18+
return (
19+
<main className="flex-1 content-center relative py-12 md:py-24 lg:py-32 xl:py-48 space-y-12 md:space-y-24">
20+
<section className="container px-4 md:px-6">
21+
<div className="grid gap-10 lg:grid-cols-[1fr_400px] lg:gap-12 xl:grid-cols-[1fr_600px]">
22+
<div className="flex flex-col justify-center space-y-4 min-h-[100%]">
23+
<div className="space-y-2">
24+
<h1 className="text-4xl font-bold tracking-tighter sm:text-5xl xl:text-6xl/none font-inter mb-6 text-balance">
25+
Onboard users to web3
26+
</h1>
27+
<p className="max-w-[600px] text-gray-500 md:text-xl dark:text-gray-300 mb-6 font-inter">
28+
Onboard anyone with flexible auth options, secure account
29+
recovery, and smart account integration.
30+
</p>
31+
</div>
32+
<div className="flex flex-col gap-4 min-[400px]:flex-row">
33+
<Button asChild size="lg">
34+
<Link
35+
target="_blank"
36+
href="https://portal.thirdweb.com/connect/in-app-wallet/overview"
37+
>
38+
View docs
39+
</Link>
40+
</Button>
41+
<Button asChild variant="outline" size="lg">
42+
<Link target="_blank" href="https://thirdweb.com/contact-us">
43+
Book a Demo
44+
</Link>
45+
</Button>
46+
</div>
47+
</div>
48+
<div className="w-full mx-auto my-auto sm:w-full order-first lg:order-last relative flex flex-col space-y-2">
49+
<div className="max-w-full sm:max-w-[600px]">
50+
<Image
51+
src={"/in-app-wallet.png"}
52+
width={600}
53+
height={400}
54+
objectFit={"contain"}
55+
alt=""
56+
priority={true}
57+
/>
58+
</div>
59+
</div>
60+
</div>
61+
</section>
62+
63+
<section className="container px-4 md:px-6 space-y-8">
64+
<AnyAuth />
65+
</section>
66+
67+
<section className="container px-4 md:px-6 space-y-8">
68+
<SponsoredInAppTx />
69+
</section>
70+
</main>
71+
);
72+
}
73+
74+
function AnyAuth() {
75+
return (
76+
<>
77+
<div className="space-y-2">
78+
<h2 className="text-2xl sm:text-3xl font-semibold tracking-tight">
79+
Any Auth Method
80+
</h2>
81+
<p className="max-w-[600px]">
82+
Use any of the built-in auth methods or bring your own.
83+
<br />
84+
Supports custom auth endpoints to integrate with your existing user
85+
base.
86+
</p>
87+
</div>
88+
89+
<CodeExample
90+
preview={<StyledConnectEmbed />}
91+
code={`import { inAppWallet } from "thirdweb/wallets";
92+
import { ConnectEmbed } from "thirdweb/react";
93+
94+
95+
const wallets = [
96+
inAppWallet(
97+
// built-in auth methods
98+
{ auth: {
99+
options: ["email", "phone", "passkey", "google", "apple", "facebook"]
100+
}
101+
}
102+
// or bring your own auth endpoint
103+
)
104+
];
105+
106+
function App(){
107+
return (
108+
<ConnectEmbed client={client} wallets={wallets} />);
109+
};`}
110+
lang="tsx"
111+
/>
112+
</>
113+
);
114+
}
115+
116+
function SponsoredInAppTx() {
117+
return (
118+
<>
119+
<div className="space-y-2">
120+
<h2 className="text-2xl sm:text-3xl font-semibold tracking-tight">
121+
Signless Sponsored Transactions
122+
</h2>
123+
<p className="max-w-[600px]">
124+
With in-app wallets, users don&apos;t need to confirm every
125+
transaction.
126+
<br />
127+
Combine it with smart account flag to cover gas costs for the best UX.
128+
</p>
129+
</div>
130+
<CodeExample
131+
preview={<SponsoredInAppTxPreview />}
132+
code={`import { inAppWallet } from "thirdweb/wallets";
133+
import { claimTo } from "thirdweb/extensions/erc1155";
134+
import { ConnectButton, TransactionButton } from "thirdweb/react";
135+
136+
137+
const wallets = [
138+
inAppWallet(
139+
// turn on gas sponsorship for in-app wallets
140+
{ smartAccount: { chain, sponsorGas: true }}
141+
)
142+
];
143+
144+
function App(){
145+
return (<>
146+
<ConnectButton client={client} wallets={wallets} />
147+
148+
{/* signless, sponsored transactions */}
149+
<TransactionButton transaction={() => claimTo({ contract, to: "0x123...", tokenId: 0n, quantity: 1n })}>Mint</TransactionButton>
150+
</>);
151+
};`}
152+
lang="tsx"
153+
/>
154+
</>
155+
);
156+
}

0 commit comments

Comments
 (0)