[{"data":1,"prerenderedAt":903},["ShallowReactive",2],{"navigation_docs":3,"-guide-addresses":84,"-guide-addresses-surround":898},[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":83},"Blockchains","\u002Fblockchains","2.blockchains\u002F0.index",[37,39,43,47,51,55,59,63,67,71,75,79],{"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},"Decred","\u002Fblockchains\u002Fdecred","2.blockchains\u002Fdecred",{"title":60,"path":61,"stem":62},"Ethereum","\u002Fblockchains\u002Fethereum","2.blockchains\u002Fethereum",{"title":64,"path":65,"stem":66},"Litecoin","\u002Fblockchains\u002Flitecoin","2.blockchains\u002Flitecoin",{"title":68,"path":69,"stem":70},"Solana","\u002Fblockchains\u002Fsolana","2.blockchains\u002Fsolana",{"title":72,"path":73,"stem":74},"Stellar","\u002Fblockchains\u002Fstellar","2.blockchains\u002Fstellar",{"title":76,"path":77,"stem":78},"Sui","\u002Fblockchains\u002Fsui","2.blockchains\u002Fsui",{"title":80,"path":81,"stem":82},"TRON","\u002Fblockchains\u002Ftron","2.blockchains\u002Ftron","i-lucide-boxes",{"id":85,"title":16,"body":86,"description":891,"extension":892,"links":893,"meta":894,"navigation":166,"path":17,"seo":896,"stem":18,"__hash__":897},"docs\u002F1.guide\u002F3.addresses.md",{"type":87,"value":88,"toc":884},"minimark",[89,94,280,284,288,291,368,371,375,425,428,442,446,617,620,624,877,880],[90,91,93],"h2",{"id":92},"from-public-key-to-address","From public key to address",[95,96,101],"pre",{"className":97,"code":98,"language":99,"meta":100,"style":100},"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 keys = chain.generateKeys();\nconst address = chain.getAddress(keys.keys.public);\n\nconsole.log(address); \u002F\u002F '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'\n","js","",[102,103,104,142,161,168,196,218,252,257],"code",{"__ignoreMap":100},[105,106,109,113,117,121,124,128,132,136,139],"span",{"class":107,"line":108},"line",1,[105,110,112],{"class":111},"sP0CR","import",[105,114,116],{"class":115},"sKlNE"," {",[105,118,120],{"class":119},"snHMy"," useBlockchain",[105,122,123],{"class":115}," }",[105,125,127],{"class":126},"stCPd"," from",[105,129,131],{"class":130},"scVjq"," \"",[105,133,135],{"class":134},"sQ7BG","@agntn\u002Fkeys",[105,137,138],{"class":130},"\"",[105,140,141],{"class":115},";\n",[105,143,145,147,150,152,154,157,159],{"class":107,"line":144},2,[105,146,112],{"class":111},[105,148,149],{"class":119}," Bitcoin",[105,151,127],{"class":126},[105,153,131],{"class":130},[105,155,156],{"class":134},"@agntn\u002Fkeys\u002Fblockchains\u002Fbitcoin",[105,158,138],{"class":130},[105,160,141],{"class":115},[105,162,164],{"class":107,"line":163},3,[105,165,167],{"emptyLinePlaceholder":166},true,"\n",[105,169,171,175,179,182,185,188,191,193],{"class":107,"line":170},4,[105,172,174],{"class":173},"s1TYA","const",[105,176,178],{"class":177},"saoiD"," chain",[105,180,181],{"class":173}," =",[105,183,120],{"class":184},"sULi6",[105,186,187],{"class":115},"(",[105,189,190],{"class":111},"new",[105,192,149],{"class":184},[105,194,195],{"class":115},"());\n",[105,197,199,201,204,206,209,212,215],{"class":107,"line":198},5,[105,200,174],{"class":173},[105,202,203],{"class":177}," keys",[105,205,181],{"class":173},[105,207,178],{"class":208},"spVlQ",[105,210,211],{"class":115},".",[105,213,214],{"class":184},"generateKeys",[105,216,217],{"class":115},"();\n",[105,219,221,223,226,228,230,232,235,237,240,242,244,246,249],{"class":107,"line":220},6,[105,222,174],{"class":173},[105,224,225],{"class":177}," address",[105,227,181],{"class":173},[105,229,178],{"class":208},[105,231,211],{"class":115},[105,233,234],{"class":184},"getAddress",[105,236,187],{"class":115},[105,238,239],{"class":208},"keys",[105,241,211],{"class":115},[105,243,239],{"class":208},[105,245,211],{"class":115},[105,247,248],{"class":208},"public",[105,250,251],{"class":115},");\n",[105,253,255],{"class":107,"line":254},7,[105,256,167],{"emptyLinePlaceholder":166},[105,258,260,263,265,268,270,273,276],{"class":107,"line":259},8,[105,261,262],{"class":208},"console",[105,264,211],{"class":115},[105,266,267],{"class":184},"log",[105,269,187],{"class":115},[105,271,272],{"class":208},"address",[105,274,275],{"class":115},"); ",[105,277,279],{"class":278},"sjhu3","\u002F\u002F '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'\n",[281,282,283],"p",{},"Every chain does the same thing here: hash the public key, then encode the hash the way the chain likes. What differs is the hash, the encoding, and whether there's a checksum.",[90,285,287],{"id":286},"address-types","Address types",[281,289,290],{},"The second argument picks a format on chains that have more than one.",[95,292,294],{"className":97,"code":293,"language":99,"meta":100,"style":100},"chain.getAddress(publicKey); \u002F\u002F legacy, starts with 1\nchain.getAddress(publicKey, \"segwit\"); \u002F\u002F bc1q...\nchain.getAddress(publicKey, \"taproot\"); \u002F\u002F bc1p...\n",[102,295,296,315,342],{"__ignoreMap":100},[105,297,298,301,303,305,307,310,312],{"class":107,"line":108},[105,299,300],{"class":208},"chain",[105,302,211],{"class":115},[105,304,234],{"class":184},[105,306,187],{"class":115},[105,308,309],{"class":208},"publicKey",[105,311,275],{"class":115},[105,313,314],{"class":278},"\u002F\u002F legacy, starts with 1\n",[105,316,317,319,321,323,325,327,330,332,335,337,339],{"class":107,"line":144},[105,318,300],{"class":208},[105,320,211],{"class":115},[105,322,234],{"class":184},[105,324,187],{"class":115},[105,326,309],{"class":208},[105,328,329],{"class":115},", ",[105,331,138],{"class":130},[105,333,334],{"class":134},"segwit",[105,336,138],{"class":130},[105,338,275],{"class":115},[105,340,341],{"class":278},"\u002F\u002F bc1q...\n",[105,343,344,346,348,350,352,354,356,358,361,363,365],{"class":107,"line":163},[105,345,300],{"class":208},[105,347,211],{"class":115},[105,349,234],{"class":184},[105,351,187],{"class":115},[105,353,309],{"class":208},[105,355,329],{"class":115},[105,357,138],{"class":130},[105,359,360],{"class":134},"taproot",[105,362,138],{"class":130},[105,364,275],{"class":115},[105,366,367],{"class":278},"\u002F\u002F bc1p...\n",[281,369,370],{},"Bitcoin and Litecoin have five formats, Cardano three, Sui uses the argument to name the curve. Decred has one and throws if you ask for another. Ethereum, Base, TRON, Solana, Stellar, and Aptos have one format and ignore the argument.",[90,372,374],{"id":373},"validating","Validating",[95,376,378],{"className":97,"code":377,"language":99,"meta":100,"style":100},"chain.validateAddress(\"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa\"); \u002F\u002F true\nchain.validateAddress(\"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNb\"); \u002F\u002F false, checksum\n",[102,379,380,403],{"__ignoreMap":100},[105,381,382,384,386,389,391,393,396,398,400],{"class":107,"line":108},[105,383,300],{"class":208},[105,385,211],{"class":115},[105,387,388],{"class":184},"validateAddress",[105,390,187],{"class":115},[105,392,138],{"class":130},[105,394,395],{"class":134},"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",[105,397,138],{"class":130},[105,399,275],{"class":115},[105,401,402],{"class":278},"\u002F\u002F true\n",[105,404,405,407,409,411,413,415,418,420,422],{"class":107,"line":144},[105,406,300],{"class":208},[105,408,211],{"class":115},[105,410,388],{"class":184},[105,412,187],{"class":115},[105,414,138],{"class":130},[105,416,417],{"class":134},"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNb",[105,419,138],{"class":130},[105,421,275],{"class":115},[105,423,424],{"class":278},"\u002F\u002F false, checksum\n",[281,426,427],{},"Validation checks the format and the checksum when the format has one. It doesn't touch the network. A valid address with no history is still valid.",[429,430,431,433,434,437,438,441],"note",{},[102,432,388],{}," is optional on the ",[102,435,436],{},"BlockchainImplementation"," type so that structural implementations can skip it, but every class built on ",[102,439,440],{},"AbstractBlockchain"," has one. Every built in chain does.",[90,443,445],{"id":444},"how-each-chain-builds-its-address","How each chain builds its address",[447,448,449,462],"table",{},[450,451,452],"thead",{},[453,454,455,459],"tr",{},[456,457,458],"th",{},"Chain",[456,460,461],{},"Recipe",[463,464,465,476,502,519,534,548,555,568,580,600],"tbody",{},[453,466,467,470],{},[468,469,48],"td",{},[468,471,472,475],{},[102,473,474],{},"RIPEMD160(SHA256(pubkey))",", then base58check for legacy and p2sh, bech32 for segwit, bech32m with a BIP341 tweak for taproot",[453,477,478,480],{},[468,479,64],{},[468,481,482,483,486,487,490,491,494,495,498,499],{},"the same hash and encodings, version ",[102,484,485],{},"0x30"," for legacy (",[102,488,489],{},"L","), ",[102,492,493],{},"0x32"," for p2sh (",[102,496,497],{},"M","), bech32 with ",[102,500,501],{},"ltc",[453,503,504,506],{},[468,505,56],{},[468,507,508,511,512,515,516],{},[102,509,510],{},"RIPEMD160(BLAKE256(pubkey))"," behind the two byte prefix ",[102,513,514],{},"07 3f",", base58check with a double BLAKE-256 checksum, so it starts with ",[102,517,518],{},"Ds",[453,520,521,524],{},[468,522,523],{},"Ethereum, Base",[468,525,526,527,329,530,533],{},"last 20 bytes of ",[102,528,529],{},"Keccak-256(uncompressed pubkey without 04)",[102,531,532],{},"0x"," prefix, EIP-55 mixed case checksum",[453,535,536,538],{},[468,537,80],{},[468,539,540,541,544,545],{},"same 20 bytes as Ethereum, version byte ",[102,542,543],{},"0x41",", base58check, so it starts with ",[102,546,547],{},"T",[453,549,550,552],{},[468,551,68],{},[468,553,554],{},"the ed25519 public key itself, base58",[453,556,557,559],{},[468,558,72],{},[468,560,561,562,564,565],{},"version byte ",[102,563,485],{},", the ed25519 public key, a CRC16-XModem checksum, all in base32, so it starts with ",[102,566,567],{},"G",[453,569,570,572],{},[468,571,40],{},[468,573,574,329,577,579],{},[102,575,576],{},"SHA3-256(pubkey + 0x00)",[102,578,532],{}," prefix",[453,581,582,584],{},[468,583,76],{},[468,585,586,589,590,593,594,597,598,579],{},[102,587,588],{},"Blake2b-256(flag + pubkey)",", flag ",[102,591,592],{},"0x00"," for ed25519 and ",[102,595,596],{},"0x01"," for secp256k1, ",[102,599,532],{},[453,601,602,604],{},[468,603,52],{},[468,605,606,609,610,613,614],{},[102,607,608],{},"Blake2b-224(pubkey)"," behind a header byte, bech32 with ",[102,611,612],{},"addr"," or ",[102,615,616],{},"stake",[281,618,619],{},"The chain pages have the code for each, plus the testnet variants where they exist.",[90,621,623],{"id":622},"a-quick-tour","A quick tour",[95,625,627],{"className":97,"code":626,"language":99,"meta":100,"style":100},"import Ethereum from \"@agntn\u002Fkeys\u002Fblockchains\u002Fethereum\";\nimport Solana from \"@agntn\u002Fkeys\u002Fblockchains\u002Fsolana\";\nimport Sui from \"@agntn\u002Fkeys\u002Fblockchains\u002Fsui\";\n\nconst ethereumChain = useBlockchain(new Ethereum());\nethereumChain.getAddress(ethereumChain.getKeyPublic(privateKey)); \u002F\u002F '0x...' with checksum\n\nconst solanaChain = useBlockchain(new Solana());\nsolanaChain.getAddress(solanaChain.getKeyPublic(privateKey)); \u002F\u002F base58, no hashing at all\n\nconst suiChain = useBlockchain(new Sui());\nconst secpKey = suiChain.getKeyPublic(privateKey, { scheme: \"secp256k1\" });\nsuiChain.getAddress(secpKey, \"secp256k1\"); \u002F\u002F '0x...' from the secp256k1 flag\n",[102,628,629,647,665,683,687,706,735,739,758,785,790,810,849],{"__ignoreMap":100},[105,630,631,633,636,638,640,643,645],{"class":107,"line":108},[105,632,112],{"class":111},[105,634,635],{"class":119}," Ethereum",[105,637,127],{"class":126},[105,639,131],{"class":130},[105,641,642],{"class":134},"@agntn\u002Fkeys\u002Fblockchains\u002Fethereum",[105,644,138],{"class":130},[105,646,141],{"class":115},[105,648,649,651,654,656,658,661,663],{"class":107,"line":144},[105,650,112],{"class":111},[105,652,653],{"class":119}," Solana",[105,655,127],{"class":126},[105,657,131],{"class":130},[105,659,660],{"class":134},"@agntn\u002Fkeys\u002Fblockchains\u002Fsolana",[105,662,138],{"class":130},[105,664,141],{"class":115},[105,666,667,669,672,674,676,679,681],{"class":107,"line":163},[105,668,112],{"class":111},[105,670,671],{"class":119}," Sui",[105,673,127],{"class":126},[105,675,131],{"class":130},[105,677,678],{"class":134},"@agntn\u002Fkeys\u002Fblockchains\u002Fsui",[105,680,138],{"class":130},[105,682,141],{"class":115},[105,684,685],{"class":107,"line":170},[105,686,167],{"emptyLinePlaceholder":166},[105,688,689,691,694,696,698,700,702,704],{"class":107,"line":198},[105,690,174],{"class":173},[105,692,693],{"class":177}," ethereumChain",[105,695,181],{"class":173},[105,697,120],{"class":184},[105,699,187],{"class":115},[105,701,190],{"class":111},[105,703,635],{"class":184},[105,705,195],{"class":115},[105,707,708,711,713,715,717,719,721,724,726,729,732],{"class":107,"line":220},[105,709,710],{"class":208},"ethereumChain",[105,712,211],{"class":115},[105,714,234],{"class":184},[105,716,187],{"class":115},[105,718,710],{"class":208},[105,720,211],{"class":115},[105,722,723],{"class":184},"getKeyPublic",[105,725,187],{"class":115},[105,727,728],{"class":208},"privateKey",[105,730,731],{"class":115},")); ",[105,733,734],{"class":278},"\u002F\u002F '0x...' with checksum\n",[105,736,737],{"class":107,"line":254},[105,738,167],{"emptyLinePlaceholder":166},[105,740,741,743,746,748,750,752,754,756],{"class":107,"line":259},[105,742,174],{"class":173},[105,744,745],{"class":177}," solanaChain",[105,747,181],{"class":173},[105,749,120],{"class":184},[105,751,187],{"class":115},[105,753,190],{"class":111},[105,755,653],{"class":184},[105,757,195],{"class":115},[105,759,761,764,766,768,770,772,774,776,778,780,782],{"class":107,"line":760},9,[105,762,763],{"class":208},"solanaChain",[105,765,211],{"class":115},[105,767,234],{"class":184},[105,769,187],{"class":115},[105,771,763],{"class":208},[105,773,211],{"class":115},[105,775,723],{"class":184},[105,777,187],{"class":115},[105,779,728],{"class":208},[105,781,731],{"class":115},[105,783,784],{"class":278},"\u002F\u002F base58, no hashing at all\n",[105,786,788],{"class":107,"line":787},10,[105,789,167],{"emptyLinePlaceholder":166},[105,791,793,795,798,800,802,804,806,808],{"class":107,"line":792},11,[105,794,174],{"class":173},[105,796,797],{"class":177}," suiChain",[105,799,181],{"class":173},[105,801,120],{"class":184},[105,803,187],{"class":115},[105,805,190],{"class":111},[105,807,671],{"class":184},[105,809,195],{"class":115},[105,811,813,815,818,820,822,824,826,828,830,833,836,839,841,844,846],{"class":107,"line":812},12,[105,814,174],{"class":173},[105,816,817],{"class":177}," secpKey",[105,819,181],{"class":173},[105,821,797],{"class":208},[105,823,211],{"class":115},[105,825,723],{"class":184},[105,827,187],{"class":115},[105,829,728],{"class":208},[105,831,832],{"class":115},", {",[105,834,835],{"class":119}," scheme",[105,837,838],{"class":115},":",[105,840,131],{"class":130},[105,842,843],{"class":134},"secp256k1",[105,845,138],{"class":130},[105,847,848],{"class":115}," });\n",[105,850,852,855,857,859,861,864,866,868,870,872,874],{"class":107,"line":851},13,[105,853,854],{"class":208},"suiChain",[105,856,211],{"class":115},[105,858,234],{"class":184},[105,860,187],{"class":115},[105,862,863],{"class":208},"secpKey",[105,865,329],{"class":115},[105,867,138],{"class":130},[105,869,843],{"class":134},[105,871,138],{"class":130},[105,873,275],{"class":115},[105,875,876],{"class":278},"\u002F\u002F '0x...' from the secp256k1 flag\n",[281,878,879],{},"The Sui line is the one people get wrong: a secp256k1 public key hashed with the ed25519 flag produces a perfectly valid looking address that no key can spend from. Keep the scheme on both calls.",[881,882,883],"style",{},"html pre.shiki code .sP0CR, html code.shiki .sP0CR{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#5DE4C7}html pre.shiki code .sKlNE, html code.shiki .sKlNE{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#A6ACCD}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 .s1TYA, html code.shiki .s1TYA{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#91B4D5}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 .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 .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);}",{"title":100,"searchDepth":144,"depth":144,"links":885},[886,887,888,889,890],{"id":92,"depth":144,"text":93},{"id":286,"depth":144,"text":287},{"id":373,"depth":144,"text":374},{"id":444,"depth":144,"text":445},{"id":622,"depth":144,"text":623},"Turn a public key into an address. Pick a format. Check one you were given.","md",null,{"icon":895},"i-lucide-map-pin",{"title":16,"description":891},"FxVNWQuvutKLBhMfbS8gg8jqF1IeHqWV1I2Dxf0KlS0",[899,901],{"title":12,"path":13,"stem":14,"description":900,"children":-1},"Private and public keys. Compression and WIF. The one chain that speaks two curves.",{"title":20,"path":21,"stem":22,"description":902,"children":-1},"One call for keys plus address. Import a key you already have. Walk a mnemonic down a path with a broken checksum if you must.",1789938976771]