Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coinabase Wallet transaction on Solana DevNet is failing #1009

Open
kkatusic opened this issue Aug 20, 2024 · 4 comments
Open

Coinabase Wallet transaction on Solana DevNet is failing #1009

kkatusic opened this issue Aug 20, 2024 · 4 comments

Comments

@kkatusic
Copy link

Describe the bug

If you want to use Coinbase wallet to test transaction on Solana Devnet network you can't. No errors in console.

To Reproduce

Steps to reproduce the behavior:

  1. Open your Chrome browser
  2. Login to the Coinabase wallet
  3. Go to link: https://next-js-vercel-pi.vercel.app/solana
  4. Add recipient solana address
  5. Add small amount of the Solana devnet token
  6. Click on button "Do test transaction to...."
  7. You will see Coinbase popup with content like on image bellow

Expected behavior

It should ask you to confirm transaction and execute same on Solana devnet network

Screenshots

Screenshot 2024-08-20 at 14 49 26

Desktop (please complete the following information):

  • OS: MAC M1 OS Sonoma 14.6.1
  • Browser Chrome
  • Version 127.0.6533.120
  • Coinbase Wallet extension for Chrome: 3.80.1

Additional context

I will provide here test code, this is component inside NextJS.:

"use client";

import dynamic from "next/dynamic";
import {
  PublicKey,
  SystemProgram,
  Transaction,
  LAMPORTS_PER_SOL,
} from "@solana/web3.js";
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
import { WalletNotConnectedError } from "@solana/wallet-adapter-base";

import { useCallback, useState } from "react";

const MakeTestSolanaTransaction = () => {
  const { connection } = useConnection();
  const { publicKey, sendTransaction } = useWallet();
  const [recipientPublicKey, setRecipientPublicKey] = useState(
    new PublicKey("CASBXtuVK8WdNByaVaDfB1PGptMM7bJoVAjAuR2nWLNL")
  );

  const [solAmount, setSolAmount] = useState(0.001); // Default to 0.001 SOL

  const createTestSolanaTransaction = useCallback(async () => {
    if (!publicKey) throw new WalletNotConnectedError();
    if (!recipientPublicKey) {
      console.warn("No generated public key available. Generate one first.");
      return;
    }

    const transaction = new Transaction().add(
      SystemProgram.transfer({
        fromPubkey: publicKey,
        toPubkey: recipientPublicKey,
        lamports: solAmount * LAMPORTS_PER_SOL,
      })
    );

    // Define feePayer if it doesn't exist
    if (!transaction.feePayer) {
      transaction.feePayer = publicKey;
    }

    const simulationResult = await connection.simulateTransaction(transaction);

    console.log("Simulation Result:", simulationResult);

    if (simulationResult.value.err) {
      console.error("Simulation error:", simulationResult.value.err);
      return;
    }

    // Send the transaction
    try {
      const signature = await sendTransaction(transaction, connection);
      console.log("Transaction signature:", signature);

      // Optionally confirm the transaction
      await connection.confirmTransaction(signature, "confirmed");
      console.log("Transaction confirmed");
    } catch (error) {
      console.error("Transaction failed", error);
    }
  }, [publicKey, sendTransaction, connection, recipientPublicKey]);

  return (
    <>
      <h3 className="mb-4 text-4xl pb-12">Try to send 0,001 SOL on Devnet</h3>
      <div className="mb-12 w-2/4">
        <label className="block text-lg font-medium text-center">
          Recipient Address
        </label>
        <input
          type="text"
          value={recipientPublicKey.toString()}
          onChange={(e) => setRecipientPublicKey(new PublicKey(e.target.value))}
          className="w-full p-2 mt-1 border rounded"
          placeholder="Enter recipient's public key"
        />
      </div>

      <div className="mb-12">
        <label className="block text-lg font-medium text-center">
          Amount (SOL)
        </label>
        <input
          type="number"
          value={solAmount}
          onChange={(e) => setSolAmount(parseFloat(e.target.value))}
          className="w-full p-2 mt-1 border rounded"
          placeholder="Enter amount in SOL"
          min="0.001"
          step="0.001"
        />
      </div>
      <button
        onClick={createTestSolanaTransaction}
        className="p-4 bg-pink-700 text-white text-xl rounded"
      >
        Do test transaction to {recipientPublicKey.toString()} (0.001 SOL)
      </button>
    </>
  );
};

export default MakeTestSolanaTransaction;

this is solana provider:

"use client";

import React, { useMemo } from "react";
import {
  ConnectionProvider,
  WalletProvider,
} from "@solana/wallet-adapter-react";
import { WalletAdapterNetwork } from "@solana/wallet-adapter-base";
import { WalletModalProvider } from "@solana/wallet-adapter-react-ui";
import { clusterApiUrl } from "@solana/web3.js";
import {
  CoinbaseWalletAdapter,
  TrustWalletAdapter,
} from "@solana/wallet-adapter-wallets";

// Default styles that can be overridden by your app
require("@solana/wallet-adapter-react-ui/styles.css");

export default function AppWalletProvider({
  children,
}: {
  children: React.ReactNode;
}) {
  const network = WalletAdapterNetwork.Devnet;
  const endpoint = useMemo(() => clusterApiUrl(network), [network]);
  const wallets = useMemo(
    () => [
      new CoinbaseWalletAdapter({ network }),
      new TrustWalletAdapter({ network }),
    ],
    [network]
  );

  return (
    <ConnectionProvider endpoint={endpoint}>
      <WalletProvider wallets={wallets} autoConnect>
        <WalletModalProvider>{children}</WalletModalProvider>
      </WalletProvider>
    </ConnectionProvider>
  );
}
@Luchanso
Copy link

the same problem

@Luchanso
Copy link

Luchanso commented Sep 14, 2024

this is solflare wallet problem - on other everything okey

@kkatusic
Copy link
Author

this is solflare wallet problem - on other everything okey

You mean this is problem inside Coinbase wallet?

@Luchanso
Copy link

I have the same problem, but with solflare wallet issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants