Install the TypeScript SDK, detect Noir Wallet, request account access, read balances, and send ZEC.
The SDK is a typed wrapper around the Noir Wallet provider injected into web pages. This guide reflects the current package exports and request types.
pnpm add @noir-wallet/sdkCall getNoirWallet() in the browser. wallet.zcash.connect() opens the wallet authorization flow, so invoke it from a deliberate button click.
import { getNoirWallet } from '@noir-wallet/sdk'
export async function connectNoirWallet() {
const wallet = getNoirWallet()
if (!wallet) {
throw new Error('Install Noir Wallet to continue')
}
const connection = await wallet.zcash.connect()
return {
wallet,
primaryShieldedAddress: connection.shielded,
authorizedAccounts: connection.accounts
}
}
connect() returns the primary account's top-level transparent and shielded addresses. Its accounts array contains every account the user authorized for read access.
Use getAccounts() during application startup. It does not open the wallet and returns null when the origin is not connected.
import { getNoirWallet } from '@noir-wallet/sdk'
export async function getExistingConnection() {
const wallet = getNoirWallet()
if (!wallet) return null
const connection = await wallet.zcash.getAccounts()
if (!connection) return null
return {
primaryAccount: {
transparent: connection.transparent,
shielded: connection.shielded
},
accounts: connection.accounts
}
}
const balance = await wallet.zcash.getBalance()
console.log(balance.available)
console.log(balance.shielded)
console.log(balance.accounts)Use available for send limits. It accounts for transaction selection, fees, and dust constraints; total and shielded are not necessarily fully spendable.
Call wallet.zcash.sendTransaction(). The destination property is to, and amounts are decimal
ZEC strings.
import { getNoirWallet } from '@noir-wallet/sdk'
const wallet = getNoirWallet()
if (!wallet) {
throw new Error('Install Noir Wallet to continue')
}
const txid = await wallet.zcash.sendTransaction({
to: 'u1...',
amount: '0.25',
fundingSource: 'shielded'
})
console.log(txid)
fundingSource: "transparent" exposes and may link the selected transparent UTXOs. Prefer
shielded funding when the workflow supports it.
Mainnet and testnet are separate Noir Wallet installations. switchNetwork() is deprecated and always throws; direct test users to install the testnet extension instead.