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