This is an example of how you can use the @solana/pay
JavaScript library to create a simple point of sale system.
You can check out the demo (using devnet), use the code as a reference, or run it yourself to start accepting decentralized payments in-person.
To build and run this app locally, you'll need:
-
Node.js v14.17.0 or above
-
Yarn
-
Setup two wallets on Phantom (Merchant and Customer)
Follow the guide on how to create a wallet. This wallet will provide the recipient address.
Follow the guide on how to create another wallet. This wallet will be paying for the goods/services.
- Click the settings icon in the Phantom window
- Select the "Change network" option and select "Devnet"
Use solfaucet to airdrop SOL to the customer wallet.
You'll need SOL in the customer wallet to pay for the goods/services + transaction fees
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
git clone https://github.com/solana-labs/solana-pay.git
gh repo clone solana-labs/solana-pay
cd solana-pay/point-of-sale
yarn install
yarn start
open "http://localhost:1234?recipient=Your+Merchant+Address&label=Your+Store+Name"
Import the Mainnet endpoint, along with USDC's mint address and icon in the RootRoute.tsx
file.
import { MAINNET_ENDPOINT, MAINNET_USDC_MINT } from '../../utils/constants';
import { USDCIcon } from '../images/USDCIcon';
In the same file, set the endpoint
value in the <ConnectionProvider>
to MAINNET_ENDPOINT
and set the following values in the <ConfigProvider>
:
splToken={MAINNET_USDC_MINT}
symbol="USDC"
icon={<USDCIcon />}
decimals={6}
minDecimals={2}
Make sure to use 6 decimals for USDC!
When you're done, it should look like this:
<ConnectionProvider endpoint={MAINNET_ENDPOINT}>
<WalletProvider wallets={wallets} autoConnect={connectWallet}>
<WalletModalProvider>
<ConfigProvider
recipient={recipient}
label={label}
splToken={MAINNET_USDC_MINT}
symbol="USDC"
icon={<USDCIcon />}
decimals={6}
minDecimals={2}
requiredConfirmations={9}
connectWallet={connectWallet}
>
You can deploy this point of sale app to Vercel with a few clicks. Fork the project and configure it like this:
Once the deployment finishes, navigate to
https://<YOUR DEPLOYMENT URL>?recipient=<YOUR WALLET ADDRESS>&label=Your+Store+Name
The Solana Pay Point of Sale app is open source and available under the Apache License, Version 2.0. See the LICENSE file for more info.