<p>Nami is a web wallet and injects its API into your website. It is not supposed to work with desktop applications but only with web apps. I recommend you to build your app with react + typescript + emurgo/cardano-serialization-lib-browser. That is how I built this <a href="https://native-asset.com/" rel="nofollow noreferrer">minting app</a></p>

CC BY-SA 4.0
2021-12-16T18:33:22.620Z
2021-12-16T18:33:22.620Z
Frank Weslien
<p>Another option:</p>
<p>Transaction can be built in Java backend and then sent to Nami for signing.</p>
<p>Here's a sample code for Multi-sig token mint where</p>
<p>(Not exactly same but similar approach can be used for your scenario)</p>
<ol>
<li>Mint Transaction is built in Java backend</li>
<li>Sign by Nami extension in the browser</li>
<li>Send the witness back to Java backend</li>
<li>Assemble transaction again with other witnesses in Java backend and submit the final transaction</li>
</ol>
<p><a href="https://github.com/bloxbean/cardano-client-examples/blob/c3aec693977aff1e82b3c24ac5402f4ecc8748fd/src/main/java/com/bloxbean/cardano/client/examples/MultiSigMint.java#L154" rel="nofollow noreferrer">MultiSigTokenMint With Java + Nami</a></p>

CC BY-SA 4.0
2022-01-02T02:36:54.443Z
2022-01-02T02:47:31.897Z
2022-01-02T02:47:31.897Z
Satya
<p>I have done this function, don't know if it will help you.</p>
<p>Two projects are required:</p>
<p><a href="https://github.com/bloxbean/cardano-client-examples" rel="nofollow noreferrer">cardano-client-examples</a>
<a href="https://github.com/zjavax/cardano-client-examples-zx/blob/main/src/main/java/cn/zjavax/BuildWithJavaBackend.java" rel="nofollow noreferrer">https://github.com/zjavax/cardano-client-examples-zx/blob/main/src/main/java/cn/zjavax/BuildWithJavaBackend.java</a></p>
<pre>
public class BuildWithJavaBackend extends BaseTest {
    public static void main(String[] args) throws AddressExcepion, CborSerializationException, ApiException {
        new BuildWithJavaBackend().transfer();
        System.exit(1);
    }

    public void transfer() throws CborSerializationException, ApiException, AddressExcepion {
//        String senderMnemonic = "kit color frog trick speak employ suit sort bomb goddess jewel primary spoil fade person useless measure manage warfare reduce few scrub beyond era";
        String senderAddress = "addr_test1qqxnp3khzm7kcj9t23hskehat7428ghsenk0pfew4rqy5v9frnmht7uwrl073q4jvq20z82kh4rksyns540azhndqexqpvhgqr";
        String receiverAddress1 = "addr_test1qqwpl7h3g84mhr36wpetk904p7fchx2vst0z696lxk8ujsjyruqwmlsm344gfux3nsj6njyzj3ppvrqtt36cp9xyydzqzumz82";

        Output output1 = Output.builder()
                .address(receiverAddress1)
                .assetName(LOVELACE)
                .qty(adaToLovelace(1))
                .build();

        TxBuilder txBuilder = (output1.outputBuilder()
                .buildInputs(createFromSender(senderAddress, senderAddress))
        )
                .andThen(feeCalculator(senderAddress, 1))
                .andThen(adjustChangeOutput(senderAddress, 1));

        Transaction signedTransaction = TxBuilderContext.init(utxoSupplier, protocolParamsSupplier).build(txBuilder);

        System.out.println("txHexDraft=\"" +signedTransaction.serializeToHex()+"\"");

    }
}
</pre>
<p><a href="https://github.com/Ausstaker/cardano-walletconnector-demo" rel="nofollow noreferrer">cardano-walletconnector-demo</a>
<a href="https://i.sstatic.net/KqmjX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/KqmjX.png" alt="enter image description here" /></a></p>
<p>The result of calling cc wallet:
<a href="https://i.sstatic.net/xpbrD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/xpbrD.png" alt="enter image description here" /></a></p>
<p>@Satya（don't know how @）</p>

CC BY-SA 4.0
2022-06-07T16:02:13.740Z
2022-06-29T02:35:54.523Z
2022-06-29T02:35:54.523Z
zjavax
<p>I don't think you can get the wallet instance from Nami as the whole point of a wallet is to hide the private key and pass transactions visually to the user so that she can approve and submit them.</p>
<p>I would rather try the other way and look if your java library has methods to generate an unbalanced transaction that can be passed to the Nami wallet. Such a method would only need the wallet's UTxOs and the address of the recipient.</p>
<p>But I also have no clue on which libraries do this. It is very difficult at the moment to find anything useful on the subject.</p>

