[{"data":1,"prerenderedAt":517},["ShallowReactive",2],{"navigation_docs":3,"-blockchains-tron":84,"-blockchains-tron-surround":514},[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":80,"body":86,"description":507,"extension":508,"links":509,"meta":510,"navigation":160,"path":81,"seo":512,"stem":82,"__hash__":513},"docs\u002F2.blockchains\u002Ftron.md",{"type":87,"value":88,"toc":500},"minimark",[89,96,101,197,201,212,263,273,277,321,330,334,384,390,394,428,493,496],[90,91],"chain-facts",{"coin":92,"curve":93,"driver":94,"formats":95},"195","secp256k1","tron","base58check",[97,98,100],"h2",{"id":99},"load-it","Load it",[102,103,108],"pre",{"className":104,"code":105,"language":106,"meta":107,"style":107},"language-js shiki shiki-themes github-light github-light poimandres","import { useBlockchain, blockchains } from \"@agntn\u002Fkeys\";\n\nconst tronChain = useBlockchain(await blockchains.tron()());\n","js","",[109,110,111,155,162],"code",{"__ignoreMap":107},[112,113,116,120,124,128,131,134,137,141,145,149,152],"span",{"class":114,"line":115},"line",1,[112,117,119],{"class":118},"sP0CR","import",[112,121,123],{"class":122},"sKlNE"," {",[112,125,127],{"class":126},"snHMy"," useBlockchain",[112,129,130],{"class":122},",",[112,132,133],{"class":126}," blockchains",[112,135,136],{"class":122}," }",[112,138,140],{"class":139},"stCPd"," from",[112,142,144],{"class":143},"scVjq"," \"",[112,146,148],{"class":147},"sQ7BG","@agntn\u002Fkeys",[112,150,151],{"class":143},"\"",[112,153,154],{"class":122},";\n",[112,156,158],{"class":114,"line":157},2,[112,159,161],{"emptyLinePlaceholder":160},true,"\n",[112,163,165,169,173,176,179,182,186,189,192,194],{"class":114,"line":164},3,[112,166,168],{"class":167},"s1TYA","const",[112,170,172],{"class":171},"saoiD"," tronChain",[112,174,175],{"class":167}," =",[112,177,127],{"class":178},"sULi6",[112,180,181],{"class":122},"(",[112,183,185],{"class":184},"sZW6a","await",[112,187,133],{"class":188},"spVlQ",[112,190,191],{"class":122},".",[112,193,94],{"class":178},[112,195,196],{"class":122},"()());\n",[97,198,200],{"id":199},"the-address","The address",[202,203,204,205,208,209,191],"p",{},"Keccak-256 of the public key, last 20 bytes, exactly like Ethereum. Then a version byte ",[109,206,207],{},"0x41"," in front and base58check around it, which is why every TRON address starts with ",[109,210,211],{},"T",[102,213,215],{"className":104,"code":214,"language":106,"meta":107,"style":107},"const publicKey = tronChain.getKeyPublic(privateKey);\ntronChain.getAddress(publicKey); \u002F\u002F TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW\n",[109,216,217,241],{"__ignoreMap":107},[112,218,219,221,224,226,228,230,233,235,238],{"class":114,"line":115},[112,220,168],{"class":167},[112,222,223],{"class":171}," publicKey",[112,225,175],{"class":167},[112,227,172],{"class":188},[112,229,191],{"class":122},[112,231,232],{"class":178},"getKeyPublic",[112,234,181],{"class":122},[112,236,237],{"class":188},"privateKey",[112,239,240],{"class":122},");\n",[112,242,243,246,248,251,253,256,259],{"class":114,"line":157},[112,244,245],{"class":188},"tronChain",[112,247,191],{"class":122},[112,249,250],{"class":178},"getAddress",[112,252,181],{"class":122},[112,254,255],{"class":188},"publicKey",[112,257,258],{"class":122},"); ",[112,260,262],{"class":261},"sjhu3","\u002F\u002F TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW\n",[202,264,265,266,268,269,272],{},"Strip the base58check and swap ",[109,267,207],{}," for ",[109,270,271],{},"0x",", and you have the Ethereum address of the same key. That is a nice trick for debugging and a bad idea for anything else.",[97,274,276],{"id":275},"testnet","Testnet",[102,278,280],{"className":104,"code":279,"language":106,"meta":107,"style":107},"const shasta = useBlockchain(await blockchains.tron({ network: \"testnet\" })());\n",[109,281,282],{"__ignoreMap":107},[112,283,284,286,289,291,293,295,297,299,301,303,306,309,312,314,316,318],{"class":114,"line":115},[112,285,168],{"class":167},[112,287,288],{"class":171}," shasta",[112,290,175],{"class":167},[112,292,127],{"class":178},[112,294,181],{"class":122},[112,296,185],{"class":184},[112,298,133],{"class":188},[112,300,191],{"class":122},[112,302,94],{"class":178},[112,304,305],{"class":122},"({",[112,307,308],{"class":126}," network",[112,310,311],{"class":122},":",[112,313,144],{"class":143},[112,315,275],{"class":147},[112,317,151],{"class":143},[112,319,320],{"class":122}," })());\n",[202,322,323,324,326,327,329],{},"TRON testnets use the same ",[109,325,207],{}," prefix as mainnet, so testnet addresses also start with ",[109,328,211],{},". The driver accepts the option for symmetry with the other chains, but there's no way to tell a Shasta address from a mainnet one by looking at it. Don't rely on the string.",[97,331,333],{"id":332},"validation","Validation",[102,335,337],{"className":104,"code":336,"language":106,"meta":107,"style":107},"tronChain.validateAddress(\"TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW\"); \u002F\u002F true\ntronChain.validateAddress(\"1JCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW\"); \u002F\u002F false, wrong prefix\n",[109,338,339,362],{"__ignoreMap":107},[112,340,341,343,345,348,350,352,355,357,359],{"class":114,"line":115},[112,342,245],{"class":188},[112,344,191],{"class":122},[112,346,347],{"class":178},"validateAddress",[112,349,181],{"class":122},[112,351,151],{"class":143},[112,353,354],{"class":147},"TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW",[112,356,151],{"class":143},[112,358,258],{"class":122},[112,360,361],{"class":261},"\u002F\u002F true\n",[112,363,364,366,368,370,372,374,377,379,381],{"class":114,"line":157},[112,365,245],{"class":188},[112,367,191],{"class":122},[112,369,347],{"class":178},[112,371,181],{"class":122},[112,373,151],{"class":143},[112,375,376],{"class":147},"1JCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW",[112,378,151],{"class":143},[112,380,258],{"class":122},[112,382,383],{"class":261},"\u002F\u002F false, wrong prefix\n",[202,385,386,387,389],{},"Base58check decode, version byte ",[109,388,207],{},", 21 bytes total. The checksum catches typos, the prefix catches pasted Bitcoin addresses.",[97,391,393],{"id":392},"signing","Signing",[202,395,396,399,400,403,404,407,408,411,412,415,416,419,420,423,424,427],{},[109,397,398],{},"signMessage"," frames the message the TIP-191 way, ",[109,401,402],{},"\"\\x19TRON Signed Message:\\n\" + length + message",", hashes it with Keccak-256 and signs with secp256k1. That's the digest TronWeb's ",[109,405,406],{},"signMessageV2"," and TronLink sign, so the same key gives the same ",[109,409,410],{},"r"," and ",[109,413,414],{},"s"," here and there. What comes back is those 64 bytes in hex, no recovery byte. ",[109,417,418],{},"verifyMessage"," here doesn't need one, ",[109,421,422],{},"verifyMessageV2"," does, so append a ",[109,425,426],{},"v"," before asking TronWeb to recover the address.",[102,429,431],{"className":104,"code":430,"language":106,"meta":107,"style":107},"const signature = tronChain.signMessage(\"hello\", privateKey);\ntronChain.verifyMessage(\"hello\", signature, publicKey); \u002F\u002F true\n",[109,432,433,464],{"__ignoreMap":107},[112,434,435,437,440,442,444,446,448,450,452,455,457,460,462],{"class":114,"line":115},[112,436,168],{"class":167},[112,438,439],{"class":171}," signature",[112,441,175],{"class":167},[112,443,172],{"class":188},[112,445,191],{"class":122},[112,447,398],{"class":178},[112,449,181],{"class":122},[112,451,151],{"class":143},[112,453,454],{"class":147},"hello",[112,456,151],{"class":143},[112,458,459],{"class":122},", ",[112,461,237],{"class":188},[112,463,240],{"class":122},[112,465,466,468,470,472,474,476,478,480,482,485,487,489,491],{"class":114,"line":157},[112,467,245],{"class":188},[112,469,191],{"class":122},[112,471,418],{"class":178},[112,473,181],{"class":122},[112,475,151],{"class":143},[112,477,454],{"class":147},[112,479,151],{"class":143},[112,481,459],{"class":122},[112,483,484],{"class":188},"signature",[112,486,459],{"class":122},[112,488,255],{"class":188},[112,490,258],{"class":122},[112,492,361],{"class":261},[202,494,495],{},"Ethereum uses the same framing under its own preamble, which is why a TRON signature and an Ethereum signature of the same message from the same key differ, and each driver rejects the other's.",[497,498,499],"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":107,"searchDepth":157,"depth":157,"links":501},[502,503,504,505,506],{"id":99,"depth":157,"text":100},{"id":199,"depth":157,"text":200},{"id":275,"depth":157,"text":276},{"id":332,"depth":157,"text":333},{"id":392,"depth":157,"text":393},"secp256k1 with Ethereum's 20 byte hash wrapped in base58check so every address starts with T.","md",null,{"icon":511},"i-token-trx",{"title":80,"description":507},"ttQfyPo5l7ELMTvLmSqJ9MweWUQPMhohNrTs3a2_FP0",[515,509],{"title":76,"path":77,"stem":78,"description":516,"children":-1},"ed25519 or secp256k1 on one chain. Blake2b over a flag byte and the public key.",1789827526013]