1- import { CodeExample } from "@/components/code/code-example" ;
2- import { StyledConnectButton } from "@/components/styled-connect-button" ;
31import { Button } from "@/components/ui/button" ;
42import { metadataBase } from "@/lib/constants" ;
53import type { Metadata } from "next" ;
4+ import Image from "next/image" ;
65import 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
1013export const metadata : Metadata = {
1114 metadataBase,
@@ -16,13 +19,13 @@ export const metadata: Metadata = {
1619
1720export 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}
0 commit comments