spacebudz / lucid

Lucid is a library, which allows you to create Cardano transactions and off-chain code for your Plutus contracts in JavaScript, Deno and Node.js.
https://lucid.spacebudz.io
MIT License
336 stars 133 forks source link

Nami requests signature fee instead of requesting payment? #227

Closed viraladmin closed 9 months ago

viraladmin commented 9 months ago

I am trying to follow the example from the README.

My code looks as follows.

      import { Lucid, Blockfrost } from "https://unpkg.com/lucid-cardano@0.10.7/web/mod.js";

      const projectId = "MY_MAINNET_ID"; // Your Blockfrost project ID 
      const payWithCardanoButton = document.getElementById("payWithCardano");

      payWithCardanoButton.addEventListener("click", async () => {
        try {
          const blockfrostBaseUrl = "https://cardano-mainnet.blockfrost.io/api/v0";
          const blockfrost = new Blockfrost(blockfrostBaseUrl, projectId);
          const lucid = await Lucid.new(blockfrost, "Mainnet");
          const nami = window.cardano.nami;

          if (nami) {
            const api = await nami.enable();
            lucid.selectWallet(api); // Select the NAMI wallet
            const tx = await lucid.newTx()
              .payToAddress("MY_WALLET_ADDRESS", { lovelace: 5000000n })
              .complete();

            const signedTx = await tx.sign().complete();
            const txHash = await signedTx.submit();
            console.log(txHash);
          } else {
            alert("NAMI wallet not detected. Please install NAMI and try again.");
          }
        } catch (error) {
          console.error("Payment process failed. Error:", error);
        }
      });

The problem I am having is... this opens the nami wallet, and says "This app requests a signature for:"

Then it shows the tx fee.

It does not actually request the user send payment to MY_WALLET_ADDRESS

What am I doing wrong?

viraladmin commented 9 months ago

I am stupid that is all. This works perfectly if I don't test it from the same wallet listed in the script.