5

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

3 Answers 3

2

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

1

Berry-Pool's github page is the only info in the public domain.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.