Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nami-wallet-api

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nami-wallet-api

Library for nami wallet

  • 1.1.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Install

npm i nami-wallet-api

Usage

Import with await

const nami_lib = await import('nami-wallet-api')
const Nami = await nami_lib.NamiWalletApi(
    window.cardano, //nami wallet object
    "<blockfrost-api-key>"
)

// The library runs with the pure js 
// https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-asmjs
// but its super slow



//React example

useEffect(() => {
  async function t(){
    const nami_lib = await import('nami-wallet-api')
    const Nami = await nami_lib.NamiWalletApi(
        window.cardano,
        "<blockfrost-api-key>"
    )
    let addr = await Nami.getAddress()
    console.log(addr)
  }
  
  t()
}, [])






// Setup the wasm lib to get 100x performance
// https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-browser

const WASM_lib = await import('@emurgo/cardano-serialization-lib-browser/ cardano_serialization_lib')
const Nami = await nami_lib.NamiWalletApi(
    window.cardano,
    "<blockfrost-api-key>",
    WASM_lib
)

The best way to import the wasm library is to make a webpack 5 project and activate wasm + top level await

Enable Nami

await Nami.enable()

Get Address

let address = await Nami.getAddress()
console.log(address)

Send

Nami.send({
        address: "addr1q9zuz87pdpavf4qv887ku2d5u3cvamz8v7mlzqdm6rw62jln442xmqc6emat80hua9a5sdf5jsavm22mkp7c2ka80c2suk45r7",
        amount: 20
    })
    
//with metadata + assets

let txHash = await Nami.send({
    address: "addr1q9zuz87pdpavf4qv887ku2d5u3cvamz8v7mlzqdm6rw62jln442xmqc6emat80hua9a5sdf5jsavm22mkp7c2ka80c2suk45r7",
    amount: 20,
    assets: [
        {
            "unit": "b863bc7369f46136ac1048adb2fa7dae3af944c3bbb2be2f216a8d4f.BerryAlba",
            "quantity": "1"
        }
    ],
    metadata: {
        "TEST": "My transaction"
    }
})

//send to multiple recipients

Nami.sendMultiple({
    recipients: [
        {
            address: "",
            amount: 2,
            assets: [
                {
                    "unit": "",
                    "quantity": "1"
                }
            ]
        },
        {
            address: "",
            amount: 3
        },
        {
            address: "",
            amount: 213
        }
    ],
})

Delegate

let txHash = await Nami.delegate({
    poolId: "pool1fvxfg0pcr4umked5cx7jgczdajp70hrz5fsutzk338u0jljlfpy"
})

Endpoints


isEnabled :  ()  =>  Promise<boolean>,
enable :  ()  =>  Promise<void>,
getAddress :  ()  =>  Promise<string>,
getAddressHex :  ()  =>  Promise<string>,
getRewardAddress :  ()  =>  Promise<string>,
getRewardAddressHex :  ()  =>  Promise<string>,
getNetworkId :  ()  =>  Promise<{
    id:  number,
    network:  string
}>,
getUtxos:  ()  =>  Promise<Utxo[]>,
getAssets:  ()  =>  Promise<Asset[]>,
getUtxosHex:  ()  =>  Promise<string[]>,

send:  (data)  =>  Promise<string>,
sendMultiple: (data) => Promise<string>,
delegate:  (data)  =>  Promise<string>

Wasm library highly recommended for send(), delegate() functions. Takes 1-2 minutes without the wasm library just to build the transaction.

Keywords

FAQs

Package last updated on 22 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc