[{"data":1,"prerenderedAt":601},["ShallowReactive",2],{"navigation_docs":3,"-guide-rlp":140,"-guide-rlp-surround":596},[4,52],{"title":5,"path":6,"stem":7,"children":8,"icon":51},"Guide","\u002Fguide","1.guide\u002F01.index",[9,11,15,19,23,27,31,35,39,43,47],{"title":10,"path":6,"stem":7},"Getting Started",{"title":12,"path":13,"stem":14},"Encoding and Decoding","\u002Fguide\u002Fencoding","1.guide\u002F02.encoding",{"title":16,"path":17,"stem":18},"Checksums","\u002Fguide\u002Fchecksums","1.guide\u002F03.checksums",{"title":20,"path":21,"stem":22},"Identify","\u002Fguide\u002Fidentify","1.guide\u002F04.identify",{"title":24,"path":25,"stem":26},"CLI","\u002Fguide\u002Fcli","1.guide\u002F05.cli",{"title":28,"path":29,"stem":30},"Agents","\u002Fguide\u002Fagents","1.guide\u002F06.agents",{"title":32,"path":33,"stem":34},"Code pages","\u002Fguide\u002Fcode-pages","1.guide\u002F07.code-pages",{"title":36,"path":37,"stem":38},"RLP","\u002Fguide\u002Frlp","1.guide\u002F08.rlp",{"title":40,"path":41,"stem":42},"OpenPGP armor","\u002Fguide\u002Farmor","1.guide\u002F09.armor",{"title":44,"path":45,"stem":46},"Custom Encodings","\u002Fguide\u002Fcustom","1.guide\u002F10.custom",{"title":48,"path":49,"stem":50},"Playground","\u002Fguide\u002Fplayground","1.guide\u002F11.playground","i-lucide-book-open",{"title":53,"path":54,"stem":55,"children":56,"icon":139},"Encodings","\u002Fencodings","2.encodings\u002F00.index",[57,59,63,67,71,75,79,83,87,91,95,99,103,107,111,115,119,123,127,131,135],{"title":58,"path":54,"stem":55},"Every encoding",{"title":60,"path":61,"stem":62},"Binary","\u002Fencodings\u002Fbinary","2.encodings\u002F01.binary",{"title":64,"path":65,"stem":66},"Octal","\u002Fencodings\u002Foctal","2.encodings\u002F02.octal",{"title":68,"path":69,"stem":70},"Decimal","\u002Fencodings\u002Fdecimal","2.encodings\u002F03.decimal",{"title":72,"path":73,"stem":74},"Integer","\u002Fencodings\u002Finteger","2.encodings\u002F03.integer",{"title":76,"path":77,"stem":78},"Hex","\u002Fencodings\u002Fhex","2.encodings\u002F04.hex",{"title":80,"path":81,"stem":82},"Base32","\u002Fencodings\u002Fbase32","2.encodings\u002F05.base32",{"title":84,"path":85,"stem":86},"Base45","\u002Fencodings\u002Fbase45","2.encodings\u002F09.base45",{"title":88,"path":89,"stem":90},"Base58","\u002Fencodings\u002Fbase58","2.encodings\u002F10.base58",{"title":92,"path":93,"stem":94},"Base64","\u002Fencodings\u002Fbase64","2.encodings\u002F14.base64",{"title":96,"path":97,"stem":98},"Base85","\u002Fencodings\u002Fbase85","2.encodings\u002F18.base85",{"title":100,"path":101,"stem":102},"basE91","\u002Fencodings\u002Fbase91","2.encodings\u002F19.base91",{"title":104,"path":105,"stem":106},"Base256","\u002Fencodings\u002Fbase256","2.encodings\u002F20.base256",{"title":108,"path":109,"stem":110},"Bech32","\u002Fencodings\u002Fbech32","2.encodings\u002F21.bech32",{"title":112,"path":113,"stem":114},"uuencode","\u002Fencodings\u002Fuuencode","2.encodings\u002F22.uuencode",{"title":116,"path":117,"stem":118},"Quoted-Printable","\u002Fencodings\u002Fquoted-printable","2.encodings\u002F23.quoted-printable",{"title":120,"path":121,"stem":122},"HTML","\u002Fencodings\u002Fhtml","2.encodings\u002F24.html",{"title":124,"path":125,"stem":126},"ITA2","\u002Fencodings\u002Fita2","2.encodings\u002F25.ita2",{"title":128,"path":129,"stem":130},"Prefix codes","\u002Fencodings\u002Fprefix","2.encodings\u002F26.prefix",{"title":132,"path":133,"stem":134},"Chess squares","\u002Fencodings\u002Fsquare","2.encodings\u002F27.square",{"title":136,"path":137,"stem":138},"FEN","\u002Fencodings\u002Ffen","2.encodings\u002F28.fen","i-lucide-library",{"id":141,"title":36,"body":142,"description":590,"extension":591,"links":592,"meta":593,"navigation":192,"path":37,"seo":594,"stem":38,"__hash__":595},"docs\u002F1.guide\u002F08.rlp.md",{"type":143,"value":144,"toc":584},"minimark",[145,150,154,273,304,308,314,337,364,375,379,389,539,554,557,561,580],[146,147,149],"h2",{"id":148},"bytes-and-lists-nothing-else","Bytes and lists, nothing else",[151,152,153],"p",{},"RLP isn't text. It's how Ethereum writes a transaction, a block header, a trie node. Every value is bytes or a list of values, and each one carries its length up front. That's the whole format. No types, no field names, no mercy.",[155,156,161],"pre",{"className":157,"code":158,"language":159,"meta":160,"style":160},"language-ts shiki shiki-themes encodings encodings encodings","import { hex, rlp } from \"@agntn\u002Fencodings\";\n\nhex.encode(rlp.encode([new TextEncoder().encode(\"dog\"), 1000n, []]));\n\u002F\u002F \"c883646f678203e8c0\"\nrlp.decode(hex.decode(\"c88363617483646f67\"));\n\u002F\u002F [Uint8Array [0x63, 0x61, 0x74], Uint8Array [0x64, 0x6f, 0x67]]\n","ts","",[162,163,164,187,194,238,245,267],"code",{"__ignoreMap":160},[165,166,169,173,177,180,184],"span",{"class":167,"line":168},"line",1,[165,170,172],{"class":171},"skH_V","import",[165,174,176],{"class":175},"s38Sx"," { hex, rlp } ",[165,178,179],{"class":171},"from",[165,181,183],{"class":182},"shU9J"," \"@agntn\u002Fencodings\"",[165,185,186],{"class":175},";\n",[165,188,190],{"class":167,"line":189},2,[165,191,193],{"emptyLinePlaceholder":192},true,"\n",[165,195,197,200,204,207,209,212,215,218,221,223,226,229,232,235],{"class":167,"line":196},3,[165,198,199],{"class":175},"hex.",[165,201,203],{"class":202},"sK71F","encode",[165,205,206],{"class":175},"(rlp.",[165,208,203],{"class":202},[165,210,211],{"class":175},"([",[165,213,214],{"class":171},"new",[165,216,217],{"class":202}," TextEncoder",[165,219,220],{"class":175},"().",[165,222,203],{"class":202},[165,224,225],{"class":175},"(",[165,227,228],{"class":182},"\"dog\"",[165,230,231],{"class":175},"), 1000",[165,233,234],{"class":171},"n",[165,236,237],{"class":175},", []]));\n",[165,239,241],{"class":167,"line":240},4,[165,242,244],{"class":243},"scIB-","\u002F\u002F \"c883646f678203e8c0\"\n",[165,246,248,251,254,257,259,261,264],{"class":167,"line":247},5,[165,249,250],{"class":175},"rlp.",[165,252,253],{"class":202},"decode",[165,255,256],{"class":175},"(hex.",[165,258,253],{"class":202},[165,260,225],{"class":175},[165,262,263],{"class":182},"\"c88363617483646f67\"",[165,265,266],{"class":175},"));\n",[165,268,270],{"class":167,"line":269},6,[165,271,272],{"class":243},"\u002F\u002F [Uint8Array [0x63, 0x61, 0x74], Uint8Array [0x64, 0x6f, 0x67]]\n",[151,274,275,277,278,281,282,285,286,288,289,292,293,296,297,299,300,303],{},[162,276,203],{}," takes a ",[162,279,280],{},"Uint8Array",", a ",[162,283,284],{},"bigint"," or a list of those, nested as deep as you like. A ",[162,287,284],{}," goes big-endian with no leading zero, so ",[162,290,291],{},"0n"," is no bytes at all and comes out as ",[162,294,295],{},"80",". ",[162,298,253],{}," hands back bytes and arrays. Was ",[162,301,302],{},"03e8"," a number or two bytes of text? RLP never says, so that call is yours.",[146,305,307],{"id":306},"why-does-decode-refuse-my-bytes","Why does decode refuse my bytes?",[151,309,310,311,313],{},"Because one value gets exactly one encoding. geth holds every node to that, and so does ",[162,312,253],{},":",[315,316,317,321,324,331,334],"ul",{},[318,319,320],"li",{},"a length written with a leading zero byte,",[318,322,323],{},"a long length header for a payload under 56 bytes,",[318,325,326,327,330],{},"one byte under ",[162,328,329],{},"0x80"," wrapped in a header it doesn't need,",[318,332,333],{},"an item that runs past the end of its list,",[318,335,336],{},"anything left over after the item.",[155,338,340],{"className":157,"code":339,"language":159,"meta":160,"style":160},"rlp.decode(hex.decode(\"8100\"));\n\u002F\u002F DecodeError: rlp: header at index 0 wraps a single byte under 0x80\n",[162,341,342,359],{"__ignoreMap":160},[165,343,344,346,348,350,352,354,357],{"class":167,"line":168},[165,345,250],{"class":175},[165,347,253],{"class":202},[165,349,256],{"class":175},[165,351,253],{"class":202},[165,353,225],{"class":175},[165,355,356],{"class":182},"\"8100\"",[165,358,266],{"class":175},[165,360,361],{"class":167,"line":189},[165,362,363],{"class":243},"\u002F\u002F DecodeError: rlp: header at index 0 wraps a single byte under 0x80\n",[151,365,366,367,370,371,374],{},"Each refusal is a ",[162,368,369],{},"DecodeError"," with the byte ",[162,372,373],{},"index",". Lenient sounds friendlier. It isn't. A lenient decoder would happily give you a digest for a transaction no node accepts.",[146,376,378],{"id":377},"a-signed-transaction-taken-apart","A signed transaction, taken apart",[151,380,381,382,385,386,388],{},"Here's a real type 2 transfer from mainnet. Drop the ",[162,383,384],{},"0x02"," type byte and decode the rest. Twelve fields come out, and the last three are the signature. Encode the first nine again behind ",[162,387,384],{},", hash it, and you hold the digest the sender signed.",[155,390,392],{"className":157,"code":391,"language":159,"meta":160,"style":160},"import { keccak256 } from \"@agntn\u002Fhashes\u002Fkeccak\";\nimport { hex, rlp, type RlpItem } from \"@agntn\u002Fencodings\";\n\nconst raw = hex.decode(\n  \"02f87301068405f5e100850299e45aba82520894f755aaace22fcfdcd4e300a3f26249000d95f1b28803b4860307b3664f80c080a03945159237a25c17a158194a90cf98a8cac028616751fc9b318a9aa2cdfd2beea05195431bd190114cb0562ca747c5784b0833369520916ee35ba8d2a78147d662\",\n);\nconst fields = rlp.decode(raw.subarray(1)) as RlpItem[];\nhex.encode(keccak256(Uint8Array.of(2, ...rlp.encode(fields.slice(0, 9)))));\n\u002F\u002F \"9b5cfa17969993d9a389747871fd5a80e82d829b276fa8245492806182b84ea6\"\n",[162,393,394,408,427,431,450,458,463,496,533],{"__ignoreMap":160},[165,395,396,398,401,403,406],{"class":167,"line":168},[165,397,172],{"class":171},[165,399,400],{"class":175}," { keccak256 } ",[165,402,179],{"class":171},[165,404,405],{"class":182}," \"@agntn\u002Fhashes\u002Fkeccak\"",[165,407,186],{"class":175},[165,409,410,412,415,418,421,423,425],{"class":167,"line":189},[165,411,172],{"class":171},[165,413,414],{"class":175}," { hex, rlp, ",[165,416,417],{"class":171},"type",[165,419,420],{"class":175}," RlpItem } ",[165,422,179],{"class":171},[165,424,183],{"class":182},[165,426,186],{"class":175},[165,428,429],{"class":167,"line":196},[165,430,193],{"emptyLinePlaceholder":192},[165,432,433,436,439,442,445,447],{"class":167,"line":240},[165,434,435],{"class":171},"const",[165,437,438],{"class":175}," raw ",[165,440,441],{"class":171},"=",[165,443,444],{"class":175}," hex.",[165,446,253],{"class":202},[165,448,449],{"class":175},"(\n",[165,451,452,455],{"class":167,"line":247},[165,453,454],{"class":182},"  \"02f87301068405f5e100850299e45aba82520894f755aaace22fcfdcd4e300a3f26249000d95f1b28803b4860307b3664f80c080a03945159237a25c17a158194a90cf98a8cac028616751fc9b318a9aa2cdfd2beea05195431bd190114cb0562ca747c5784b0833369520916ee35ba8d2a78147d662\"",[165,456,457],{"class":175},",\n",[165,459,460],{"class":167,"line":269},[165,461,462],{"class":175},");\n",[165,464,466,468,471,473,476,478,481,484,487,490,493],{"class":167,"line":465},7,[165,467,435],{"class":171},[165,469,470],{"class":175}," fields ",[165,472,441],{"class":171},[165,474,475],{"class":175}," rlp.",[165,477,253],{"class":202},[165,479,480],{"class":175},"(raw.",[165,482,483],{"class":202},"subarray",[165,485,486],{"class":175},"(1)) ",[165,488,489],{"class":171},"as",[165,491,492],{"class":202}," RlpItem",[165,494,495],{"class":175},"[];\n",[165,497,499,501,503,505,508,511,514,517,520,522,524,527,530],{"class":167,"line":498},8,[165,500,199],{"class":175},[165,502,203],{"class":202},[165,504,225],{"class":175},[165,506,507],{"class":202},"keccak256",[165,509,510],{"class":175},"(Uint8Array.",[165,512,513],{"class":202},"of",[165,515,516],{"class":175},"(2, ",[165,518,519],{"class":171},"...",[165,521,250],{"class":175},[165,523,203],{"class":202},[165,525,526],{"class":175},"(fields.",[165,528,529],{"class":202},"slice",[165,531,532],{"class":175},"(0, 9)))));\n",[165,534,536],{"class":167,"line":535},9,[165,537,538],{"class":243},"\u002F\u002F \"9b5cfa17969993d9a389747871fd5a80e82d829b276fa8245492806182b84ea6\"\n",[151,540,541,542,545,546,553],{},"Feed that digest and the signature to ",[162,543,544],{},"keys_message_recover"," from ",[547,548,552],"a",{"href":549,"rel":550},"https:\u002F\u002Fgithub.com\u002Fagntn\u002Fkeys",[551],"nofollow","@agntn\u002Fkeys"," and out comes the sender's public key. It was sitting in the transaction all along.",[151,555,556],{},"Deeply nested input is fine too. Neither direction recurses, so a list a hundred thousand levels deep costs memory, not your call stack.",[146,558,560],{"id":559},"where-it-lives","Where it lives",[151,562,563,564,567,568,571,572,575,576,579],{},"RLP gives back lists, and every encoding in the registry gives back bytes. So ",[162,565,566],{},"rlp"," sits outside it, like the ",[547,569,570],{"href":33},"code pages",", and ",[162,573,574],{},"identify"," never guesses it. The subpath is ",[162,577,578],{},"@agntn\u002Fencodings\u002Frlp",". No CLI command and no agent tool yet, just the two functions.",[581,582,583],"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 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)}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":160,"searchDepth":189,"depth":189,"links":585},[586,587,588,589],{"id":148,"depth":189,"text":149},{"id":306,"depth":189,"text":307},{"id":377,"depth":189,"text":378},{"id":559,"depth":189,"text":560},"Ethereum's Recursive Length Prefix. Bytes and nested lists in and out and decoded as strictly as geth does it","md",null,{},{"title":36,"description":590},"Ep8yHtQnMghapRXCxvbc-QGq8mit8JM4DmlNLwvLew4",[597,599],{"title":32,"path":33,"stem":34,"description":598,"children":-1},"EBCDIC, DOS 437, Latin-1 and Windows-1252. Read bytes as text in another character set or turn mojibake back into what it was",{"title":40,"path":41,"stem":42,"description":600,"children":-1},"The -----BEGIN PGP----- blocks from RFC 9580. Wrap bytes in armor or pull them back out with the label and headers intact",1794584247950]