<p>Here is an open-source starter project:
<a href="https://github.com/cheffNFT/namiwallettemplate" rel="nofollow noreferrer">https://github.com/cheffNFT/namiwallettemplate</a></p>

CC BY-SA 4.0
2021-12-24T03:41:41.280Z
2021-12-24T03:41:41.280Z
base2c
<p>There is a demo in the Plutus GitHub repository since a few days: <a href="https://github.com/input-output-hk/plutus-apps/tree/main/plutus-pab/demo/pab-nami" rel="nofollow noreferrer">https://github.com/input-output-hk/plutus-apps/tree/main/plutus-pab/demo/pab-nami</a></p>
<p>Basically, you have the following parts;</p>
<ul>
<li>The PAB instance,</li>
<li>the webserver backend,</li>
<li>the webserver frontend.</li>
</ul>
<p>I think, you should not expose the PAB through a public entry point. Instead have it running on local host. The PAB exposes post-, get-, and put-request that your webserver backend can use.</p>
<p>Your webserver backend should have a basic utility method to query the PAB consisting of 4 steps (all http request to the PAB using its standard http-endpoints):</p>
<ol>
<li>Activate a contract instance (this returns an instance-id that you need in steps 2 to 4).</li>
<li>Post a request to the instance to execute your Plutus contracts.</li>
<li>Wait 2 seconds and query the status of the instance. This status contains the transaction that you need to pass to the Nami wallet later on in your JavaScript code.</li>
<li>Close the endpoint (or leave it open If you want to cache it).</li>
</ol>
<p>You can use this utility function to construct your service functions (eg. <code>buyTokens(amount, wallet_address)</code>)</p>
<p>In your frontend, you have JavaScript code that interacts with the Nami wallet. This code does the following steps:</p>
<ol>
<li>Connects to the Nami wallet extension and fetches the wallet address.</li>
<li>Passes the wallet address (and needed arguments) to the service function of the webserver backend.</li>
<li>Receives the partial transaction from the webserver backend and passes it to Nami to balance, sign, and submit it.</li>
</ol>
<p>The only current complication is that in the last step 3, the balancing of the partial transaction cannot be performed by Nami because it does not yet expose a corresponding function. This will certainly change soon. For the moment a workaround is needed. One is shown in the Plutus PAB demo.</p>

CC BY-SA 4.0
2021-12-24T12:45:30.670Z
2021-12-24T12:52:04.793Z
2021-12-24T12:52:04.793Z
Jey
<p>What is the best approach to implement Nami Wallet. Can some provide a boiler plate or any kind of documentation.?</p>

<wallet><nami-wallet>
What is the best approach to implement Nami Wallet. Can some provide a boiler plate or any kind of documentation.?
# What is the best approach to implement Nami Wallet. Can some provide a boiler plate or any kind of documentation.?

(Asked by: username_0 on 2021-11-05)

What is the best approach to implement Nami Wallet. Can some provide a boiler plate or any kind of documentation.?

**Tags:** wallet, nami-wallet

---

## 2 answers

### Answer by username_1 on 2021-12-24. Score: 2

Here is an open-source starter project:
<https://github.com/cheffNFT/namiwallettemplate>


---

### Answer by username_2 on 2021-12-24. Score: 0

There is a demo in the Plutus GitHub repository since a few days: <https://github.com/input-output-hk/plutus-apps/tree/main/plutus-pab/demo/pab-nami>

Basically, you have the following parts;

* The PAB instance,
* the webserver backend,
* the webserver frontend.

I think, you should not expose the PAB through a public entry point. Instead have it running on local host. The PAB exposes post-, get-, and put-request that your webserver backend can use.

Your webserver backend should have a basic utility method to query the PAB consisting of 4 steps (all http request to the PAB using its standard http-endpoints):

1. Activate a contract instance (this returns an instance-id that you need in steps 2 to 4).
2. Post a request to the instance to execute your Plutus contracts.
3. Wait 2 seconds and query the status of the instance. This status contains the transaction that you need to pass to the Nami wallet later on in your JavaScript code.
4. Close the endpoint (or leave it open If you want to cache it).

You can use this utility function to construct your service functions (eg. `buyTokens(amount, wallet_address)`)

In your frontend, you have JavaScript code that interacts with the Nami wallet. This code does the following steps:

1. Connects to the Nami wallet extension and fetches the wallet address.
2. Passes the wallet address (and needed arguments) to the service function of the webserver backend.
3. Receives the partial transaction from the webserver backend and passes it to Nami to balance, sign, and submit it.

The only current complication is that in the last step 3, the balancing of the partial transaction cannot be performed by Nami because it does not yet expose a corresponding function. This will certainly change soon. For the moment a workaround is needed. One is shown in the Plutus PAB demo.


---

