[{"data":1,"prerenderedAt":716},["ShallowReactive",2],{"navigation_docs":3,"-blockchains-polkadot":128,"-blockchains-polkadot-surround":711},[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":127},"Blockchains","\u002Fblockchains","2.blockchains\u002F0.index",[37,39,43,47,51,55,59,63,67,71,75,79,83,87,91,95,99,103,107,111,115,119,123],{"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},"Bitcoin Cash","\u002Fblockchains\u002Fbitcoincash","2.blockchains\u002Fbitcoincash",{"title":56,"path":57,"stem":58},"Bitcoin Gold","\u002Fblockchains\u002Fbitcoingold","2.blockchains\u002Fbitcoingold",{"title":60,"path":61,"stem":62},"Bitcoin SV","\u002Fblockchains\u002Fbitcoinsv","2.blockchains\u002Fbitcoinsv",{"title":64,"path":65,"stem":66},"Cardano","\u002Fblockchains\u002Fcardano","2.blockchains\u002Fcardano",{"title":68,"path":69,"stem":70},"Cosmos","\u002Fblockchains\u002Fcosmos","2.blockchains\u002Fcosmos",{"title":72,"path":73,"stem":74},"Dash","\u002Fblockchains\u002Fdash","2.blockchains\u002Fdash",{"title":76,"path":77,"stem":78},"Decred","\u002Fblockchains\u002Fdecred","2.blockchains\u002Fdecred",{"title":80,"path":81,"stem":82},"Dogecoin","\u002Fblockchains\u002Fdogecoin","2.blockchains\u002Fdogecoin",{"title":84,"path":85,"stem":86},"eCash","\u002Fblockchains\u002Fecash","2.blockchains\u002Fecash",{"title":88,"path":89,"stem":90},"Ethereum","\u002Fblockchains\u002Fethereum","2.blockchains\u002Fethereum",{"title":92,"path":93,"stem":94},"Litecoin","\u002Fblockchains\u002Flitecoin","2.blockchains\u002Flitecoin",{"title":96,"path":97,"stem":98},"NEAR","\u002Fblockchains\u002Fnear","2.blockchains\u002Fnear",{"title":100,"path":101,"stem":102},"Polkadot","\u002Fblockchains\u002Fpolkadot","2.blockchains\u002Fpolkadot",{"title":104,"path":105,"stem":106},"Solana","\u002Fblockchains\u002Fsolana","2.blockchains\u002Fsolana",{"title":108,"path":109,"stem":110},"Stellar","\u002Fblockchains\u002Fstellar","2.blockchains\u002Fstellar",{"title":112,"path":113,"stem":114},"Sui","\u002Fblockchains\u002Fsui","2.blockchains\u002Fsui",{"title":116,"path":117,"stem":118},"TRON","\u002Fblockchains\u002Ftron","2.blockchains\u002Ftron",{"title":120,"path":121,"stem":122},"XRP Ledger","\u002Fblockchains\u002Fxrpl","2.blockchains\u002Fxrpl",{"title":124,"path":125,"stem":126},"Zcash","\u002Fblockchains\u002Fzcash","2.blockchains\u002Fzcash","i-lucide-boxes",{"id":129,"title":100,"body":130,"description":703,"extension":704,"links":705,"meta":706,"navigation":183,"path":101,"seo":708,"stem":102,"__hash__":710},"docs\u002F2.blockchains\u002Fpolkadot.md",{"type":131,"value":132,"toc":695},"minimark",[133,140,145,267,275,284,288,291,372,379,386,424,431,435,438,504,526,537,548,559,563,581,623,632,636,661,665,691],[134,135],"chain-facts",{"coin":136,"curve":137,"driver":138,"formats":139},"354","ed25519","polkadot","SS58 under any network prefix",[141,142,144],"h2",{"id":143},"load-it","Load it",[146,147,152],"pre",{"className":148,"code":149,"language":150,"meta":151,"style":151},"language-js shiki shiki-themes keys keys keys","import { useBlockchain, blockchains } from \"@agntn\u002Fkeys\";\n\nconst polkadot = useBlockchain(await blockchains.polkadot()());\nconst kusama = useBlockchain(await blockchains.polkadot({ ss58Prefix: 2 })());\nconst westend = useBlockchain(await blockchains.polkadot({ network: \"testnet\" })());\n","js","",[153,154,155,178,185,215,238],"code",{"__ignoreMap":151},[156,157,160,164,168,171,175],"span",{"class":158,"line":159},"line",1,[156,161,163],{"class":162},"skH_V","import",[156,165,167],{"class":166},"s38Sx"," { useBlockchain, blockchains } ",[156,169,170],{"class":162},"from",[156,172,174],{"class":173},"shU9J"," \"@agntn\u002Fkeys\"",[156,176,177],{"class":166},";\n",[156,179,181],{"class":158,"line":180},2,[156,182,184],{"emptyLinePlaceholder":183},true,"\n",[156,186,188,191,194,197,201,204,207,210,212],{"class":158,"line":187},3,[156,189,190],{"class":162},"const",[156,192,193],{"class":166}," polkadot ",[156,195,196],{"class":162},"=",[156,198,200],{"class":199},"sK71F"," useBlockchain",[156,202,203],{"class":166},"(",[156,205,206],{"class":162},"await",[156,208,209],{"class":166}," blockchains.",[156,211,138],{"class":199},[156,213,214],{"class":166},"()());\n",[156,216,218,220,223,225,227,229,231,233,235],{"class":158,"line":217},4,[156,219,190],{"class":162},[156,221,222],{"class":166}," kusama ",[156,224,196],{"class":162},[156,226,200],{"class":199},[156,228,203],{"class":166},[156,230,206],{"class":162},[156,232,209],{"class":166},[156,234,138],{"class":199},[156,236,237],{"class":166},"({ ss58Prefix: 2 })());\n",[156,239,241,243,246,248,250,252,254,256,258,261,264],{"class":158,"line":240},5,[156,242,190],{"class":162},[156,244,245],{"class":166}," westend ",[156,247,196],{"class":162},[156,249,200],{"class":199},[156,251,203],{"class":166},[156,253,206],{"class":162},[156,255,209],{"class":166},[156,257,138],{"class":199},[156,259,260],{"class":166},"({ network: ",[156,262,263],{"class":173},"\"testnet\"",[156,265,266],{"class":166}," })());\n",[268,269,270,271,274],"p",{},"One class for every Substrate chain. The chain shows up as a number in front of the key. 0 is Polkadot, 2 is Kusama, 42 is the generic Substrate format. ",[153,272,273],{},"network: \"testnet\""," picks 42, which is what Westend and Paseo use.",[276,277,279,280,283],"warning",{"title":278},"ed25519 only, for now","Most wallets create sr25519 accounts. This driver writes ed25519 ones. Same words, other curve, other address. So if Polkadot.js shows something else for your phrase, nothing's broken. sr25519 comes once ",[153,281,282],{},"@agntn\u002Fcurves"," has Ristretto255 to stand on.",[141,285,287],{"id":286},"whats-in-an-address","What's in an address?",[268,289,290],{},"The prefix, the public key itself and two checksum bytes, in base58. No hash of the key at all. The account is the key.",[146,292,294],{"className":148,"code":293,"language":150,"meta":151,"style":151},"const privateKey = \"0000000000000000000000000000000000000000000000000000000000000001\";\nconst publicKey = polkadot.getKeyPublic(privateKey);\n\npolkadot.getAddress(publicKey); \u002F\u002F 12jacCzszzdckmb7pYNSGxy61nUwP9nrNefP92AFpKP62N46\nkusama.getAddress(publicKey); \u002F\u002F EJu8C5gmaP54tQ3dc8V2mVwJkmXVX3tkXmeNPSrk2a4akcB\nwestend.getAddress(publicKey); \u002F\u002F 5DoHTsjp9DN9KEabruKS8p8wAAVHgrEiJ9vtyjAuGEMZqpWt\n",[153,295,296,310,328,332,347,359],{"__ignoreMap":151},[156,297,298,300,303,305,308],{"class":158,"line":159},[156,299,190],{"class":162},[156,301,302],{"class":166}," privateKey ",[156,304,196],{"class":162},[156,306,307],{"class":173}," \"0000000000000000000000000000000000000000000000000000000000000001\"",[156,309,177],{"class":166},[156,311,312,314,317,319,322,325],{"class":158,"line":180},[156,313,190],{"class":162},[156,315,316],{"class":166}," publicKey ",[156,318,196],{"class":162},[156,320,321],{"class":166}," polkadot.",[156,323,324],{"class":199},"getKeyPublic",[156,326,327],{"class":166},"(privateKey);\n",[156,329,330],{"class":158,"line":187},[156,331,184],{"emptyLinePlaceholder":183},[156,333,334,337,340,343],{"class":158,"line":217},[156,335,336],{"class":166},"polkadot.",[156,338,339],{"class":199},"getAddress",[156,341,342],{"class":166},"(publicKey); ",[156,344,346],{"class":345},"scIB-","\u002F\u002F 12jacCzszzdckmb7pYNSGxy61nUwP9nrNefP92AFpKP62N46\n",[156,348,349,352,354,356],{"class":158,"line":240},[156,350,351],{"class":166},"kusama.",[156,353,339],{"class":199},[156,355,342],{"class":166},[156,357,358],{"class":345},"\u002F\u002F EJu8C5gmaP54tQ3dc8V2mVwJkmXVX3tkXmeNPSrk2a4akcB\n",[156,360,362,365,367,369],{"class":158,"line":361},6,[156,363,364],{"class":166},"westend.",[156,366,339],{"class":199},[156,368,342],{"class":166},[156,370,371],{"class":345},"\u002F\u002F 5DoHTsjp9DN9KEabruKS8p8wAAVHgrEiJ9vtyjAuGEMZqpWt\n",[268,373,374,375,378],{},"Three addresses, one key. The only blake2b in there is the checksum, and it hashes the string ",[153,376,377],{},"SS58PRE"," in front of everything. Yes, really.",[268,380,381,382,385],{},"Prefixes up to 63 take one byte, the rest up to 16383 take two. 46 and 47 are reserved, so they throw when you load the chain. ",[153,383,384],{},"validateAddress"," wants the checksum and this instance's prefix:",[146,387,389],{"className":148,"code":388,"language":150,"meta":151,"style":151},"polkadot.validateAddress(\"12jacCzszzdckmb7pYNSGxy61nUwP9nrNefP92AFpKP62N46\"); \u002F\u002F true\npolkadot.validateAddress(\"EJu8C5gmaP54tQ3dc8V2mVwJkmXVX3tkXmeNPSrk2a4akcB\"); \u002F\u002F false\n",[153,390,391,408],{"__ignoreMap":151},[156,392,393,395,397,399,402,405],{"class":158,"line":159},[156,394,336],{"class":166},[156,396,384],{"class":199},[156,398,203],{"class":166},[156,400,401],{"class":173},"\"12jacCzszzdckmb7pYNSGxy61nUwP9nrNefP92AFpKP62N46\"",[156,403,404],{"class":166},"); ",[156,406,407],{"class":345},"\u002F\u002F true\n",[156,409,410,412,414,416,419,421],{"class":158,"line":180},[156,411,336],{"class":166},[156,413,384],{"class":199},[156,415,203],{"class":166},[156,417,418],{"class":173},"\"EJu8C5gmaP54tQ3dc8V2mVwJkmXVX3tkXmeNPSrk2a4akcB\"",[156,420,404],{"class":166},[156,422,423],{"class":345},"\u002F\u002F false\n",[268,425,426,427,430],{},"A Kusama account on Polkadot is ",[153,428,429],{},"false",", good checksum or not. Only 32-byte accounts pass. Old account indices and 33-byte ECDSA ones don't come from a key here, so they don't validate either.",[141,432,434],{"id":433},"mnemonics","Mnemonics",[268,436,437],{},"Not BIP32, and not even the BIP39 seed. Substrate runs PBKDF2 over the phrase's entropy, keeps 32 bytes and calls it the mini secret. That's the root key. Below it you walk junctions.",[146,439,441],{"className":148,"code":440,"language":150,"meta":151,"style":151},"const mnemonic =\n  \"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about\";\n\npolkadot.deriveHDWallet(mnemonic, \"m\").address;\n\u002F\u002F 14HKDhPM8fr6JB9yk9TGZTsBUdk8WJq1AiMbi1YAzUarv1Jp\npolkadot.deriveHDWallet(mnemonic, \"\u002F\u002Fpolkadot\u002F\u002F0\").address;\n\u002F\u002F 14a9YHn5Mast138yujPzW3NKQw83fZS2gN2QQPmsZAf5NC8U\n",[153,442,443,453,460,464,480,485,498],{"__ignoreMap":151},[156,444,445,447,450],{"class":158,"line":159},[156,446,190],{"class":162},[156,448,449],{"class":166}," mnemonic ",[156,451,452],{"class":162},"=\n",[156,454,455,458],{"class":158,"line":180},[156,456,457],{"class":173},"  \"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about\"",[156,459,177],{"class":166},[156,461,462],{"class":158,"line":187},[156,463,184],{"emptyLinePlaceholder":183},[156,465,466,468,471,474,477],{"class":158,"line":217},[156,467,336],{"class":166},[156,469,470],{"class":199},"deriveHDWallet",[156,472,473],{"class":166},"(mnemonic, ",[156,475,476],{"class":173},"\"m\"",[156,478,479],{"class":166},").address;\n",[156,481,482],{"class":158,"line":240},[156,483,484],{"class":345},"\u002F\u002F 14HKDhPM8fr6JB9yk9TGZTsBUdk8WJq1AiMbi1YAzUarv1Jp\n",[156,486,487,489,491,493,496],{"class":158,"line":361},[156,488,336],{"class":166},[156,490,470],{"class":199},[156,492,473],{"class":166},[156,494,495],{"class":173},"\"\u002F\u002Fpolkadot\u002F\u002F0\"",[156,497,479],{"class":166},[156,499,501],{"class":158,"line":500},7,[156,502,503],{"class":345},"\u002F\u002F 14a9YHn5Mast138yujPzW3NKQw83fZS2gN2QQPmsZAf5NC8U\n",[268,505,506,509,510,513,514,517,518,521,522,525],{},[153,507,508],{},"m"," or an empty path is the root. ",[153,511,512],{},"\u002F\u002Fname"," is a hard junction, and a number like ",[153,515,516],{},"\u002F\u002F0"," counts as a number. The ",[153,519,520],{},"\u002F\u002F\u002Fpassword"," of a Substrate URI goes in ",[153,523,524],{},"passphrase",", not in the path.",[268,527,528,529,532,533,536],{},"What throws? A soft junction like ",[153,530,531],{},"\u002F0",", since ed25519 can't walk one. And two junctions the reference tools read differently. ",[153,534,535],{},"\u002F\u002F0x00"," is hex to polkadot.js and a name to subkey. A number past 64 bits is a 256-bit number to one and a name to the other. Two implementations, two keys. We'd rather throw than guess which one your wallet used.",[268,538,539,540,543,544,547],{},"Here's a fun one. The checksum never gets into the entropy. Twelve times ",[153,541,542],{},"abandon"," fails the checksum, but with ",[153,545,546],{},"allowInvalidChecksum"," it lands on the exact account above, with a warning.",[268,549,550,551,554,555,558],{},"There's no BIP44 path to build, so ",[153,552,553],{},"getDerivationPath()"," throws. ",[153,556,557],{},"keys_hd_wallet_scan"," won't walk Polkadot either. Wallets name their own junctions, so there's no list to walk.",[141,560,562],{"id":561},"signing","Signing",[268,564,565,568,569,572,573,576,577,580],{},[153,566,567],{},"signMessage"," wraps the message in ",[153,570,571],{},"\u003CBytes>"," and ",[153,574,575],{},"\u003C\u002FBytes>"," first. That's what the polkadot.js extension does in ",[153,578,579],{},"signRaw",", so your signature matches the one it hands out. You get 64 bytes of ed25519 in hex.",[146,582,584],{"className":148,"code":583,"language":150,"meta":151,"style":151},"const signature = polkadot.signMessage(\"Hello, Polkadot!\", privateKey);\npolkadot.verifyMessage(\"Hello, Polkadot!\", signature, publicKey); \u002F\u002F true\n",[153,585,586,607],{"__ignoreMap":151},[156,587,588,590,593,595,597,599,601,604],{"class":158,"line":159},[156,589,190],{"class":162},[156,591,592],{"class":166}," signature ",[156,594,196],{"class":162},[156,596,321],{"class":166},[156,598,567],{"class":199},[156,600,203],{"class":166},[156,602,603],{"class":173},"\"Hello, Polkadot!\"",[156,605,606],{"class":166},", privateKey);\n",[156,608,609,611,614,616,618,621],{"class":158,"line":180},[156,610,336],{"class":166},[156,612,613],{"class":199},"verifyMessage",[156,615,203],{"class":166},[156,617,603],{"class":173},[156,619,620],{"class":166},", signature, publicKey); ",[156,622,407],{"class":345},[268,624,625,627,628,631],{},[153,626,613],{}," takes a signature over the raw message too, like polkadot.js ",[153,629,630],{},"signatureVerify",". Got one from a script that never wrapped anything? It still checks out.",[141,633,635],{"id":634},"agents","Agents",[268,637,638,639,642,643,646,647,650,651,654,655,657,658,660],{},"On ",[153,640,641],{},"chain: \"polkadot\""," the ",[153,644,645],{},"prefix"," argument is the SS58 number as text, ",[153,648,649],{},"\"2\""," for Kusama. ",[153,652,653],{},"keys_hd_wallet_derive"," takes junctions or ",[153,656,508],{}," as its path, and ",[153,659,524],{}," is the URI password.",[141,662,664],{"id":663},"where-it-lives","Where it lives",[268,666,667,670,671,674,675,678,679,682,683,686,687,690],{},[153,668,669],{},"src\u002Fblockchains\u002Fpolkadot.ts",", with SS58 in ",[153,672,673],{},"src\u002Futils\u002Fss58.ts"," and junctions in ",[153,676,677],{},"src\u002Futils\u002Fsubstrate.ts",". ed25519 comes from ",[153,680,681],{},"@noble\u002Fcurves",", blake2b and PBKDF2 from ",[153,684,685],{},"@agntn\u002Fhashes",", base58 from ",[153,688,689],{},"@agntn\u002Fencodings",".",[692,693,694],"style",{},"html pre.shiki code .skH_V, html code.shiki .skH_V{--shiki-light:var(--shiki-token-keyword);--shiki-default:var(--shiki-token-keyword);--shiki-dark:var(--shiki-token-keyword)}html pre.shiki code .s38Sx, html code.shiki .s38Sx{--shiki-light:var(--ui-text-highlighted);--shiki-default:var(--ui-text-highlighted);--shiki-dark:var(--ui-text-highlighted)}html pre.shiki code .shU9J, html code.shiki .shU9J{--shiki-light:var(--shiki-token-string);--shiki-default:var(--shiki-token-string);--shiki-dark:var(--shiki-token-string)}html pre.shiki code .sK71F, html code.shiki .sK71F{--shiki-light:var(--shiki-token-function);--shiki-default:var(--shiki-token-function);--shiki-dark:var(--shiki-token-function)}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 .scIB-, html code.shiki .scIB-{--shiki-light:var(--shiki-token-comment);--shiki-default:var(--shiki-token-comment);--shiki-dark:var(--shiki-token-comment)}",{"title":151,"searchDepth":180,"depth":180,"links":696},[697,698,699,700,701,702],{"id":143,"depth":180,"text":144},{"id":286,"depth":180,"text":287},{"id":433,"depth":180,"text":434},{"id":561,"depth":180,"text":562},{"id":634,"depth":180,"text":635},{"id":663,"depth":180,"text":664},"ed25519 keys and BIP39 words to Polkadot, Kusama and Substrate SS58 addresses. Hard junctions derive the way subkey and polkadot.js do.","md",null,{"icon":707},"i-token-dot",{"title":709,"description":703},"Polkadot and Kusama SS58 addresses from keys and BIP39 words","DqjgzRpEDZCv42ArzrOOk5cJ8NEIcymYVX9zaHrnBDI",[712,714],{"title":96,"path":97,"stem":98,"description":713,"children":-1},"ed25519 keys and BIP39 words to NEAR implicit accounts. The account ID is the public key in hex. Named accounts stay on chain.",{"title":104,"path":105,"stem":106,"description":715,"children":-1},"ed25519. The address is the public key itself in base58 with nothing hashed.",1791396797940]