[{"data":1,"prerenderedAt":827},["ShallowReactive",2],{"navigation_docs":3,"-guide-wallets":72,"-guide-wallets-surround":822},[4,32],{"title":5,"path":6,"stem":7,"children":8,"icon":31},"Guide","\u002Fguide","1.guide\u002F1.index",[9,11,15,19,23,27],{"title":10,"path":6,"stem":7},"Getting Started",{"title":12,"path":13,"stem":14},"Working with Keys","\u002Fguide\u002Fkeys","1.guide\u002F2.keys",{"title":16,"path":17,"stem":18},"Working with Addresses","\u002Fguide\u002Faddresses","1.guide\u002F3.addresses",{"title":20,"path":21,"stem":22},"Generating Wallets","\u002Fguide\u002Fwallets","1.guide\u002F4.wallets",{"title":24,"path":25,"stem":26},"Working with EVM Chains","\u002Fguide\u002Fevm","1.guide\u002F5.evm",{"title":28,"path":29,"stem":30},"Creating Custom Blockchains","\u002Fguide\u002Fcustom","1.guide\u002F6.custom","i-lucide-book-open",{"title":33,"path":34,"stem":35,"children":36,"icon":71},"Blockchains","\u002Fblockchains","2.blockchains\u002F0.index",[37,39,43,47,51,55,59,63,67],{"title":38,"path":34,"stem":35},"Overview",{"title":40,"path":41,"stem":42},"Aptos","\u002Fblockchains\u002Faptos","2.blockchains\u002Faptos",{"title":44,"path":45,"stem":46},"Base","\u002Fblockchains\u002Fbase","2.blockchains\u002Fbase",{"title":48,"path":49,"stem":50},"Bitcoin","\u002Fblockchains\u002Fbitcoin","2.blockchains\u002Fbitcoin",{"title":52,"path":53,"stem":54},"Cardano","\u002Fblockchains\u002Fcardano","2.blockchains\u002Fcardano",{"title":56,"path":57,"stem":58},"Ethereum","\u002Fblockchains\u002Fethereum","2.blockchains\u002Fethereum",{"title":60,"path":61,"stem":62},"Solana","\u002Fblockchains\u002Fsolana","2.blockchains\u002Fsolana",{"title":64,"path":65,"stem":66},"Sui","\u002Fblockchains\u002Fsui","2.blockchains\u002Fsui",{"title":68,"path":69,"stem":70},"TRON","\u002Fblockchains\u002Ftron","2.blockchains\u002Ftron","i-lucide-boxes",{"id":73,"title":20,"body":74,"description":815,"extension":816,"links":817,"meta":818,"navigation":209,"path":21,"seo":820,"stem":22,"__hash__":821},"docs\u002F1.guide\u002F4.wallets.md",{"type":75,"value":76,"toc":807},"minimark",[77,82,86,144,148,311,321,400,403,407,484,490,494,500,612,615,650,653,657,660,664,670,796,803],[78,79,81],"h2",{"id":80},"what-a-wallet-is-here","What a wallet is here",[83,84,85],"p",{},"Keys plus the address they map to. Nothing else, no storage, no balance, no transactions.",[87,88,93],"pre",{"className":89,"code":90,"language":91,"meta":92,"style":92},"language-typescript shiki shiki-themes github-light github-light poimandres","interface Wallet extends Keys {\n  address: string;\n}\n","typescript","",[94,95,96,121,138],"code",{"__ignoreMap":92},[97,98,101,105,109,113,117],"span",{"class":99,"line":100},"line",1,[97,102,104],{"class":103},"s1TYA","interface",[97,106,108],{"class":107},"sCrqT"," Wallet",[97,110,112],{"class":111},"sP0CR"," extends",[97,114,116],{"class":115},"scZRh"," Keys",[97,118,120],{"class":119},"sKlNE"," {\n",[97,122,124,128,131,135],{"class":99,"line":123},2,[97,125,127],{"class":126},"s0VbO","  address",[97,129,130],{"class":103},":",[97,132,134],{"class":133},"s8yaW"," string",[97,136,137],{"class":119},";\n",[97,139,141],{"class":99,"line":140},3,[97,142,143],{"class":119},"}\n",[78,145,147],{"id":146},"new-wallet","New wallet",[87,149,153],{"className":150,"code":151,"language":152,"meta":92,"style":92},"language-js shiki shiki-themes github-light github-light poimandres","import { useBlockchain } from \"@agntn\u002Fkeys\";\nimport Bitcoin from \"@agntn\u002Fkeys\u002Fblockchains\u002Fbitcoin\";\n\nconst chain = useBlockchain(new Bitcoin());\nconst wallet = chain.generateWallet();\n\nwallet.keys.private;\nwallet.keys.public;\nwallet.address;\n","js",[94,154,155,187,205,211,238,260,265,283,299],{"__ignoreMap":92},[97,156,157,160,163,167,170,174,178,182,185],{"class":99,"line":100},[97,158,159],{"class":111},"import",[97,161,162],{"class":119}," {",[97,164,166],{"class":165},"snHMy"," useBlockchain",[97,168,169],{"class":119}," }",[97,171,173],{"class":172},"stCPd"," from",[97,175,177],{"class":176},"scVjq"," \"",[97,179,181],{"class":180},"sQ7BG","@agntn\u002Fkeys",[97,183,184],{"class":176},"\"",[97,186,137],{"class":119},[97,188,189,191,194,196,198,201,203],{"class":99,"line":123},[97,190,159],{"class":111},[97,192,193],{"class":165}," Bitcoin",[97,195,173],{"class":172},[97,197,177],{"class":176},[97,199,200],{"class":180},"@agntn\u002Fkeys\u002Fblockchains\u002Fbitcoin",[97,202,184],{"class":176},[97,204,137],{"class":119},[97,206,207],{"class":99,"line":140},[97,208,210],{"emptyLinePlaceholder":209},true,"\n",[97,212,214,217,221,224,227,230,233,235],{"class":99,"line":213},4,[97,215,216],{"class":103},"const",[97,218,220],{"class":219},"saoiD"," chain",[97,222,223],{"class":103}," =",[97,225,166],{"class":226},"sULi6",[97,228,229],{"class":119},"(",[97,231,232],{"class":111},"new",[97,234,193],{"class":226},[97,236,237],{"class":119},"());\n",[97,239,241,243,246,248,251,254,257],{"class":99,"line":240},5,[97,242,216],{"class":103},[97,244,245],{"class":219}," wallet",[97,247,223],{"class":103},[97,249,220],{"class":250},"spVlQ",[97,252,253],{"class":119},".",[97,255,256],{"class":226},"generateWallet",[97,258,259],{"class":119},"();\n",[97,261,263],{"class":99,"line":262},6,[97,264,210],{"emptyLinePlaceholder":209},[97,266,268,271,273,276,278,281],{"class":99,"line":267},7,[97,269,270],{"class":250},"wallet",[97,272,253],{"class":119},[97,274,275],{"class":250},"keys",[97,277,253],{"class":119},[97,279,280],{"class":250},"private",[97,282,137],{"class":119},[97,284,286,288,290,292,294,297],{"class":99,"line":285},8,[97,287,270],{"class":250},[97,289,253],{"class":119},[97,291,275],{"class":250},[97,293,253],{"class":119},[97,295,296],{"class":250},"public",[97,298,137],{"class":119},[97,300,302,304,306,309],{"class":99,"line":301},9,[97,303,270],{"class":250},[97,305,253],{"class":119},[97,307,308],{"class":250},"address",[97,310,137],{"class":119},[83,312,313,314,317,318,253],{},"Two optional arguments: key options first, address type second. The key options go to ",[94,315,316],{},"generateKeys",", the address type to ",[94,319,320],{},"getAddress",[87,322,324],{"className":150,"code":323,"language":152,"meta":92,"style":92},"chain.generateWallet({ compressed: false }); \u002F\u002F uncompressed public key, legacy address\nchain.generateWallet({}, \"p2sh\"); \u002F\u002F starts with 3\nchain.generateWallet({}, \"taproot\"); \u002F\u002F starts with bc1p\n",[94,325,326,354,378],{"__ignoreMap":92},[97,327,328,331,333,335,338,341,343,347,350],{"class":99,"line":100},[97,329,330],{"class":250},"chain",[97,332,253],{"class":119},[97,334,256],{"class":226},[97,336,337],{"class":119},"({",[97,339,340],{"class":165}," compressed",[97,342,130],{"class":119},[97,344,346],{"class":345},"sNe8j"," false",[97,348,349],{"class":119}," }); ",[97,351,353],{"class":352},"sjhu3","\u002F\u002F uncompressed public key, legacy address\n",[97,355,356,358,360,362,365,367,370,372,375],{"class":99,"line":123},[97,357,330],{"class":250},[97,359,253],{"class":119},[97,361,256],{"class":226},[97,363,364],{"class":119},"({}, ",[97,366,184],{"class":176},[97,368,369],{"class":180},"p2sh",[97,371,184],{"class":176},[97,373,374],{"class":119},"); ",[97,376,377],{"class":352},"\u002F\u002F starts with 3\n",[97,379,380,382,384,386,388,390,393,395,397],{"class":99,"line":140},[97,381,330],{"class":250},[97,383,253],{"class":119},[97,385,256],{"class":226},[97,387,364],{"class":119},[97,389,184],{"class":176},[97,391,392],{"class":180},"taproot",[97,394,184],{"class":176},[97,396,374],{"class":119},[97,398,399],{"class":352},"\u002F\u002F starts with bc1p\n",[83,401,402],{},"That empty object in the middle is annoying but honest: the address type is the second parameter and there is no overload that lets you skip the first.",[78,404,406],{"id":405},"a-key-you-already-have","A key you already have",[87,408,410],{"className":150,"code":409,"language":152,"meta":92,"style":92},"const privateKey = \"7f9e5b9e3bbed34a4c28c8c1665525fc2cd7afb4fdc7edca3eb93ddf8a31ef56\";\nconst wallet = chain.deriveWallet(privateKey);\nconst segwitWallet = chain.deriveWallet(privateKey, {}, \"segwit\");\n",[94,411,412,430,453],{"__ignoreMap":92},[97,413,414,416,419,421,423,426,428],{"class":99,"line":100},[97,415,216],{"class":103},[97,417,418],{"class":219}," privateKey",[97,420,223],{"class":103},[97,422,177],{"class":176},[97,424,425],{"class":180},"7f9e5b9e3bbed34a4c28c8c1665525fc2cd7afb4fdc7edca3eb93ddf8a31ef56",[97,427,184],{"class":176},[97,429,137],{"class":119},[97,431,432,434,436,438,440,442,445,447,450],{"class":99,"line":123},[97,433,216],{"class":103},[97,435,245],{"class":219},[97,437,223],{"class":103},[97,439,220],{"class":250},[97,441,253],{"class":119},[97,443,444],{"class":226},"deriveWallet",[97,446,229],{"class":119},[97,448,449],{"class":250},"privateKey",[97,451,452],{"class":119},");\n",[97,454,455,457,460,462,464,466,468,470,472,475,477,480,482],{"class":99,"line":140},[97,456,216],{"class":103},[97,458,459],{"class":219}," segwitWallet",[97,461,223],{"class":103},[97,463,220],{"class":250},[97,465,253],{"class":119},[97,467,444],{"class":226},[97,469,229],{"class":119},[97,471,449],{"class":250},[97,473,474],{"class":119},", {}, ",[97,476,184],{"class":176},[97,478,479],{"class":180},"segwit",[97,481,184],{"class":176},[97,483,452],{"class":119},[83,485,486,487,489],{},"Same arguments as ",[94,488,256],{},", minus the randomness.",[78,491,493],{"id":492},"from-a-mnemonic","From a mnemonic",[83,495,496,499],{},[94,497,498],{},"deriveHDWallet"," walks a BIP39 mnemonic down a derivation path and returns the wallet at the end:",[87,501,503],{"className":150,"code":502,"language":152,"meta":92,"style":92},"const mnemonic =\n  \"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about\";\n\nchain.deriveHDWallet(mnemonic, \"m\u002F84'\u002F0'\u002F0'\u002F0\u002F0\").address; \u002F\u002F bc1q...\nchain.deriveHDWallet(mnemonic, \"m\u002F44'\u002F0'\u002F0'\u002F0\u002F0\", { passphrase: \"TREZOR\" }, \"p2sh\");\n",[94,504,505,515,527,531,565],{"__ignoreMap":92},[97,506,507,509,512],{"class":99,"line":100},[97,508,216],{"class":103},[97,510,511],{"class":219}," mnemonic",[97,513,514],{"class":103}," =\n",[97,516,517,520,523,525],{"class":99,"line":123},[97,518,519],{"class":176},"  \"",[97,521,522],{"class":180},"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",[97,524,184],{"class":176},[97,526,137],{"class":119},[97,528,529],{"class":99,"line":140},[97,530,210],{"emptyLinePlaceholder":209},[97,532,533,535,537,539,541,544,547,549,552,554,557,559,562],{"class":99,"line":213},[97,534,330],{"class":250},[97,536,253],{"class":119},[97,538,498],{"class":226},[97,540,229],{"class":119},[97,542,543],{"class":250},"mnemonic",[97,545,546],{"class":119},", ",[97,548,184],{"class":176},[97,550,551],{"class":180},"m\u002F84'\u002F0'\u002F0'\u002F0\u002F0",[97,553,184],{"class":176},[97,555,556],{"class":119},").",[97,558,308],{"class":250},[97,560,561],{"class":119},"; ",[97,563,564],{"class":352},"\u002F\u002F bc1q...\n",[97,566,567,569,571,573,575,577,579,581,584,586,589,592,594,596,599,601,604,606,608,610],{"class":99,"line":240},[97,568,330],{"class":250},[97,570,253],{"class":119},[97,572,498],{"class":226},[97,574,229],{"class":119},[97,576,543],{"class":250},[97,578,546],{"class":119},[97,580,184],{"class":176},[97,582,583],{"class":180},"m\u002F44'\u002F0'\u002F0'\u002F0\u002F0",[97,585,184],{"class":176},[97,587,588],{"class":119},", {",[97,590,591],{"class":165}," passphrase",[97,593,130],{"class":119},[97,595,177],{"class":176},[97,597,598],{"class":180},"TREZOR",[97,600,184],{"class":176},[97,602,603],{"class":119}," }, ",[97,605,184],{"class":176},[97,607,369],{"class":180},[97,609,184],{"class":176},[97,611,452],{"class":119},[83,613,614],{},"Things that will bite you:",[616,617,618,622,628,647],"ul",{},[619,620,621],"li",{},"The mnemonic has to pass the English BIP39 checksum. A typo in word eleven fails before any derivation happens.",[619,623,624,625,253],{},"secp256k1 chains derive with BIP32, ed25519 chains with SLIP-10. SLIP-10 only has hardened children, so Solana, Aptos, and Sui on ed25519 need every segment hardened: ",[94,626,627],{},"m\u002F44'\u002F501'\u002F0'\u002F0'",[619,629,630,631,634,635,638,639,642,643,646],{},"Bitcoin reads the purpose when you do not pass an address type. ",[94,632,633],{},"m\u002F44'"," gives legacy, ",[94,636,637],{},"m\u002F49'"," p2sh, ",[94,640,641],{},"m\u002F84'"," segwit, ",[94,644,645],{},"m\u002F86'"," taproot. An explicit type wins.",[619,648,649],{},"Cardano throws. CIP-1852 starts from the entropy, not from the BIP39 seed, and pretending otherwise would hand you addresses that no Cardano wallet recognises.",[83,651,652],{},"The mnemonic above is the public BIP39 test vector. It is fine for docs and tests and for nothing else.",[78,654,656],{"id":655},"security-again","Security, again",[83,658,659],{},"The library does not store keys, encrypt keys, or forget keys. Whatever calls it holds the private key in memory as a plain string, and so does every log line that prints a wallet object. Generate throwaway keys for tests, keep real ones on hardware, and be twice as careful in a browser tab where an extension can read the page.",[78,661,663],{"id":662},"the-whole-method","The whole method",[83,665,666,667,669],{},"This is all ",[94,668,256],{}," is:",[87,671,675],{"className":672,"code":673,"language":674,"meta":92,"style":92},"language-ts shiki shiki-themes github-light github-light poimandres","generateWallet(options?: KeyOptions, addressType?: AddressType): Wallet {\n  const keys = this.generateKeys(options);\n  const address = this.getAddress(keys.keys.public, addressType);\n\n  return { ...keys, address };\n}\n","ts",[94,676,677,710,734,767,771,792],{"__ignoreMap":92},[97,678,679,681,683,686,689,692,694,697,699,702,705,708],{"class":99,"line":100},[97,680,256],{"class":226},[97,682,229],{"class":119},[97,684,685],{"class":250},"options",[97,687,688],{"class":103},"?:",[97,690,691],{"class":250}," KeyOptions",[97,693,546],{"class":119},[97,695,696],{"class":250},"addressType",[97,698,688],{"class":103},[97,700,701],{"class":250}," AddressType",[97,703,704],{"class":119},"): ",[97,706,707],{"class":250},"Wallet",[97,709,120],{"class":119},[97,711,712,715,718,720,724,726,728,730,732],{"class":99,"line":123},[97,713,714],{"class":103},"  const",[97,716,717],{"class":219}," keys",[97,719,223],{"class":103},[97,721,723],{"class":722},"s-lox"," this",[97,725,253],{"class":119},[97,727,316],{"class":226},[97,729,229],{"class":119},[97,731,685],{"class":250},[97,733,452],{"class":119},[97,735,736,738,741,743,745,747,749,751,753,755,757,759,761,763,765],{"class":99,"line":140},[97,737,714],{"class":103},[97,739,740],{"class":219}," address",[97,742,223],{"class":103},[97,744,723],{"class":722},[97,746,253],{"class":119},[97,748,320],{"class":226},[97,750,229],{"class":119},[97,752,275],{"class":250},[97,754,253],{"class":119},[97,756,275],{"class":250},[97,758,253],{"class":119},[97,760,296],{"class":250},[97,762,546],{"class":119},[97,764,696],{"class":250},[97,766,452],{"class":119},[97,768,769],{"class":99,"line":213},[97,770,210],{"emptyLinePlaceholder":209},[97,772,773,777,779,782,784,787,789],{"class":99,"line":240},[97,774,776],{"class":775},"sZW6a","  return",[97,778,162],{"class":119},[97,780,781],{"class":103}," ...",[97,783,275],{"class":250},[97,785,786],{"class":119},",",[97,788,740],{"class":250},[97,790,791],{"class":119}," };\n",[97,793,794],{"class":99,"line":262},[97,795,143],{"class":119},[83,797,798,799,802],{},"It lives on ",[94,800,801],{},"AbstractBlockchain",", so every chain, including one you write yourself, gets it for free.",[804,805,806],"style",{},"html pre.shiki code .s1TYA, html code.shiki .s1TYA{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#91B4D5}html pre.shiki code .sCrqT, html code.shiki .sCrqT{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#A6ACCDC0}html pre.shiki code .sP0CR, html code.shiki .sP0CR{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#5DE4C7}html pre.shiki code .scZRh, html code.shiki .scZRh{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#ADD7FF}html pre.shiki code .sKlNE, html code.shiki .sKlNE{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#A6ACCD}html pre.shiki code .s0VbO, html code.shiki .s0VbO{--shiki-light:#E36209;--shiki-default:#E36209;--shiki-dark:#A6ACCD}html pre.shiki code .s8yaW, html code.shiki .s8yaW{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#A6ACCDC0}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .snHMy, html code.shiki .snHMy{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#ADD7FF}html pre.shiki code .stCPd, html code.shiki .stCPd{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#A6ACCD}html pre.shiki code .scVjq, html code.shiki .scVjq{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#A6ACCD}html pre.shiki code .sQ7BG, html code.shiki .sQ7BG{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#5DE4C7}html pre.shiki code .saoiD, html code.shiki .saoiD{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#E4F0FB}html pre.shiki code .sULi6, html code.shiki .sULi6{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#E4F0FBD0}html pre.shiki code .spVlQ, html code.shiki .spVlQ{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E4F0FB}html pre.shiki code .sNe8j, html code.shiki .sNe8j{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#D0679D}html pre.shiki code .sjhu3, html code.shiki .sjhu3{--shiki-light:#6A737D;--shiki-light-font-style:inherit;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#767C9DB0;--shiki-dark-font-style:italic}html pre.shiki code .s-lox, html code.shiki .s-lox{--shiki-light:#005CC5;--shiki-light-font-style:inherit;--shiki-default:#005CC5;--shiki-default-font-style:inherit;--shiki-dark:#5DE4C7;--shiki-dark-font-style:italic}html pre.shiki code .sZW6a, html code.shiki .sZW6a{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#5DE4C7C0}",{"title":92,"searchDepth":123,"depth":123,"links":808},[809,810,811,812,813,814],{"id":80,"depth":123,"text":81},{"id":146,"depth":123,"text":147},{"id":405,"depth":123,"text":406},{"id":492,"depth":123,"text":493},{"id":655,"depth":123,"text":656},{"id":662,"depth":123,"text":663},"One call for keys plus address, importing a key you already have, and walking a mnemonic down a path.","md",null,{"icon":819},"i-lucide-wallet",{"title":20,"description":815},"Ax0PUWiAMtu9-k3yl9lGcgF7AuLu6mK1Fj1FBFuZEdk",[823,825],{"title":16,"path":17,"stem":18,"description":824,"children":-1},"Turn a public key into an address, pick a format, and check one you were given.",{"title":24,"path":25,"stem":26,"description":826,"children":-1},"Ethereum and Base share one implementation, one address, and one signing scheme.",1788428715659]