> For the complete documentation index, see [llms.txt](https://docs-wallet.magiceden.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-wallet.magiceden.io/solana/sending-a-transaction.md).

# Sending a Transaction

Sending a transaction on the Solana network requires the creation of a Transaction object, followed by the transaction being signed and submitted by the user's Magic Eden wallet.

{% hint style="info" %}
:green\_book:**Solana Web3js**

For more information on interacting with Solana on the client side, check out the docs for [Solana Web3js](https://solana-labs.github.io/solana-web3.js/)

For more general Solana development information, check out the courses and resources offered on [Soldev](https://www.soldev.app/)
{% endhint %}

## Creating a Transaction

Before you can sign or send a transaction, you must create one! Below is a basic example of creating a tx that has a user send funds right back to themselves

```javascript
import {
  Transaction,
  SystemProgram,
  Connection,
  PublicKey,
} from "@solana/web3.js";

/**
 * Creates an example transaction to transfer 100 lamports to the same account.
 * @param {String} publicKey a wallet public key
 * @param {Connection} connection an RPC connection
 * @returns {Transaction} a transaction
 */
export const createTransaction = async (
  publicKey: PublicKey,
  connection: Connection
): Promise<Transaction> => {
  const latestBlockhash = (await connection.getLatestBlockhash()).blockhash;
  const transaction = new Transaction().add(
    SystemProgram.transfer({
      fromPubkey: publicKey,
      toPubkey: publicKey,
      lamports: 1000,
    })
  );
  transaction.feePayer = publicKey;
  transaction.recentBlockhash = latestBlockhash;

  return transaction;
};

```

## Signing and Sending a Transaction

Once the transaction is created, you can then prompt the user to sign and send it using the `signAndSendTransaction` method exposed by the provider

```javascript
import { Transaction } from "@solana/web3.js";

import { MagicEdenProvider } from "../types/types";

/**
 * Signs and sends the given created transaction using the MagicEdenProvider object.
 * @param {MagicEdenProvider} provider The MagicEdenProvider object
 * @param {Transaction} transaction The transaction to sign and send
 * @returns {Promise<string>} A promise that resolves to the signature of the transaction
 */
export const signAndSendTransaction = async (
  provider: MagicEdenProvider,
  transaction: Transaction
): Promise<string> => {
  try {
    const { signature } = await provider.signAndSendTransaction(transaction);
    return signature;
  } catch (error) {
    console.warn(error);
    throw new Error(
      "An unexpected error occured while signing the transaction."
    );
  }
};

```

All of this functionality and more can be found at our [Solana Demo](https://github.com/Tcadle434/me-wallet-solana-react/blob/main/src/App.tsx), so feel free to check it out if you want to learn more about handling wallet functionality when connecting directly to the Magic Eden wallet.

{% hint style="info" %}
**Note** :pencil:\
The signAndSendTransaction method supports both Legacy and [Versioned Transactions](https://solana.com/docs/advanced/versions). The newer Versioned Txs allow for [Address Lookup Tables](https://solana.com/docs/advanced/lookup-tables)
{% endhint %}
