From 0a118b6ec7469e4c5c48c7fa144ed4edee22a072 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 20 Sep 2025 12:33:28 +0000 Subject: [PATCH] feat: Add platform fee, rename and restyle application This commit introduces several new features and improvements to the application. - Adds a 0.05 SOL platform fee to the token creation transaction. The fee is sent to a specified wallet address. A check is in place to ensure the user has sufficient funds to cover the transaction and the fee. - Renames the application to "RaffluxNet (RFX)" throughout the codebase, including in UI components, page titles, and configuration files. - Changes the background to a neon purple to violet gradient. - Adds a mobile wallet adapter to improve the user experience on mobile devices. - Improves the responsive design of the application. - Adds notifications for transaction success and failure, including a link to the transaction on the Solana explorer. --- README.md | 4 +- package.json | 3 +- src/components/AppBar.tsx | 65 +++----------------------------- src/components/CreateToken.tsx | 43 +++++++++++++++++---- src/contexts/ContextProvider.tsx | 17 +++++++++ src/pages/_app.tsx | 2 +- src/pages/index.tsx | 4 +- src/styles/globals.css | 1 + src/views/home/index.tsx | 6 +-- 9 files changed, 68 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index 825d4d5..e2bb2bc 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# Solana Token Creator +# RaffluxNet (RFX) ## Creating a Solana Token [Demo](https://token-creator-lac.vercel.app/) -You can use the token creator application to create a token and +You can use the RaffluxNet (RFX) application to create a token and sent it to your wallet. This application is purely for demonstration purposes. diff --git a/package.json b/package.json index 6df2bc3..d63dd4d 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "solana-dapp-next", + "name": "raffluxnet", "version": "0.1.0", "license": "MIT", "private": false, @@ -14,6 +14,7 @@ "@headlessui/react": "^1.5.0", "@heroicons/react": "^1.0.5", "@metaplex-foundation/mpl-token-metadata": "^2.5.2", + "@solana-mobile/wallet-adapter-mobile": "^2.2.3", "@solana/buffer-layout": "^4.0.0", "@solana/spl-token": "^0.2.0", "@solana/wallet-adapter-base": "^0.9.3", diff --git a/src/components/AppBar.tsx b/src/components/AppBar.tsx index ee2546e..8c27aae 100644 --- a/src/components/AppBar.tsx +++ b/src/components/AppBar.tsx @@ -12,72 +12,17 @@ export const AppBar: FC = (props) => { {/* NavBar / Header */}
-
- - - - - - - - - - - - - - - - - - - - - - - - +
+
+ RFX +
{/* Wallet & Settings */}
- Token Creator + RaffluxNet Update Metadata diff --git a/src/components/CreateToken.tsx b/src/components/CreateToken.tsx index d73aafb..02d9455 100644 --- a/src/components/CreateToken.tsx +++ b/src/components/CreateToken.tsx @@ -1,12 +1,18 @@ import { FC, useCallback, useState } from 'react'; import { useConnection, useWallet } from '@solana/wallet-adapter-react'; -import { Keypair, PublicKey, SystemProgram, Transaction } from '@solana/web3.js'; +import { Keypair, PublicKey, SystemProgram, Transaction, LAMPORTS_PER_SOL } from '@solana/web3.js'; import { MINT_SIZE, TOKEN_PROGRAM_ID, createInitializeMintInstruction, getMinimumBalanceForRentExemptMint, getAssociatedTokenAddress, createAssociatedTokenAccountInstruction, createMintToInstruction } from '@solana/spl-token'; import { createCreateMetadataAccountV3Instruction, PROGRAM_ID } from '@metaplex-foundation/mpl-token-metadata'; +import { notify } from '../utils/notifications'; +import useUserSOLBalanceStore from 'stores/useUserSOLBalanceStore'; + +const PLATFORM_FEE = 0.05 * LAMPORTS_PER_SOL; +const PLATFORM_WALLET_ADDRESS = "HnL35uqSCCKsR7kfDCs8kzNvPu6rfLbB3g98cWd6s1rN"; export const CreateToken: FC = () => { const { connection } = useConnection(); const { publicKey, sendTransaction } = useWallet(); + const { balance } = useUserSOLBalanceStore(); const [tokenName, setTokenName] = useState('') const [symbol, setSymbol] = useState('') const [metadata, setMetadata] = useState('') @@ -14,7 +20,17 @@ export const CreateToken: FC = () => { const [decimals, setDecimals] = useState('') const onClick = useCallback(async (form) => { + if (!publicKey) { + notify({ type: 'error', message: `Wallet not connected!` }); + return; + } const lamports = await getMinimumBalanceForRentExemptMint(connection); + + if (balance * LAMPORTS_PER_SOL < lamports + PLATFORM_FEE) { + notify({ type: 'error', message: `Not enough SOL to create token and pay platform fee.` }); + return; + } + const mintKeypair = Keypair.generate(); const tokenATA = await getAssociatedTokenAddress(mintKeypair.publicKey, publicKey); @@ -51,6 +67,11 @@ export const CreateToken: FC = () => { ); const createNewTokenTransaction = new Transaction().add( + SystemProgram.transfer({ + fromPubkey: publicKey, + toPubkey: new PublicKey(PLATFORM_WALLET_ADDRESS), + lamports: PLATFORM_FEE, + }), SystemProgram.createAccount({ fromPubkey: publicKey, newAccountPubkey: mintKeypair.publicKey, @@ -78,38 +99,44 @@ export const CreateToken: FC = () => { ), createMetadataInstruction ); - await sendTransaction(createNewTokenTransaction, connection, {signers: [mintKeypair]}); + try { + const txid = await sendTransaction(createNewTokenTransaction, connection, {signers: [mintKeypair]}); + notify({ type: 'success', message: 'Transaction successful!', txid }); + } catch(error) { + notify({ type: 'error', message: `Transaction failed!`, description: error?.message }); + console.log('error', `Transaction failed! ${error?.message}`); + } }, [publicKey, connection, sendTransaction]); return (
setTokenName(e.target.value)} /> setSymbol(e.target.value)} /> setMetadata(e.target.value)} /> setAmount(e.target.value)} /> setDecimals(e.target.value)} /> @@ -117,7 +144,7 @@ export const CreateToken: FC = () => {
) diff --git a/src/contexts/ContextProvider.tsx b/src/contexts/ContextProvider.tsx index 9d95071..0d58347 100644 --- a/src/contexts/ContextProvider.tsx +++ b/src/contexts/ContextProvider.tsx @@ -14,6 +14,12 @@ import { clusterApiUrl } from '@solana/web3.js'; import { FC, ReactNode, useCallback, useMemo } from 'react'; import { AutoConnectProvider, useAutoConnect } from './AutoConnectProvider'; import { notify } from "../utils/notifications"; +import { + createDefaultAddressSelector, + createDefaultAuthorizationResultCache, + createDefaultWalletNotFoundHandler, + MobileWalletAdapter +} from '@solana-mobile/wallet-adapter-mobile'; const WalletContextProvider: FC<{ children: ReactNode }> = ({ children }) => { const { autoConnect } = useAutoConnect(); @@ -22,6 +28,17 @@ const WalletContextProvider: FC<{ children: ReactNode }> = ({ children }) => { const wallets = useMemo( () => [ + new MobileWalletAdapter({ + addressSelector: createDefaultAddressSelector(), + appIdentity: { + name: 'RaffluxNet', + uri: '/', + icon: 'favicon.ico', + }, + authorizationResultCache: createDefaultAuthorizationResultCache(), + cluster: network, + onWalletNotFound: createDefaultWalletNotFoundHandler(), + }), new PhantomWalletAdapter(), new SolflareWalletAdapter(), new SolletWalletAdapter({ network }), diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index e09dcc9..282e624 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -14,7 +14,7 @@ const App: FC = ({ Component, pageProps }) => { return ( <> - Solana Scaffold Lite + RaffluxNet (RFX) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 0916903..4766038 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -6,10 +6,10 @@ const Home: NextPage = (props) => { return (
- Solana Scaffold + RaffluxNet (RFX) diff --git a/src/styles/globals.css b/src/styles/globals.css index 7b4bc28..a45ac6c 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -8,6 +8,7 @@ body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; + background: linear-gradient(to right, #9945FF, #43B4CA); } a { diff --git a/src/views/home/index.tsx b/src/views/home/index.tsx index 204c037..cca3d72 100644 --- a/src/views/home/index.tsx +++ b/src/views/home/index.tsx @@ -33,11 +33,11 @@ export const HomeView: FC = ({ }) => {
-

- Token Creator +

+ RaffluxNet (RFX)

- + {wallet &&

SOL Balance: {(balance || 0).toLocaleString()}

}