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