> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Solana Legacy Transaction

<Card title="Recommended: JavaScript SDK with React Hooks" icon="react" color="#4779FE">
  For new React apps, we recommend the JavaScript SDK with React Hooks (`@dynamic-labs-sdk/react-hooks`) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the [React quickstart (JavaScript SDK)](/javascript/reference/react-quickstart) to get started.
</Card>

```tsx React theme={"system"}
    import React, { useState } from 'react';
    import type { ISolana } from '@dynamic-labs/solana-core';
    import { isSolanaWallet } from '@dynamic-labs/solana-core';
    import { useDynamicContext } from '@dynamic-labs/sdk-react-core';
    import type { Connection } from '@solana/web3.js';
    import { PublicKey, SystemProgram, Transaction } from '@solana/web3.js';

    function LegacyTransaction() {
        const [address, setAddress] = useState('');
        const [amount, setAmount] = useState('');
        const { primaryWallet } = useDynamicContext();

        const sendTransaction = async () => {

            if(!primaryWallet || !isSolanaWallet(primaryWallet)) {
            return;
            }

            const connection: Connection = await primaryWallet.getConnection();
            const cluster = connection.rpcEndpoint.includes('devnet') ? 'devnet' : 'mainnet';

            const fromKey = new PublicKey(primaryWallet.address);
            const toKey = new PublicKey(address);

            const amountInLamports = Number(amount) * 1000000000;
            const transferTransaction = new Transaction().add(
            SystemProgram.transfer({
                fromPubkey: fromKey,
                lamports: amountInLamports,
                toPubkey: toKey,
            }),
            );
            const blockhash = await connection.getLatestBlockhash();
            transferTransaction.recentBlockhash = blockhash.blockhash;
            transferTransaction.feePayer = fromKey;

            const signer: ISolana = await primaryWallet.getSigner();

            await signer
            .signAndSendTransaction(transferTransaction)
            .then((value: { signature: string }) => {
                console.log(
                `Transaction successful: https://solscan.io/tx/${value.signature}?cluster=${cluster}`,
                );
            })
            .catch((error: Error) => {
                console.error(error);
            });
        }

        return (
            <div>
                <h1>Legacy Transaction</h1>
                    <input type="text" placeholder="Address" value={address} onChange={(e) => setAddress(e.target.value)} />
                    <input type="text" placeholder="Amount" value={amount} onChange={(e) => setAmount(e.target.value)} />
                    <button type="button" onClick={() => sendTransaction()}>Send Transaction</button>

            </div>
        )
    }

    export default LegacyTransaction;
```

## Simulate a Transaction

Before sending a transaction, you can simulate it to preview the effects and validate that it will succeed. Transaction simulation shows all asset transfers involved in the transaction.

<Note>
  Transaction simulation uses the currently selected primary wallet. Make sure the user has a wallet connected before attempting to simulate a transaction.
</Note>
