Skip to content

Privy MPC wallet demo #97

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mauridev777
Copy link

πŸ“ BNB Ping Pong DApp β€” Privy MPC Wallet Demo

This is a minimal web3 DApp that demonstrates how to use Privy Embedded Wallets to interact with a smart contract on the BNB Testnet. Players can click Ping or Pong, which sends an on-chain transaction via Privy, updating the contract state.

πŸ“ Demo Details

πŸ“¦ Tech Stack

  • Next.js 14 (App Router)
  • Tailwind CSS
  • Ethers.js
  • Privy Embedded Wallet SDK
  • React Hot Toast

πŸ›  How to Run Locally

1. Clone the repo

git clone https://github.com/yourusername/bnb-pingpong.git
cd bnb-pingpong

2. Install dependencies

npm install

3. Configure environment variables

Copy the .env.example to .env.local:

cp .env.example .env.local

Then update the following fields with your Privy credentials:

NEXT_PUBLIC_PRIVY_APP_ID=YOUR_PRIVY_APP_ID
PRIVY_APP_SECRET=YOUR_PRIVY_APP_SECRET

4. Create a Privy Project

  1. Go to https://www.privy.io
  2. Create a new account or log in
  3. Create a new app
  4. Enable:
    • Embedded Wallet
    • Email
    • Social Media Logins
  5. Copy your:
    • App ID β†’ use for NEXT_PUBLIC_PRIVY_APP_ID
    • App Secret β†’ use for PRIVY_APP_SECRET
  6. Add http://localhost:3000 to the allowed origins in your Privy dashboard

5. Start the dev server

npm run dev

Visit http://localhost:3000 in your browser.

πŸ“„ Smart Contract ABI

function ping() external;
function pong() external;
function pingCount() view returns (uint256);
function pongCount() view returns (uint256);
function nextMove() view returns (string);

πŸ”” UX Notes

  • You will see a toast after transaction is sent (with link to BscScan)
  • Toasts appear above Privy modals
  • This demo uses Privy's useSendTransaction() with success callbacks

πŸ§ͺ BNB Testnet Faucet

Get testnet BNB from:
πŸ‘‰ https://bnb-faucet.netlify.app/

πŸ“ .env.example

Use this template to set up your local .env.local file:

NEXT_PUBLIC_PRIVY_APP_ID=YOUR_PRIVY_APP_ID
PRIVY_APP_SECRET=YOUR_PRIVY_APP_SECRET
PINGPONG_ADDRESS=0x52943bFb088221cd6E3181fbc19081A6B34be948
RPC_URL=https://data-seed-prebsc-1-s1.binance.org:8545/
NEXT_PUBLIC_PINGPONG_CONTRACT_ADDRESS=0x52943bFb088221cd6E3181fbc19081A6B34be948
NEXT_PUBLIC_RPC_URL=https://data-seed-prebsc-1-s1.binance.org:8545/

πŸ“œ License

MIT β€” use freely for demos, hacks, and experimentation.

Made with πŸ’› on BNB Testnet.

@Tianaliu
Copy link

Tianaliu commented Jul 31, 2025

Congrats! You are the bounty winner. Please share your BSC address for the reward. thanks! https://x.com/BNBChainDevs/status/1950753301496254648

@mauridev777
Copy link
Author

Congrats! You are the bounty winner. Please share your BSC address for the reward. thanks! https://x.com/BNBChainDevs/status/1950753301496254648

Hello! here is my Binance.com addres for BSC chain.
0x354754c0f812e673858070586e462ce78ff1a43a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants