The initialize method is the primary way to create or restore a Spark wallet. Leave mnemonicOrSeed blank to generate a new wallet, or provide an existing mnemonic seed phrase to import an existing wallet.
import { SparkWallet } from "@buildonspark/spark-sdk";// Create a new walletconst { wallet, mnemonic } = await SparkWallet.initialize({ options: { network: "REGTEST" // or "MAINNET" }});console.log("New wallet created!");console.log("Mnemonic:", mnemonic);console.log("Address:", await wallet.getSparkAddress());
import { SparkWallet } from "@buildonspark/spark-sdk";// Restore wallet from existing mnemonicconst { wallet } = await SparkWallet.initialize({ mnemonicOrSeed: "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", accountNumber: 0, // Optional: specify account index options: { network: "REGTEST" // or "MAINNET" }});console.log("Wallet restored from mnemonic!");console.log("Address:", await wallet.getSparkAddress());
Account index for generating multiple identity keys from the same mnemonic (default: 0 on REGTEST, 1 on MAINNET). Important: Always specify this explicitly if you use the same mnemonic across networks.
Map of Bech32m token identifiers to token balance and metadata. UserTokenMetadata includes extraMetadata?: Uint8Array for arbitrary issuer-defined bytes.
Initialization starts an active wallet: it subscribes to events, claims incoming transfers, and runs periodic maintenance such as token-output optimization. This also applies to a wallet used only to create invoices for other users. For queries alone, use SparkReadonlyClient.Automatic token-output optimization is enabled by default. To disable that task, pass tokenOptimizationOptions: { enabled: false } inside the initialization options. The wallet still subscribes to events and claims incoming transfers; this is not a read-only mode.Call cleanup() when the wallet is no longer needed. It clears background intervals, aborts streams, removes listeners, and closes connections. Open resources can keep a Node.js script alive after its main function finishes.
try { console.log(await wallet.getSparkAddress()); // Perform this script’s wallet work here.} finally { await wallet.cleanup();}
const { wallet } = await SparkWallet.initialize({ options: { network: "MAINNET" }});// Use for production applications
const { wallet } = await SparkWallet.initialize({ options: { network: "REGTEST" }});// Use for development and testing
Always use REGTEST for development and testing. Only use MAINNET for production applications with real Bitcoin.
Account number defaults differ by network. REGTEST defaults to account 0, MAINNET defaults to account 1. If you test on REGTEST without specifying accountNumber, then deploy to MAINNET with the same mnemonic, your wallet will be empty because funds are on a different account. Always explicitly set accountNumber for consistent behavior.
// Initialize wallet with mnemonic or seedinitialize({ mnemonicOrSeed, signer, options })// Get the identity public keygetIdentityPublicKey()// Get the Spark addressgetSparkAddress()// Clean up connectionscleanup()
{"docsConfig":{"theme":"aspen","$schema":"https://mintlify.com/docs.json","name":"Spark","colors":{"primary":"#000000","light":"#FFFFFF","dark":"#151515"},"logo":{"light":"https://mintcdn.com/lightspark/uYWAuFR6Cxtb0uSg/images/logo-black.svg?fit=max\u0026auto=format\u0026n=uYWAuFR6Cxtb0uSg\u0026q=85\u0026s=25372f66a4814d6d53c52af40d4721e3","dark":"https://mintcdn.com/lightspark/uYWAuFR6Cxtb0uSg/images/logo-white.svg?fit=max\u0026auto=format\u0026n=uYWAuFR6Cxtb0uSg\u0026q=85\u0026s=7468254a8804b96e77b2bb4a33bbd8d0","href":"https://docs.spark.money"},"favicon":"https://mintcdn.com/lightspark/9Uoevi-SGmZ4_qMo/images/favicon.svg?fit=max\u0026auto=format\u0026n=9Uoevi-SGmZ4_qMo\u0026q=85\u0026s=247876e19fe2aca2e8ff4725910ccda6","api":{},"navbar":{"links":[{"href":"https://www.spark.money/report","label":"Report a bug"},{"href":"https://www.spark.money/contact","label":"Get in touch"}]},"footer":{"socials":{"x":"https://x.com/spark","github":"https://github.com/buildonspark"},"links":[{"header":"Legal","items":[{"label":"Privacy Policy","href":"https://spark.money/privacy"},{"label":"Terms of Service","href":"https://spark.money/terms-of-use"}]}]},"search":{},"seo":{"metatags":{"canonical":"https://docs.spark.money","og:image":"/images/og/og-spark.png","og:site_name":"Spark Documentation","og:locale":"en_US","twitter:site":"@spark","twitter:card":"summary_large_image","robots":"index, follow","language":"en","author":"Spark","category":"Technology","keywords":"bitcoin layer 2, bitcoin l2, self-custody bitcoin, lightning network, bitcoin stablecoin, stablecoin on bitcoin, bitcoin payments, bitcoin wallet sdk, 0-conf deposits, zero confirmation bitcoin, bitcoin scaling, spark protocol, BTKN tokens, bitcoin native tokens"},"indexing":"all"},"integrations":{"ga4":{"measurementId":"G-DZD23R72CM"},"segment":{"key":"jj3Pmdv7apJ7K8KZP0JrLQWhGJrRSPgN"}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"lightspark","hasAudioNarration":false,"actualSubdomain":"lightspark","customDomains":["docs.spark.money"],"gitSource":{"type":"github","owner":"buildonspark","repo":"spark-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6abb064378859c2eaac739ec","collectionId":"2cde6498-3e4a-4449-b9a6-faf2d2992c26","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6abb064378859c2eaac739ec"},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6abb064378859c2eaac739ec","clientVersion":"0.0.3965","searchFilterCounts":[{"language":"default","tag":"API Reference","count":95},{"language":"default","tag":"Wallets","count":86},{"language":"default","tag":"Issuance","count":29},{"language":"default","tag":"Learn","count":21},{"language":"default","tag":"Advanced","count":20},{"language":"default","tag":"Wallet Viewer","count":15},{"language":"default","tag":"Bitcoin","count":15},{"language":"default","tag":"Tokens","count":14},{"language":"default","tag":"Core operations","count":13},{"language":"default","tag":"Introduction","count":12}]},"assistantConfig":{},"hasChatPermissions":false,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-v7-file-tree","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"pause-universal-search-reconcile","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"per-site-search-delta","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-private-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-nav-generations","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-agent-model-picker","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"isAtlas":false,"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":":root{--black:#0a0a0a;--white:#fafafa;--blue:#15b9eb;--white-pure:#fff;--green:#00c896;--green-bright:#2adf72;--red:#ff4d4d;--yellow:#f2e863;--orange:#ff8c42;--purple:#fafafa;--white-00:rgba(250, 250, 250, 0);--white-01:rgba(250, 250, 250, 0.01);--white-02:rgba(250, 250, 250, 0.02);--white-04:rgba(250, 250, 250, 0.04);--white-08:rgba(250, 250, 250, 0.08);--white-10:rgba(250, 250, 250, 0.1);--white-20:rgba(250, 250, 250, 0.2);--white-30:rgba(250, 250, 250, 0.3);--white-40:rgba(250, 250, 250, 0.4);--white-50:rgba(250, 250, 250, 0.5);--white-60:rgba(250, 250, 250, 0.6);--white-70:rgba(250, 250, 250, 0.7);--white-80:rgba(250, 250, 250, 0.8);--white-90:rgba(250, 250, 250, 0.9);--black-00:rgba(10, 10, 10, 0);--black-01:rgba(10, 10, 10, 0.01);--black-02:rgba(10, 10, 10, 0.02);--black-04:rgba(10, 10, 10, 0.04);--black-08:rgba(10, 10, 10, 0.08);--black-10:rgba(10, 10, 10, 0.1);--black-20:rgba(10, 10, 10, 0.2);--black-30:rgba(10, 10, 10, 0.3);--black-40:rgba(10, 10, 10, 0.4);--black-50:rgba(10, 10, 10, 0.5);--black-60:rgba(10, 10, 10, 0.6);--black-70:rgba(10, 10, 10, 0.7);--black-80:rgba(10, 10, 10, 0.8);--black-90:rgba(10, 10, 10, 0.9)}:not(code):not(pre):not(code *):not(pre *){font-family:\"Helvetica Neue\",Helvetica,Arial,sans-serif!important}.dark article,.dark label,.dark li,.dark p,.dark span,.dark td,.dark th{color:#e5e5e5!important}.prose li,.prose p,article li,article p{font-size:1.0625rem!important;line-height:1.7!important}h4{font-size:1em!important;font-weight:400!important}*{scrollbar-width:none!important;-ms-overflow-style:none!important;-webkit-overflow-scrolling:touch!important}::-webkit-scrollbar{display:none!important}img[src*=\"/icons/icon-activity-lime.svg\"],img[src*=\"/icons/icon-app-brale.svg\"],img[src*=\"/icons/icon-app-sparkscan.svg\"],img[src*=\"/icons/icon-cli-white.svg\"],img[src*=\"/icons/icon-grid-white.svg\"],img[src*=\"/icons/icon-hidden-white.svg\"],img[src*=\"/icons/icon-network-spark.svg\"],img[src*=\"/icons/icon-sign-white.svg\"]{filter:invert(1) brightness(0) saturate(0%)!important}a.bg-primary\\/10 img[src*=\"/icons/icon-activity-lime.svg\"],a.bg-primary\\/10 img[src*=\"/icons/icon-app-brale.svg\"],a.bg-primary\\/10 img[src*=\"/icons/icon-app-sparkscan.svg\"],a.bg-primary\\/10 img[src*=\"/icons/icon-cli-white.svg\"],a.bg-primary\\/10 img[src*=\"/icons/icon-grid-white.svg\"],a.bg-primary\\/10 img[src*=\"/icons/icon-hidden-white.svg\"],a.bg-primary\\/10 img[src*=\"/icons/icon-network-spark.svg\"],a.bg-primary\\/10 img[src*=\"/icons/icon-sign-white.svg\"]{filter:invert(1)!important;opacity:1}.dark img[src*=\"/icons/icon-activity-lime.svg\"],.dark img[src*=\"/icons/icon-app-brale.svg\"],.dark img[src*=\"/icons/icon-app-sparkscan.svg\"],.dark img[src*=\"/icons/icon-cli-white.svg\"],.dark img[src*=\"/icons/icon-grid-white.svg\"],.dark img[src*=\"/icons/icon-hidden-white.svg\"],.dark img[src*=\"/icons/icon-network-spark.svg\"],.dark img[src*=\"/icons/icon-sign-white.svg\"]{filter:invert(0) brightness(100) saturate(0%)!important}.dark a.dark\\:bg-primary-light\\/10 img[src*=\"/icons/icon-activity-lime.svg\"],.dark a.dark\\:bg-primary-light\\/10 img[src*=\"/icons/icon-app-brale.svg\"],.dark a.dark\\:bg-primary-light\\/10 img[src*=\"/icons/icon-app-sparkscan.svg\"],.dark a.dark\\:bg-primary-light\\/10 img[src*=\"/icons/icon-cli-white.svg\"],.dark a.dark\\:bg-primary-light\\/10 img[src*=\"/icons/icon-grid-white.svg\"],.dark a.dark\\:bg-primary-light\\/10 img[src*=\"/icons/icon-hidden-white.svg\"],.dark a.dark\\:bg-primary-light\\/10 img[src*=\"/icons/icon-network-spark.svg\"],.dark a.dark\\:bg-primary-light\\/10 img[src*=\"/icons/icon-sign-white.svg\"]{filter:invert(0)!important;opacity:1}#navigation-items li a,#sidebar-group li button,#sidebar-group li div{background-color:transparent!important;color:var(--black-60)!important;transition:all .2s ease!important}.dark #navigation-items li a,.dark #sidebar-group li button,.dark #sidebar-group li div{background-color:transparent!important;color:var(--white-60)!important;transition:all .2s ease!important}#navigation-items li a:hover,#sidebar-group li button:hover,#sidebar-group li div:hover{background-color:transparent!important;color:var(--black-80)!important}.dark #navigation-items li a:hover,.dark #sidebar-group li button:hover,.dark #sidebar-group li div:hover{background-color:transparent!important;color:var(--white-80)!important}#navigation-items li a.bg-primary\\/10,#sidebar-group li button[aria-expanded=true],#sidebar-group li div[aria-expanded=true]{color:var(--black)!important;font-weight:500!important}.dark #navigation-items li a.dark\\:bg-primary-light\\/10,.dark #sidebar-group li button[aria-expanded=true],.dark #sidebar-group li div[aria-expanded=true]{color:var(--white)!important;font-weight:500!important}#header .eyebrow,li[id=\"https://app.lightspark.com/regtest-faucet\"] svg,li[id=\"https://btkn.info/\"] svg,li[id=\"https://www.sparkscan.io/?network=mainnet\"] svg{display:none!important}.chill{pointer-events:none!important}.grid a[class*=rounded],.not-prose a[class*=block],.not-prose>div>a,.not-prose>div>div>a,[class*=Accordion],[class*=Card_],[class*=Card_card],[class*=CodeBlock],[class*=CodeGroup],[class*=Expandable],[class*=Tab_],[class*=Tabs],[class*=_card],[class*=accordion],[class*=border][class*=rounded],[class*=card_card],[class*=code_],[class*=codeblock],[class*=codegroup],[class*=expandable],[class*=pre_],[class*=rounded-2xl],[class*=rounded-lg],[class*=rounded-xl],[class*=tab_],[class*=tabs],[style*=border-radius],article a[class*=rounded],article div[class*=rounded],code,details,details summary,pre{border-radius:4px!important}.spark-card{background-color:var(--black-02)}.dark .spark-card{background-color:var(--white-02)}.spark-card:hover{background-color:var(--black-04)}.dark .spark-card:hover{background-color:var(--white-04)}.spark-card .icon-light{display:block}.dark .spark-card .icon-light,.spark-card .icon-dark{display:none}.dark .spark-card .icon-dark{display:block}.spark-card .card-description,.spark-card .card-title{color:var(--black);font-size:1rem!important;margin:0!important;padding:0!important}.dark .spark-card .card-title{color:var(--white)}.feature-card h3,.feature-card p,.feature-card span,.spark-card,.spark-card *{border:0!important;border-bottom:none!important}.spark-card .card-description{font-size:.875rem!important;font-weight:400!important;line-height:1.5!important;color:var(--black-50)!important}.dark .spark-card .card-description{color:var(--white-50)!important}.hcard-row,.spark-card .hcard-row{display:flex!important;flex-direction:row!important;flex-wrap:nowrap!important;align-items:center!important;gap:1rem!important}.hcard-icon,.spark-card .hcard-icon{flex-shrink:0!important;order:-1!important;width:40px!important;height:40px!important;min-width:40px!important}.hcard-icon img,.spark-card .hcard-icon img{width:100%!important;height:100%!important;margin:0!important}.hcard-text,.spark-card .hcard-text{order:1!important;gap:.5rem!important}.hcard-text,.spark-card .hcard-text,.spark-card .vcard-col{display:flex!important;flex-direction:column!important}.spark-card .vcard-image{width:100%!important;aspect-ratio:16/9!important;position:relative!important}.spark-card .vcard-image img{width:100%!important;height:100%!important;object-fit:cover!important}.spark-card .vcard-content{display:flex!important;flex-direction:column!important;gap:.5rem!important;padding:1.5rem!important}.spark-tabcard-btn,.spark-tabcard-container{background-color:var(--black-02)}.dark .spark-tabcard-btn,.dark .spark-tabcard-container{background-color:var(--white-02)}.spark-tabcard-item-active{background-color:var(--black-04)}.dark .spark-tabcard-item-active{background-color:var(--white-04)}.spark-tabcard-title{color:var(--black)}.dark .spark-tabcard-title{color:var(--white)}.spark-tabcard-desc{color:var(--black-50)}.dark .spark-tabcard-desc{color:var(--white-50)}.spark-tabcard-img-light{display:block}.dark .spark-tabcard-img-light,.spark-tabcard-img-dark{display:none}.dark .spark-tabcard-img-dark{display:block}.spark-method{background-color:var(--black-02);color:var(--black);border-color:var(--black-04)}.dark .spark-method{background-color:var(--white-02);color:var(--white);border-color:var(--white-04)}.spark-button{background-color:var(--black);color:var(--white)!important;border-radius:6px!important}.dark .spark-button,.dark .spark-button *{background-color:var(--white);color:#000!important}.spark-button:hover{background-color:var(--black-50)}.dark .spark-button:hover{background-color:var(--white-50)}.spark-button-outline{background-color:transparent;border:1px solid #e5e7eb;color:#374151!important;border-radius:6px!important}.dark .spark-button-outline{border-color:rgba(255,255,255,.07);color:#d1d5db!important}.spark-button-outline:hover{background-color:var(--black-02)}.dark .spark-button-outline:hover{background-color:var(--white-02)}.spark-videotile-active{background-color:#f3f4f6}.dark .spark-videotile-active{background-color:rgba(255,255,255,.05)}.spark-videotile-title{color:#000}.dark .spark-videotile-title{color:#fff}.spark-videotile-desc{color:#4b5563}.dark .spark-videotile-desc{color:#9ca3af}.dark .spark-videotile-link,.spark-videotile-link{color:#2563eb}.spark-videotile-link:hover{color:#1d4ed8}.dark .spark-videotile-link:hover{color:#3b82f6}.spark-videotile-container{background-color:#f5f8ff;border-color:#d3e1ff}.dark .spark-videotile-container{background-color:#001033;border-color:#011d5b}.spark-videotile-empty{color:#9ca3af}.dark .spark-videotile-empty{color:#6b7280}.feature-card{border:1px solid var(--black-10)!important;border-radius:6px!important;padding:0!important;overflow:hidden;transition:border-color .2s ease}.dark .feature-card{border-color:var(--white-10)!important}.feature-card:hover{border-color:var(--black-20)!important}.dark .feature-card:hover{border-color:var(--white-20)!important}.feature-card [class*=Zoom],.feature-card [class*=zoom],.feature-card button,a[href*=\"mintlify.com\"][href*=\"utm_campaign=poweredBy\"],a[href*=\"mintlify.com\"][href*=poweredBy]{display:none!important}.feature-card-inner{display:flex!important;flex-direction:column!important;text-decoration:none!important}.feature-card-header{display:flex!important;flex-direction:row!important;align-items:center!important;gap:10px!important;padding:16px 20px!important;border-bottom:1px solid var(--black-08)!important}.dark .feature-card-header{border-bottom-color:var(--white-08)!important}.feature-card-icon{flex-shrink:0;width:20px;height:20px;display:flex;align-items:center;justify-content:center}.feature-card-icon img{width:20px;height:20px;margin:0!important;pointer-events:none}.feature-card .icon-light{display:block}.dark .feature-card .icon-light,.feature-card .icon-dark{display:none}.dark .feature-card .icon-dark{display:block}.feature-card-description,.feature-card-title{font-size:15px!important;font-weight:500!important;line-height:1.3!important;margin:0!important;padding:0!important;color:var(--black)}.dark .feature-card-title{color:var(--white)}.feature-card-description{font-weight:400!important;line-height:1.6!important;padding:16px 20px!important;color:var(--black-50)}.dark .feature-card-description{color:var(--white-50)}.status-badge{display:inline-flex;align-items:center;gap:6px;padding:4px 10px 4px 8px;border-radius:6px;font-size:13px;font-weight:500}.status-badge-live{background-color:rgba(0,200,150,.1);color:#00a67d}.dark .status-badge-live{background-color:rgba(0,200,150,.15);color:#00c896}.status-badge-dev{background-color:rgba(255,140,66,.1);color:#d97316}.dark .status-badge-dev{background-color:rgba(255,140,66,.15);color:#ff8c42}.status-dot{width:8px;height:8px;border-radius:50%}.status-dot-live{background-color:#00c896}.status-dot-dev{background-color:#ff8c42}.chat-assistant-floating-input>div>div,div:has(>div>#chat-assistant-textarea){background-color:var(--white-20)!important;border:1px solid var(--black-10)!important;border-radius:12px!important}.dark .chat-assistant-floating-input>div>div,.dark div:has(>div>#chat-assistant-textarea){background-color:var(--black-10)!important;border:1px solid var(--white-10)!important}.chat-assistant-floating-input>div{transition:transform .2s ease!important}[id^=headlessui-dialog-panel-][class*=rounded]{backdrop-filter:blur(48px)!important;background-color:var(--white-80)!important;border:1px solid var(--black-10)!important;border-radius:12px!important}.dark [id^=headlessui-dialog-panel-][class*=rounded]{background-color:var(--black-20)!important;border:1px solid var(--white-10)!important;border-radius:12px!important}#search-input,#search-input:focus{outline:0!important;outline-width:0!important;outline-color:transparent!important;border:0!important;background-color:var(--black-04)!important}.dark #search-input,.dark #search-input:focus{background-color:var(--white-04)!important}"}],"page":{"pagePath":"wallets/create-wallet","slug":"/wallets/create-wallet","pageMetadata":{"title":"Create a Wallet","description":null,"sidebarTitle":"Create a Wallet","keywords":["create bitcoin wallet","wallet initialization","self-custody wallet","bitcoin mnemonic","wallet setup","bitcoin key management"],"icon":"/icons/icon-wallet-purple.svg","og:image":"/images/og/og-wallet-sdk.png","seo":{"title":"Create a Spark Wallet | Mnemonic \u0026 Multi-Account Support","description":"Initialize wallets with BIP-39 mnemonics or raw seeds. Support for multiple accounts via derivation path."},"href":"/wallets/create-wallet"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];const Method=({children,className=``})=>{return _jsx(`code`,{className:`spark-method not-prose mint-inline-block mint-px-2 mint-py-1 mint-mt-12 mint-text-sm mint-font-mono mint-font-semibold mint-rounded-md mint-border ${className}`,children})};function _createMdxContent(props){const _components={a:`a`,code:`code`,hr:`hr`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Expandable,Frame,Heading,Info,OptimizedImage,ResponseField,Warning,_MdxComponentBoundary}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Frame)_missingMdxReference(`Frame`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Info)_missingMdxReference(`Info`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!ResponseField)_missingMdxReference(`ResponseField`,true);if(!Warning)_missingMdxReference(`Warning`,true);if(!_MdxComponentBoundary)_missingMdxReference(`_MdxComponentBoundary`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Create and initialize Spark wallets with full key control.`}),`\n`,_jsxs(Frame,{className:`chill`,children:[_jsx(OptimizedImage,{className:`mint-block dark:mint-hidden`,src:`https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet-light.png?fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=faf6742206877d45941f090f65be07bb`,alt:`Create a Wallet`,\"data-og-width\":`3840`,width:`3840`,\"data-og-height\":`2160`,height:`2160`,\"data-path\":`images/wallets/create-wallet-light.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet-light.png?w=280\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=d4ab66c40f48762cddb5c71990434f10 280w, https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet-light.png?w=560\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=da301a74690e4131186b7d5f69ca305a 560w, https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet-light.png?w=840\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=b8fba900479e9e068714814018788491 840w, https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet-light.png?w=1100\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=0091db4c2e59c1ef144aebfd87a11e6b 1100w, https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet-light.png?w=1650\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=1cde4802d4a844e768af78d0f6278daa 1650w, https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet-light.png?w=2500\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=637f53d5af10d558ae45b49ac5df9a75 2500w`}),_jsx(OptimizedImage,{className:`mint-hidden dark:mint-block`,src:`https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet.png?fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=08a6acffb83763e58f6f4bab4b7f9ab2`,alt:`Create a Wallet`,\"data-og-width\":`3840`,width:`3840`,\"data-og-height\":`2160`,height:`2160`,\"data-path\":`images/wallets/create-wallet.png`,\"data-optimize\":`true`,\"data-opv\":`3`,srcset:`https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet.png?w=280\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=12f9a4dac23d1f45bc26df85848e10dc 280w, https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet.png?w=560\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=a7dae1aa61808ba14fbe1457d2cdf962 560w, https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet.png?w=840\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=739d731233945c31e340220c941c83f6 840w, https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet.png?w=1100\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=a5f781774d9c0cf59c8159a9675c43e7 1100w, https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet.png?w=1650\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=d7ee5c9264cdab1cf175ce70652988f4 1650w, https://mintcdn.com/lightspark/RCkJgy8FQAJRUhsh/images/wallets/create-wallet.png?w=2500\u0026fit=max\u0026auto=format\u0026n=RCkJgy8FQAJRUhsh\u0026q=85\u0026s=4631f56399cd5949f6957aa0ed124b5d 2500w`})]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`initialize-wallet`,children:`Initialize Wallet`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`initialize`}),` method is the primary way to create or restore a Spark wallet. Leave `,_jsx(_components.code,{children:`mnemonicOrSeed`}),` blank to generate a new wallet, or provide an existing mnemonic seed phrase to import an existing wallet.`]}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Create Wallet`,numberOfLines:`12`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`SparkWallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@buildonspark/spark-sdk\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Create a new wallet`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`mnemonic`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` SparkWallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`initialize`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` options:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` network:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"REGTEST\"`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // or \"MAINNET\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"New wallet created!\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Mnemonic:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`mnemonic`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Address:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getSparkAddress`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`());`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Import Wallet`,numberOfLines:`13`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`SparkWallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@buildonspark/spark-sdk\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Restore wallet from existing mnemonic`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` SparkWallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`initialize`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` mnemonicOrSeed:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` accountNumber:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Optional: specify account index`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` options:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` network:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"REGTEST\"`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // or \"MAINNET\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Wallet restored from mnemonic!\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Address:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getSparkAddress`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`());`})]}),`\n`]})})})]}),`\n`,_jsxs(Expandable,{title:`Parameters`,children:[_jsx(ResponseField,{name:`mnemonicOrSeed`,type:`Uint8Array | string`,required:false,id:`param-mnemonic-or-seed`,children:_jsx(_components.p,{children:`BIP-39 mnemonic phrase or raw seed. Leave blank to generate a new wallet.`})}),_jsx(ResponseField,{name:`accountNumber`,type:`number`,required:false,id:`param-account-number`,children:_jsxs(_components.p,{children:[`Account index for generating multiple identity keys from the same mnemonic (default: 0 on REGTEST, 1 on MAINNET). `,_jsx(_components.strong,{children:`Important:`}),` Always specify this explicitly if you use the same mnemonic across networks.`]})}),_jsx(ResponseField,{name:`signer`,type:`SparkSigner`,required:false,id:`param-signer`,children:_jsx(_components.p,{children:`Custom signer implementation for advanced use cases`})}),_jsx(ResponseField,{name:`options`,type:`ConfigOptions`,required:false,id:`param-options`,children:_jsx(_components.p,{children:`Wallet configuration options including network selection`})})]}),`\n`,_jsxs(Expandable,{title:`Returns`,children:[_jsx(ResponseField,{name:`wallet`,type:`SparkWallet`,required:true,id:`param-wallet`,children:_jsx(_components.p,{children:`The initialized SparkWallet instance`})}),_jsx(ResponseField,{name:`mnemonic`,type:`string`,required:false,id:`param-mnemonic`,children:_jsx(_components.p,{children:`The 12-word mnemonic seed phrase for wallet recovery (undefined for raw seed)`})})]}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`essential-wallet-operations`,children:`Essential Wallet Operations`}),`\n`,_jsx(_components.p,{children:`After creating your wallet, you can perform these essential operations`}),`\n`,_jsx(_MdxComponentBoundary,{name:`Method`,children:_jsx(Method,{children:`getIdentityPublicKey()`})}),`\n`,_jsx(_components.p,{children:`Gets the identity public key of the wallet`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` identityKey`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getIdentityPublicKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Identity Public Key:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`identityKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(Expandable,{title:`Returns`,children:_jsx(ResponseField,{name:`identityKey`,type:`string`,required:true,id:`param-identity-key`,children:_jsx(_components.p,{children:`The identity public key as a hex string`})})}),`\n`,_jsx(_MdxComponentBoundary,{name:`Method`,children:_jsx(Method,{children:`getSparkAddress()`})}),`\n`,_jsx(_components.p,{children:`Gets the Spark address of the wallet`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` sparkAddress`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getSparkAddress`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Spark Address:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`sparkAddress`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(Expandable,{title:`Returns`,children:_jsx(ResponseField,{name:`sparkAddress`,type:`SparkAddressFormat`,required:true,id:`param-spark-address`,children:_jsx(_components.p,{children:`The Spark address for receiving Bitcoin and tokens`})})}),`\n`,_jsx(_MdxComponentBoundary,{name:`Method`,children:_jsx(Method,{children:`getBalance()`})}),`\n`,_jsx(_components.p,{children:`Gets the current balance of the wallet, including Bitcoin and token balances.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` balance`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getBalance`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Balance:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`balance`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`satsBalance`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`available`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"sats\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Token Balances:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`balance`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`tokenBalances`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(Expandable,{title:`Returns`,children:[_jsx(ResponseField,{name:`satsBalance`,type:`object`,required:true,id:`param-sats-balance`,children:_jsxs(_components.p,{children:[`Bitcoin balances in satoshis: `,_jsx(_components.code,{children:`available`}),`, `,_jsx(_components.code,{children:`owned`}),`, and `,_jsx(_components.code,{children:`incoming`}),`. Use `,_jsx(_components.code,{children:`available`}),` for spendable funds.`]})}),_jsx(ResponseField,{name:`tokenBalances`,type:`Map\u003cstring, { ownedBalance: bigint, availableToSendBalance: bigint, tokenMetadata: UserTokenMetadata }>`,required:true,id:`param-token-balances`,children:_jsxs(_components.p,{children:[`Map of Bech32m token identifiers to token balance and metadata. `,_jsx(_components.code,{children:`UserTokenMetadata`}),` includes `,_jsx(_components.code,{children:`extraMetadata?: Uint8Array`}),` for arbitrary issuer-defined bytes.`]})})]}),`\n`,_jsx(_MdxComponentBoundary,{name:`Method`,children:_jsx(Method,{children:`cleanup()`})}),`\n`,_jsxs(_components.p,{children:[`Initialization starts an active wallet: it subscribes to events, claims incoming transfers, and runs periodic maintenance such as token-output optimization. This also applies to a wallet used only to create invoices for other users. For queries alone, use `,_jsx(_components.a,{href:`/wallets/readonly-client`,children:_jsx(_components.code,{children:`SparkReadonlyClient`})}),`.`]}),`\n`,_jsxs(_components.p,{children:[`Automatic token-output optimization is enabled by default. To disable that task, pass `,_jsx(_components.code,{children:`tokenOptimizationOptions: { enabled: false }`}),` inside the initialization `,_jsx(_components.code,{children:`options`}),`. The wallet still subscribes to events and claims incoming transfers; this is not a read-only mode.`]}),`\n`,_jsxs(_components.p,{children:[`Call `,_jsx(_components.code,{children:`cleanup()`}),` when the wallet is no longer needed. It clears background intervals, aborts streams, removes listeners, and closes connections. Open resources can keep a Node.js script alive after its main function finishes.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`try`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getSparkAddress`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`());`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // Perform this script’s wallet work here.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`} `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`finally`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`cleanup`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Expandable,{title:`Returns`,children:_jsx(ResponseField,{name:`void`,type:`Promise\u003cvoid>`,required:true,id:`param-void`,children:_jsx(_components.p,{children:`No return value - cleans up connections and aborts active streams`})})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`network-configuration`,children:`Network Configuration`}),`\n`,_jsx(_components.p,{children:`Spark supports both mainnet and regtest networks:`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`Mainnet`,numberOfLines:`6`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` SparkWallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`initialize`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` options:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` network:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"MAINNET\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Use for production applications`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`Regtest`,numberOfLines:`6`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`6`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` SparkWallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`initialize`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` options:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` network:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"REGTEST\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Use for development and testing`})}),`\n`]})})})]}),`\n`,_jsx(Info,{children:_jsx(_components.p,{children:`Always use REGTEST for development and testing. Only use MAINNET for production applications with real Bitcoin.`})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Account number defaults differ by network.`}),` REGTEST defaults to account 0, MAINNET defaults to account 1. If you test on REGTEST without specifying `,_jsx(_components.code,{children:`accountNumber`}),`, then deploy to MAINNET with the same mnemonic, your wallet will be empty because funds are on a different account. Always explicitly set `,_jsx(_components.code,{children:`accountNumber`}),` for consistent behavior.`]})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`account-derivation`,children:`Account Derivation`}),`\n`,_jsx(_components.p,{children:`You can create multiple accounts from the same mnemonic by specifying different account numbers:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`15`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`15`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Account 0 (default)`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` wallet0`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` SparkWallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`initialize`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` mnemonicOrSeed:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"your mnemonic here\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` accountNumber:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Account 1`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` wallet1`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` SparkWallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`initialize`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` mnemonicOrSeed:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"your mnemonic here\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` accountNumber:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Each account will have different addresses`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Account 0:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getSparkAddress`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`());`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Account 1:\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getSparkAddress`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`());`})]}),`\n`]})})}),`\n`,_jsx(_components.hr,{}),`\n`,_jsx(Heading,{level:`2`,id:`api-reference`,children:`API Reference`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`SparkWallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`initialize`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` mnemonicOrSeed?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` Uint8Array`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Optional: existing mnemonic or seed`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` accountNumber?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` number`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Optional: account index (default: 0)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` signer?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` SparkSigner`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Optional: custom signer implementation`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` options?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` network?`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"MAINNET\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"TESTNET\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"SIGNET\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"REGTEST\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` |`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"LOCAL\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`})`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Returns: { wallet: SparkWallet, mnemonic: string | undefined }`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Wallet Methods:`})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`11`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Initialize wallet with mnemonic or seed`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`initialize`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`mnemonicOrSeed`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`signer`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`options`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` })`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Get the identity public key`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getIdentityPublicKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Get the Spark address`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getSparkAddress`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Clean up connections`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`cleanup`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{Method,default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Create a Wallet","description":null,"sidebarTitle":"Create a Wallet","keywords":["create bitcoin wallet","wallet initialization","self-custody wallet","bitcoin mnemonic","wallet setup","bitcoin key management"],"icon":"/icons/icon-wallet-purple.svg","og:image":"/images/og/og-wallet-sdk.png","seo":{"title":"Create a Spark Wallet | Mnemonic \u0026 Multi-Account Support","description":"Initialize wallets with BIP-39 mnemonics or raw seeds. Support for multiple accounts via derivation path."},"href":"/wallets/create-wallet"}}},"mdxSourceWithNoJs":null,"noJsSplices":[[142,385,")=>null;function _cr"]]},"mdxExtracts":{"tableOfContents":[{"title":"Initialize Wallet","slug":"initialize-wallet","depth":2,"children":[]},{"title":"Essential Wallet Operations","slug":"essential-wallet-operations","depth":2,"children":[]},{"title":"Network Configuration","slug":"network-configuration","depth":2,"children":[]},{"title":"Account Derivation","slug":"account-derivation","depth":2,"children":[]},{"title":"API Reference","slug":"api-reference","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"dynamicCss":".mint-mt-12 {\n margin-top: 3rem\n}\n.mint-block {\n display: block\n}\n.mint-inline-block {\n display: inline-block\n}\n.mint-hidden {\n display: none\n}\n.mint-rounded-md {\n border-radius: 0.375rem\n}\n.mint-border {\n border-width: 1px\n}\n.mint-px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem\n}\n.mint-py-1 {\n padding-top: 0.25rem;\n padding-bottom: 0.25rem\n}\n.mint-font-mono {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace\n}\n.mint-text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem\n}\n.mint-font-semibold {\n font-weight: 600\n}\n.dark\\:mint-block:is(.dark *) {\n display: block\n}\n.dark\\:mint-hidden:is(.dark *) {\n display: none\n}","subdomain":"lightspark","siteName":"Spark","title":"Create a Wallet - Spark","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-29T00:29:06.293Z","originalFileLocation":"wallets/create-wallet.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"keywords\" content=\"bitcoin layer 2, bitcoin l2, self-custody bitcoin, lightning network, bitcoin stablecoin, stablecoin on bitcoin, bitcoin payments, bitcoin wallet sdk, 0-conf deposits, zero confirmation bitcoin, bitcoin scaling, spark protocol, BTKN tokens, bitcoin native tokens\">\u003cmeta data-mint-head name=\"application-name\" content=\"Spark\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003cmeta data-mint-head name=\"robots\" content=\"index, follow\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/lightspark/KbHTQsAQFJB5ca_h/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/lightspark/KbHTQsAQFJB5ca_h/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/lightspark/KbHTQsAQFJB5ca_h/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/lightspark/KbHTQsAQFJB5ca_h/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/lightspark/KbHTQsAQFJB5ca_h/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/lightspark/KbHTQsAQFJB5ca_h/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/lightspark/KbHTQsAQFJB5ca_h/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/lightspark/KbHTQsAQFJB5ca_h/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/lightspark/KbHTQsAQFJB5ca_h/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Create a Wallet - Spark\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Spark Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.spark.money/wallets/create-wallet\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://lightspark.mintlify.app/images/og/og-wallet-sdk.png\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Create a Wallet - Spark\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://lightspark.mintlify.app/images/og/og-wallet-sdk.png\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/lightspark/KbHTQsAQFJB5ca_h/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Spark\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#000000\">\u003cmeta data-mint-head name=\"og:locale\" content=\"en_US\">\u003cmeta data-mint-head name=\"language\" content=\"en\">\u003cmeta data-mint-head name=\"author\" content=\"Spark\">\u003cmeta data-mint-head name=\"category\" content=\"Technology\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.spark.money/wallets/create-wallet\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/wallets/create-wallet.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.spark.money/#organization\",\"name\":\"Spark\",\"url\":\"https://docs.spark.money\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/lightspark/uYWAuFR6Cxtb0uSg/images/logo-black.svg?fit=max\u0026auto=format\u0026n=uYWAuFR6Cxtb0uSg\u0026q=85\u0026s=25372f66a4814d6d53c52af40d4721e3\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.spark.money#website\",\"name\":\"Spark\",\"url\":\"https://docs.spark.money\",\"publisher\":{\"@id\":\"https://docs.spark.money/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.spark.money/wallets/create-wallet#webpage\",\"url\":\"https://docs.spark.money/wallets/create-wallet\",\"name\":\"Create a Wallet\",\"dateModified\":\"2026-09-29T00:29:06.293Z\",\"isPartOf\":{\"@id\":\"https://docs.spark.money#website\"},\"breadcrumb\":{\"@id\":\"https://docs.spark.money/wallets/create-wallet#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.spark.money/wallets/create-wallet#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Wallet\",\"item\":\"https://docs.spark.money/wallets/addressing\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create a Wallet\",\"item\":\"https://docs.spark.money/wallets/create-wallet\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.spark.money/wallets/create-wallet#article\",\"headline\":\"Create a Wallet\",\"name\":\"Create a Wallet\",\"url\":\"https://docs.spark.money/wallets/create-wallet\",\"mainEntityOfPage\":{\"@id\":\"https://docs.spark.money/wallets/create-wallet#webpage\"},\"image\":\"https://docs.spark.money/images/og/og-wallet-sdk.png\",\"dateModified\":\"2026-09-29T00:29:06.293Z\",\"keywords\":\"create bitcoin wallet, wallet initialization, self-custody wallet, bitcoin mnemonic, wallet setup, bitcoin key management\",\"publisher\":{\"@id\":\"https://docs.spark.money/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.spark.money#website\"}}]}\u003c/script>","siteName":"Spark","nav":{"global":null,"tabs":[{"tab":"Get Started","pages":[{"title":"Get Started","href":"/start/overview"}]},{"tab":"Wallets","groups":[{"group":"Introduction","pages":[{"title":"Overview","sidebarTitle":"Overview","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-grid-white.svg","mode":"wide","href":"/wallets/overview"}]},{"group":"Installation","pages":[{"title":"React Native SDK","sidebarTitle":"React Native","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-reactnative.svg","href":"/wallets/react-native"},{"title":"TypeScript SDK","sidebarTitle":"TypeScript","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-typescript.svg","href":"/wallets/typescript"},{"title":"API Reference","sidebarTitle":"API Reference","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-api-red.svg","href":"/wallets/api-reference"}]},{"group":"Wallet","pages":[{"title":"Addressing","description":null,"sidebarTitle":"Addressing","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-at-blue.svg","href":"/wallets/addressing"},{"title":"Create a Wallet","sidebarTitle":"Create a Wallet","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-wallet-purple.svg","href":"/wallets/create-wallet"},{"title":"Balances \u0026 Activity","description":null,"sidebarTitle":"Balances \u0026 Activity","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-activity-lime.svg","href":"/wallets/balances"},{"title":"Privacy Mode","sidebarTitle":"Privacy Mode","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-hidden-white.svg","href":"/wallets/privacy"},{"title":"Webhooks","sidebarTitle":"Webhooks","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-activity-lime.svg","href":"/wallets/webhooks"},{"title":"Wallet Viewer","sidebarTitle":"Wallet Viewer","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-data-blue.svg","href":"/wallets/readonly-client"}]},{"group":"Transfers","pages":[{"title":"Transfer Tokens","sidebarTitle":"Transfer Tokens","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-btkn.svg","href":"/wallets/transfer-tokens"},{"title":"Transfer Bitcoin","sidebarTitle":"Transfer Bitcoin","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-btc.svg","href":"/wallets/transfer-bitcoin"},{"title":"Spark Invoices","sidebarTitle":"Spark Invoices","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-document-purple.svg","href":"/wallets/spark-invoices"}]},{"group":"Deposits","pages":[{"title":"Deposit from L1","sidebarTitle":"Deposit from L1","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-deposit-orange.svg","href":"/wallets/deposit-from-l1"},{"title":"Deposit from Lightning","sidebarTitle":"Deposit from Lightning","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-deposit-purple.svg","href":"/wallets/deposit-from-lightning"}]},{"group":"Withdrawals","pages":[{"title":"Withdraw to L1","sidebarTitle":"Withdraw to L1","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-withdraw-orange.svg","href":"/wallets/withdraw-to-l1"},{"title":"Withdraw to Lightning","sidebarTitle":"Withdraw to Lightning","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-withdraw-purple.svg","href":"/wallets/withdraw-to-lightning"},{"title":"Unilateral Exit","sidebarTitle":"Unilateral Exit","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-withdraw-orange.svg","href":"/wallets/unilateral-exit"}]},{"group":"Fees","pages":[{"title":"Estimate Fees","sidebarTitle":"Estimate Fees","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-math-greenbright.svg","href":"/wallets/estimate-fees"}]},{"group":"Spark Signer Interface","pages":[{"title":"Spark Signer Interface","sidebarTitle":"Spark Signer Interface","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-sign-white.svg","href":"/wallets/spark-signer"},{"title":"Identity Key Derivation","sidebarTitle":"Identity Key Derivation","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-key-red.svg","href":"/wallets/identity-key-derivation"}]},{"group":"Tools","pages":[{"title":"Regtest Faucet","sidebarTitle":"Regtest Faucet","url":"https://app.lightspark.com/regtest-faucet","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-drop-blue.svg","href":"/tools/faucet"},{"title":"Explorer","sidebarTitle":"Explorer","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-globe-greenbright.svg","url":"https://www.sparkscan.io/?network=mainnet","href":"/tools/explorer"},{"title":"Spark CLI","sidebarTitle":"Spark CLI","icon":"https://mintlify.s3.us-west-1.amazonaws.com/lightspark/icons/icon-cli-white.svg","mode":"wide","href":"/wallets/tools/cli"}]}]},{"tab":"Issuance","pages":[{"title":"Issuance","href":"/issuance/overview"}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/overview"}]},{"tab":"Learn","pages":[{"title":"Learn","href":"/learn/tldr"}]}]},"title":"Create a Wallet - Spark","buildId":"dpl_849ArpqvBiCczQiT1Y1stNGpbqHT","deploymentId":"dpl_849ArpqvBiCczQiT1Y1stNGpbqHT","dynamics":["07c022d89b","a74be98ba7"],"chunks":["Frame-Cz91mEGH.js","DynamicMarkdown-a8hUKrw6.js","zoom-image-lightbox-CaUwvYH3.js","lightbox-handle-r17bVUz3.js"]}