[{"data":1,"prerenderedAt":518},["ShallowReactive",2],{"navigation_docs":3,"-blockchains-cardano":72,"-blockchains-cardano-surround":513},[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":52,"body":74,"description":506,"extension":507,"links":508,"meta":509,"navigation":148,"path":53,"seo":511,"stem":54,"__hash__":512},"docs\u002F2.blockchains\u002Fcardano.md",{"type":75,"value":76,"toc":499},"minimark",[77,84,89,226,230,234,320,421,427,430,434,471,478,482,488,492,495],[78,79],"chain-facts",{"coin":80,"curve":81,"driver":82,"formats":83},"1815","ed25519","cardano","bech32 base, enterprise, stake",[85,86,88],"h2",{"id":87},"load-it","Load it",[90,91,96],"pre",{"className":92,"code":93,"language":94,"meta":95,"style":95},"language-js shiki shiki-themes github-light github-light poimandres","import { useBlockchain, blockchains } from \"@agntn\u002Fkeys\";\n\nconst cardanoChain = useBlockchain(await blockchains.cardano()());\nconst preprod = useBlockchain(await blockchains.cardano({ network: \"testnet\" })());\n","js","",[97,98,99,143,150,185],"code",{"__ignoreMap":95},[100,101,104,108,112,116,119,122,125,129,133,137,140],"span",{"class":102,"line":103},"line",1,[100,105,107],{"class":106},"sP0CR","import",[100,109,111],{"class":110},"sKlNE"," {",[100,113,115],{"class":114},"snHMy"," useBlockchain",[100,117,118],{"class":110},",",[100,120,121],{"class":114}," blockchains",[100,123,124],{"class":110}," }",[100,126,128],{"class":127},"stCPd"," from",[100,130,132],{"class":131},"scVjq"," \"",[100,134,136],{"class":135},"sQ7BG","@agntn\u002Fkeys",[100,138,139],{"class":131},"\"",[100,141,142],{"class":110},";\n",[100,144,146],{"class":102,"line":145},2,[100,147,149],{"emptyLinePlaceholder":148},true,"\n",[100,151,153,157,161,164,167,170,174,177,180,182],{"class":102,"line":152},3,[100,154,156],{"class":155},"s1TYA","const",[100,158,160],{"class":159},"saoiD"," cardanoChain",[100,162,163],{"class":155}," =",[100,165,115],{"class":166},"sULi6",[100,168,169],{"class":110},"(",[100,171,173],{"class":172},"sZW6a","await",[100,175,121],{"class":176},"spVlQ",[100,178,179],{"class":110},".",[100,181,82],{"class":166},[100,183,184],{"class":110},"()());\n",[100,186,188,190,193,195,197,199,201,203,205,207,210,213,216,218,221,223],{"class":102,"line":187},4,[100,189,156],{"class":155},[100,191,192],{"class":159}," preprod",[100,194,163],{"class":155},[100,196,115],{"class":166},[100,198,169],{"class":110},[100,200,173],{"class":172},[100,202,121],{"class":176},[100,204,179],{"class":110},[100,206,82],{"class":166},[100,208,209],{"class":110},"({",[100,211,212],{"class":114}," network",[100,214,215],{"class":110},":",[100,217,132],{"class":131},[100,219,220],{"class":135},"testnet",[100,222,139],{"class":131},[100,224,225],{"class":110}," })());\n",[85,227,229],{"id":228},"three-address-types","Three address types",[231,232,233],"p",{},"Cardano hashes the public key with Blake2b-224 and puts a header byte in front: the address type in the high nibble, the network id in the low one. Then bech32.",[235,236,237,256],"table",{},[238,239,240],"thead",{},[241,242,243,247,250,253],"tr",{},[244,245,246],"th",{},"Type",[244,248,249],{},"Mainnet",[244,251,252],{},"Testnet",[244,254,255],{},"Payload",[257,258,259,282,300],"tbody",{},[241,260,261,269,274,279],{},[262,263,264,265,268],"td",{},"base (default, also ",[97,266,267],{},"payment",")",[262,270,271],{},[97,272,273],{},"addr1...",[262,275,276],{},[97,277,278],{},"addr_test1...",[262,280,281],{},"payment hash + stake hash, 57 bytes",[241,283,284,289,293,297],{},[262,285,286],{},[97,287,288],{},"enterprise",[262,290,291],{},[97,292,273],{},[262,294,295],{},[97,296,278],{},[262,298,299],{},"payment hash only, 29 bytes",[241,301,302,307,312,317],{},[262,303,304],{},[97,305,306],{},"stake",[262,308,309],{},[97,310,311],{},"stake1...",[262,313,314],{},[97,315,316],{},"stake_test1...",[262,318,319],{},"stake hash, 29 bytes",[90,321,323],{"className":92,"code":322,"language":94,"meta":95,"style":95},"const publicKey = cardanoChain.getKeyPublic(privateKey);\n\ncardanoChain.getAddress(publicKey); \u002F\u002F base\ncardanoChain.getAddress(publicKey, \"enterprise\");\ncardanoChain.getAddress(publicKey, \"stake\");\n",[97,324,325,349,353,375,398],{"__ignoreMap":95},[100,326,327,329,332,334,336,338,341,343,346],{"class":102,"line":103},[100,328,156],{"class":155},[100,330,331],{"class":159}," publicKey",[100,333,163],{"class":155},[100,335,160],{"class":176},[100,337,179],{"class":110},[100,339,340],{"class":166},"getKeyPublic",[100,342,169],{"class":110},[100,344,345],{"class":176},"privateKey",[100,347,348],{"class":110},");\n",[100,350,351],{"class":102,"line":145},[100,352,149],{"emptyLinePlaceholder":148},[100,354,355,358,360,363,365,368,371],{"class":102,"line":152},[100,356,357],{"class":176},"cardanoChain",[100,359,179],{"class":110},[100,361,362],{"class":166},"getAddress",[100,364,169],{"class":110},[100,366,367],{"class":176},"publicKey",[100,369,370],{"class":110},"); ",[100,372,374],{"class":373},"sjhu3","\u002F\u002F base\n",[100,376,377,379,381,383,385,387,390,392,394,396],{"class":102,"line":187},[100,378,357],{"class":176},[100,380,179],{"class":110},[100,382,362],{"class":166},[100,384,169],{"class":110},[100,386,367],{"class":176},[100,388,389],{"class":110},", ",[100,391,139],{"class":131},[100,393,288],{"class":135},[100,395,139],{"class":131},[100,397,348],{"class":110},[100,399,401,403,405,407,409,411,413,415,417,419],{"class":102,"line":400},5,[100,402,357],{"class":176},[100,404,179],{"class":110},[100,406,362],{"class":166},[100,408,169],{"class":110},[100,410,367],{"class":176},[100,412,389],{"class":110},[100,414,139],{"class":131},[100,416,306],{"class":135},[100,418,139],{"class":131},[100,420,348],{"class":110},[231,422,423,424,426],{},"One honest caveat about the base address. A real base address carries two different hashes, the payment key and the stake key, and a wallet derives them from two paths. This driver has one key, so it uses the same hash for both halves. The address is valid and spendable with that key, but its stake half points at the payment key, which is not how a full wallet lays things out. Use ",[97,425,288],{}," when you want an address with no staking story at all.",[231,428,429],{},"Testnet is a constructor option, not an address type. Preprod and preview both use network id 0, so one driver covers them.",[85,431,433],{"id":432},"validation","Validation",[90,435,437],{"className":92,"code":436,"language":94,"meta":95,"style":95},"cardanoChain.validateAddress(\n  \"addr1q9kytfmxk3vdze7s5prpnrjl6j3qldqssvn7mkcpnpvd2p0ltsyswunewxmf58504d9tkqelz2vf02w0msgtvcuzdmsdhq0z4\",\n); \u002F\u002F true\n",[97,438,439,451,464],{"__ignoreMap":95},[100,440,441,443,445,448],{"class":102,"line":103},[100,442,357],{"class":176},[100,444,179],{"class":110},[100,446,447],{"class":166},"validateAddress",[100,449,450],{"class":110},"(\n",[100,452,453,456,459,461],{"class":102,"line":145},[100,454,455],{"class":131},"  \"",[100,457,458],{"class":135},"addr1q9kytfmxk3vdze7s5prpnrjl6j3qldqssvn7mkcpnpvd2p0ltsyswunewxmf58504d9tkqelz2vf02w0msgtvcuzdmsdhq0z4",[100,460,139],{"class":131},[100,462,463],{"class":110},",\n",[100,465,466,468],{"class":102,"line":152},[100,467,370],{"class":110},[100,469,470],{"class":373},"\u002F\u002F true\n",[231,472,473,474,477],{},"bech32 decode, then the header byte has to match the driver's network, and the length has to match the type: 57 bytes for base, 29 for enterprise and stake. A mainnet driver rejects ",[97,475,476],{},"addr_test"," addresses.",[85,479,481],{"id":480},"mnemonics","Mnemonics",[231,483,484,487],{},[97,485,486],{},"deriveHDWallet"," throws. Cardano wallets follow CIP-1852, which starts from the BIP39 entropy and runs it through a different key derivation than BIP32 or SLIP-10. Faking it from the BIP39 seed would produce addresses that Daedalus, Lace, and Eternl have never heard of, and a library that quietly does that is worse than one that refuses. So it refuses.",[85,489,491],{"id":490},"signing","Signing",[231,493,494],{},"Plain ed25519 over the message bytes, hex out. Not the CIP-8 envelope that dapps use for wallet login.",[496,497,498],"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 .sZW6a, html code.shiki .sZW6a{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#5DE4C7C0}html pre.shiki code .spVlQ, html code.shiki .spVlQ{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E4F0FB}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 .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}",{"title":95,"searchDepth":145,"depth":145,"links":500},[501,502,503,504,505],{"id":87,"depth":145,"text":88},{"id":228,"depth":145,"text":229},{"id":432,"depth":145,"text":433},{"id":480,"depth":145,"text":481},{"id":490,"depth":145,"text":491},"ed25519 with bech32 base, enterprise, and stake addresses. Mnemonic derivation is refused on purpose.","md",null,{"icon":510},"i-simple-icons-cardano",{"title":52,"description":506},"JBvGEIfJNa8laA6WYP6tA6oqWrL9tY1OENRFx06mliQ",[514,516],{"title":48,"path":49,"stem":50,"description":515,"children":-1},"secp256k1 with legacy, p2sh, segwit, p2wsh, and taproot addresses, on mainnet and testnet.",{"title":56,"path":57,"stem":58,"description":517,"children":-1},"secp256k1 with EIP-55 checksummed addresses and personal_sign message signatures.",1788428715659]