Coder Social home page Coder Social logo

solpay's Introduction

Point of Sale

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.

Prerequisites

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)

    1. Create merchant wallet

    Follow the guide on how to create a wallet. This wallet will provide the recipient address.

    2. Create customer wallet

    Follow the guide on how to create another wallet. This wallet will be paying for the goods/services.

    3. Set Phantom to connect to devnet

    1. Click the settings icon in the Phantom window
    2. Select the "Change network" option and select "Devnet"

    4. Airdrop SOL to customer wallet

    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

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Clone the repository

With Git

git clone https://github.com/solana-labs/solana-pay.git

With Github CLI

gh repo clone solana-labs/solana-pay

Install dependencies

cd solana-pay/point-of-sale
yarn install

Start the local dev server

yarn start

Open the point of sale app

open "http://localhost:1234?recipient=Your+Merchant+Address&label=Your+Store+Name"

Accepting USDC on Mainnet

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}
            >

Deploying to Vercel

You can deploy this point of sale app to Vercel with a few clicks. Fork the project and configure it like this:

Solana Pay Point of Sale app Vercel configuration

Once the deployment finishes, navigate to

https://<YOUR DEPLOYMENT URL>?recipient=<YOUR WALLET ADDRESS>&label=Your+Store+Name

License

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.

solpay's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.