Skip to content

Commit 5e57150

Browse files
committed
Update readme
1 parent 5b448f4 commit 5e57150

2 files changed

Lines changed: 45 additions & 21 deletions

File tree

.env.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
NEXT_PUBLIC_THIRDWEB_CLIENT_ID=
21
NEXT_PUBLIC_WALLET_ADDRESS=
2+
NEXT_PUBLIC_THIRDWEB_CLIENT_ID=
33
NEXT_PUBLIC_NFT_CONTRACT_ADDRESS=
44
PAY_WEBHOOK_SECRET=
55
BACKEND_WALLET_ADDRESS=

README.md

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,60 @@
1-
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
1+
# Direct Payments with Pay and Engine
2+
3+
This [Next.js](https://nextjs.org) example project follows the [Direct Payments guide](https://portal.thirdweb.com/connect/pay/guides/accept-direct-payments) and shows you how to build a cross-chain purchase flow that:
4+
5+
1. Sends tokens to your merchant wallet address using thirdweb's Pre-built Pay component.
6+
2. Sends an NFT to the buyer's wallet address using thirdweb Engine.
27

38
## Getting Started
49

5-
First, run the development server:
10+
The main logic for this example can be found in `src/app/page.tsx` (client) and `src/app/api/route.ts` (server).
11+
12+
In order to run this example, you'll need to copy `.env.sample` to a new `.env` and populate the following fields:
613

714
```bash
8-
npm run dev
9-
# or
10-
yarn dev
11-
# or
12-
pnpm dev
13-
# or
14-
bun dev
15+
NEXT_PUBLIC_WALLET_ADDRESS=
16+
NEXT_PUBLIC_THIRDWEB_CLIENT_ID=
17+
NEXT_PUBLIC_NFT_CONTRACT_ADDRESS=
18+
PAY_WEBHOOK_SECRET=
19+
BACKEND_WALLET_ADDRESS=
20+
ENGINE_API_URL=
21+
ENGINE_ACCESS_TOKEN=
1522
```
1623

17-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
24+
Note that `NEXT_PUBLIC_WALLET_ADDRESS` should be the merchant wallet address you'd like funds to be sent to. This could be your business wallet, for example.
25+
26+
### Getting a Client ID
27+
28+
To create a Client ID, navigate to the [Settings page](https://thirdweb.com/dashboard/settings/api-keys) in your dashboard and click Create API Key. Copy the Client ID field and paste it into your `.env`.
1829

19-
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
30+
### Deploying an NFT Contract
2031

21-
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
32+
Head to our [Contract Explorer](https://thirdweb.com/explore) and choose the token contract (ERC20, ERC721, ERC721C, ERC1155) that suits your use case. In our example, we utilize the [NFT Drop contract](https://thirdweb.com/thirdweb.eth/DropERC721). Enter the required information and select your chain. Once your contract has been deployed, copy the contract address and paste it into your `.env`.
2233

23-
## Learn More
34+
### Creating a Pay Webhook
2435

25-
To learn more about Next.js, take a look at the following resources:
36+
Navigate to your [Pay Dashboard](https://thirdweb.com/dashboard/connect/pay), click the "Webhooks" tab, and click "Create Webhook". Enter the URL where you'd like to listen events. In our case, since we are testing locally, we'll need to specify `localhost:3000/api` (or the port of your choice). Copy the generated Webhook URL and paste it into your `.env`.
2637

27-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
38+
### Deploying an Engine
2939

30-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
40+
If you have not already deployed an Engine instance, navigate to the [Engine Dashboard](https://thirdweb.com/dashboard/engine) and click "Create Engine Instance". Select the tier that best suits your use case. Once you've deployed, copy the generated URL and paste it into your `.env`.
3141

32-
## Deploy on Vercel
42+
### Creating an Engine Access Token
3343

34-
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
44+
Once you've deployed your Engine, click into your instance and navigate to the Access Tokens page. Click "Create Access Token". Copy the generated token and paste it into your `.env`.
45+
46+
### Try it out
47+
48+
Now, you can run your development server:
49+
50+
```bash
51+
npm run dev
52+
# or
53+
yarn dev
54+
# or
55+
pnpm dev
56+
# or
57+
bun dev
58+
```
3559

36-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
60+
Your Direct Payments client and server will now run at `localhost:3000`.

0 commit comments

Comments
 (0)