Part of https://www.notion.so/Laconic-Mainnet-Plan-1eca6b22d47280569cd0d1e6d711d949 Co-authored-by: Shreerang Kale <shreerangkale@gmail.com> Co-authored-by: Nabarun <nabarun@deepstacksoft.com> Reviewed-on: #1 Co-authored-by: shreerang <shreerang@noreply.git.vdb.to> Co-committed-by: shreerang <shreerang@noreply.git.vdb.to> |
||
---|---|---|
deploy | ||
public | ||
src | ||
.env.example | ||
.eslintrc.cjs | ||
.gitignore | ||
CLAUDE.md | ||
eslint.config.mjs | ||
next-env.d.ts | ||
next.config.mjs | ||
package-lock.json | ||
package.json | ||
postcss.config.mjs | ||
README.md | ||
tsconfig.json |
GOR Deploy - Laconic Registry
A simple Next.js frontend that allows users to pay in GOR tokens (configurable Solana SPL tokens) using Solana wallets and paste a URL. The transaction hash and URL are used to create records in the Laconic Registry.
Features
- Solana wallet integration (Phantom & Solflare) for GOR token payments
- Configurable Solana SPL token support (defaults to GOR)
- URL validation and submission
- Solana transaction verification with replay protection
- Laconic Registry record creation using official
@cerc-io/registry-sdk
- LNT token transfer integration for registry payments
- Automatic salt addition to DNS names to prevent collisions
- Error handling and validation throughout the application flow
Prerequisites
- Node.js 18.x or later
- npm or yarn
- Solana wallet browser extension (Phantom or Solflare)
- Access to a Laconic Registry node
Environment Variables
Copy the .env.local.example
file to .env.local
and fill in the required variables:
cp .env.local.example .env.local
Required environment variables:
Client-side (must be prefixed with NEXT_PUBLIC_):
NEXT_PUBLIC_SOLANA_RPC_URL
- The RPC URL for the Solana blockchainNEXT_PUBLIC_SOLANA_TOKEN_MINT_ADDRESS
- The mint address of the SPL token to acceptNEXT_PUBLIC_SOLANA_TOKEN_RECIPIENT_ADDRESS
- The Solana address that will receive token paymentsNEXT_PUBLIC_SOLANA_TOKEN_SYMBOL
- The token symbol to display (e.g., "GOR")NEXT_PUBLIC_SOLANA_TOKEN_DECIMALS
- The number of decimals for the token (e.g., 6)NEXT_PUBLIC_SOLANA_PAYMENT_AMOUNT
- The fixed payment amount required (e.g., 400)NEXT_PUBLIC_DOMAIN_SUFFIX
- Optional suffix to append to DNS names in the UI (e.g. ".example.com")NEXT_PUBLIC_EXAMPLE_URL
- Example URL to pre-fill in the URL form (e.g. "https://github.com/cerc-io/laconic-registry-cli")
Server-side:
REGISTRY_CHAIN_ID
- The chain ID for the Laconic RegistryREGISTRY_GQL_ENDPOINT
- The GraphQL endpoint for the Laconic RegistryREGISTRY_RPC_ENDPOINT
- The RPC endpoint for the Laconic RegistryREGISTRY_BOND_ID
- The bond ID to use for Laconic Registry recordsREGISTRY_AUTHORITY
- The authority for Laconic Registry LRNsREGISTRY_USER_KEY
- The private key for Laconic Registry transactions (also used for LNT transfers)APP_NAME
- The name of the application (used in record creation, defaults to "gor-deploy")DEPLOYER_LRN
- The LRN of the deployer
Installation
npm install
Development
npm run dev
Visit http://localhost:3000 to see the application.
Build for Production
npm run build
Start Production Server
npm start
How It Works
- User connects their Solana wallet (Phantom or Solflare) to the application
- User enters a URL they want to deploy to the Laconic Registry
- User completes payment in GOR tokens (or configured SPL token) to a specified Solana address
- The application verifies the Solana transaction with replay protection
- After payment verification, the server transfers LNT tokens from a prefilled account to the service provider
- The application calls a server-side API route which creates records in the Laconic Registry using the LNT transfer hash
- The server generates a unique DNS name by adding a random salt to prevent name collisions
- Two records are created in the Laconic Registry:
- An ApplicationRecord containing metadata about the URL
- An ApplicationDeploymentRequest linking the URL, DNS, and payment details with external_payment metadata
Architecture
This application uses a hybrid client/server approach:
- Client-side: Handles the user interface, Solana wallet integration, and transaction verification
- Server-side: Next.js API route handles LNT transfers and communication with the Laconic Registry
This architecture allows us to keep sensitive keys secure on the server side while providing a responsive user experience. The dual-payment system (Solana → LNT → Registry) enables cross-chain payment acceptance.
Resource Name Formats
DNS Name Format
The DNS names are generated with the following format:
{sanitized-url-name}-{short-commit-hash}-{random-salt}{domain-suffix}
For example:
- Basic DNS:
github-abc123-xyz789
- With domain suffix:
github-abc123-xyz789.example.com
The random salt ensures that each deployment request has a unique DNS name, even if the same URL is deployed multiple times or by different users. The optional domain suffix allows the application to display a full domain name to users.
Laconic Resource Name (LRN) Format
The Laconic Resource Names (LRNs) are generated with the following format:
lrn://{authority}/applications/{app-name}-{short-commit-hash}-{random-salt}
For example: lrn://gor/applications/github-abc123-xyz789
Including the commit hash and salt in the LRN ensures that each application record has a unique identifier, consistently matching the DNS naming pattern.
Reference Files
This application was built with reference to:
snowballtools-base/packages/backend/src/registry.ts
- Original
hosted-frontends/deploy-atom.sh
(adapted for Solana/GOR)
Deployment to Production
To deploy this application to production, follow these steps:
- Clone the repository
- Install dependencies:
npm install
- Create a production build:
npm run build
- Set up all required environment variables in your production environment
- Start the production server:
npm start
For containerized deployments, you can use the following Dockerfile:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
EXPOSE 3000
ENV NODE_ENV=production
CMD ["npm", "start"]
Build and run the Docker container:
docker build -t gor-deploy .
docker run -p 3000:3000 --env-file .env.production gor-deploy
Known Issues
- You may see a deprecated Buffer() warning during build. This comes from dependencies in the registry-sdk. This doesn't affect functionality.
- Ensure that your Solana RPC endpoint supports CORS for client-side requests.
- Solana wallet integrations require HTTPS in production environments.
Troubleshooting
Solana Wallet Issues
- Wallet not detecting: Install the Phantom or Solflare browser extension and refresh the page.
- Connection issues: Ensure the wallet is unlocked and try refreshing the page.
- Transaction failures: Check that you have sufficient SOL for transaction fees and enough tokens for the payment.
Token Configuration
- Wrong token: Verify the
NEXT_PUBLIC_SOLANA_TOKEN_MINT_ADDRESS
matches your desired SPL token. - Incorrect decimals: Ensure
NEXT_PUBLIC_SOLANA_TOKEN_DECIMALS
matches the token's actual decimal count. - Payment amount: Adjust
NEXT_PUBLIC_SOLANA_PAYMENT_AMOUNT
to the desired payment amount.
Laconic Registry Issues
- Failed to create record: Check that your REGISTRY_USER_KEY and REGISTRY_BOND_ID are correctly set.
- LNT transfer errors: Ensure your REGISTRY_USER_KEY has sufficient LNT balance.
- Transaction verification errors: Ensure your SOLANA_RPC_URL is accessible and returns correct transaction data.