CC BY-SA 4.0
2021-12-16T10:53:58.600Z
2021-12-16T10:53:58.600Z
Jey
<p>I am trying to build a transaction with the libary of cardano-client-lib (java sdk).
Inorder to build a transaction one needs to provide an account object which can only be created with the mnemonic phase, which is clearly a problem.</p>
<p>I thought of using Nami wallet API as a walkaround, but seems unable to get the specific instance of the wallet in java.  is there a way to build a transaction in java with nami api?</p>
<p>thanks.</p>

<wallet><smart-contract><transaction><nami-wallet><java>
Building a transaction using Nami api wallet and cardano-client-lib
# Building a transaction using Nami api wallet and cardano-client-lib

(Asked by: username_0 on 2021-12-16)

I am trying to build a transaction with the libary of cardano-client-lib (java sdk).
Inorder to build a transaction one needs to provide an account object which can only be created with the mnemonic phase, which is clearly a problem.

I thought of using Nami wallet API as a walkaround, but seems unable to get the specific instance of the wallet in java. is there a way to build a transaction in java with nami api?

thanks.

**Tags:** wallet, smart-contract, transaction, nami-wallet, java

---

## 4 answers

### Answer by username_1 on 2021-12-16. Score: 1

Nami is a web wallet and injects its API into your website. It is not supposed to work with desktop applications but only with web apps. I recommend you to build your app with react + typescript + emurgo/cardano-serialization-lib-browser. That is how I built this [minting app](https://native-asset.com/)


---

### Answer by username_2 on 2022-01-02. Score: 1

Another option:

Transaction can be built in Java backend and then sent to Nami for signing.

Here's a sample code for Multi-sig token mint where

(Not exactly same but similar approach can be used for your scenario)

1. Mint Transaction is built in Java backend
2. Sign by Nami extension in the browser
3. Send the witness back to Java backend
4. Assemble transaction again with other witnesses in Java backend and submit the final transaction

[MultiSigTokenMint With Java + Nami](https://github.com/bloxbean/cardano-client-examples/blob/c3aec693977aff1e82b3c24ac5402f4ecc8748fd/src/main/java/com/bloxbean/cardano/client/examples/MultiSigMint.java#L154)


---

### Answer by username_3 on 2022-06-07. Score: 0

I have done this function, don't know if it will help you.
Two projects are required:
cardano-client-examples
https://github.com/zjavax/cardano-client-examples-zx/blob/main/src/main/java/cn/zjavax/BuildWithJavaBackend.java

public class BuildWithJavaBackend extends BaseTest {
    public static void main(String[] args) throws AddressExcepion, CborSerializationException, ApiException {
        new BuildWithJavaBackend().transfer();
        System.exit(1);
    }

    public void transfer() throws CborSerializationException, ApiException, AddressExcepion {
//        String senderMnemonic = "kit color frog trick speak employ suit sort bomb goddess jewel primary spoil fade person useless measure manage warfare reduce few scrub beyond era";
        String senderAddress = "addr_test1qqxnp3khzm7kcj9t23hskehat7428ghsenk0pfew4rqy5v9frnmht7uwrl073q4jvq20z82kh4rksyns540azhndqexqpvhgqr";
        String receiverAddress1 = "addr_test1qqwpl7h3g84mhr36wpetk904p7fchx2vst0z696lxk8ujsjyruqwmlsm344gfux3nsj6njyzj3ppvrqtt36cp9xyydzqzumz82";

        Output output1 = Output.builder()
                .address(receiverAddress1)
                .assetName(LOVELACE)
                .qty(adaToLovelace(1))
                .build();

        TxBuilder txBuilder = (output1.outputBuilder()
                .buildInputs(createFromSender(senderAddress, senderAddress))
        )
                .andThen(feeCalculator(senderAddress, 1))
                .andThen(adjustChangeOutput(senderAddress, 1));

        Transaction signedTransaction = TxBuilderContext.init(utxoSupplier, protocolParamsSupplier).build(txBuilder);

        System.out.println("txHexDraft=\"" +signedTransaction.serializeToHex()+"\"");

    }
}

cardano-walletconnector-demo

The result of calling cc wallet:

@Satya（don't know how @）


---

### Answer by username_4 on 2021-12-16. Score: 0

I don't think you can get the wallet instance from Nami as the whole point of a wallet is to hide the private key and pass transactions visually to the user so that she can approve and submit them.

I would rather try the other way and look if your java library has methods to generate an unbalanced transaction that can be passed to the Nami wallet. Such a method would only need the wallet's UTxOs and the address of the recipient.

But I also have no clue on which libraries do this. It is very difficult at the moment to find anything useful on the subject.


---

