Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
nami-wallet-api
Advanced tools
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.
FAQs
Library for nami wallet
The npm package nami-wallet-api receives a total of 2 weekly downloads. As such, nami-wallet-api popularity was classified as not popular.
We found that nami-wallet-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.