ox 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (756) hide show
  1. package/Abi/package.json +6 -0
  2. package/Abi.ts +163 -0
  3. package/AbiConstructor/package.json +6 -0
  4. package/AbiConstructor.ts +413 -0
  5. package/AbiError/package.json +6 -0
  6. package/AbiError.ts +719 -0
  7. package/AbiEvent/package.json +6 -0
  8. package/AbiEvent.ts +1284 -0
  9. package/AbiFunction/package.json +6 -0
  10. package/AbiFunction.ts +813 -0
  11. package/AbiItem/package.json +6 -0
  12. package/AbiItem.ts +779 -0
  13. package/AbiParameters/package.json +6 -0
  14. package/AbiParameters.ts +712 -0
  15. package/AccessList/package.json +6 -0
  16. package/AccessList.ts +124 -0
  17. package/AccountProof/package.json +6 -0
  18. package/AccountProof.ts +35 -0
  19. package/Address/package.json +6 -0
  20. package/Address.ts +359 -0
  21. package/AesGcm/package.json +6 -0
  22. package/AesGcm.ts +220 -0
  23. package/Authorization/package.json +6 -0
  24. package/Authorization.ts +639 -0
  25. package/Base58/package.json +6 -0
  26. package/Base58.ts +180 -0
  27. package/Base64/package.json +6 -0
  28. package/Base64.ts +333 -0
  29. package/Blobs/package.json +6 -0
  30. package/Blobs.ts +982 -0
  31. package/Block/package.json +6 -0
  32. package/Block.ts +317 -0
  33. package/Bloom/package.json +6 -0
  34. package/Bloom.ts +80 -0
  35. package/Bls/package.json +6 -0
  36. package/Bls.ts +496 -0
  37. package/BlsPoint/package.json +6 -0
  38. package/BlsPoint.ts +232 -0
  39. package/Bytes/package.json +6 -0
  40. package/Bytes.ts +963 -0
  41. package/CHANGELOG.md +7 -0
  42. package/Caches/package.json +6 -0
  43. package/Caches.ts +21 -0
  44. package/ContractAddress/package.json +6 -0
  45. package/ContractAddress.ts +181 -0
  46. package/Ens/package.json +6 -0
  47. package/Ens.ts +116 -0
  48. package/Errors/package.json +6 -0
  49. package/Errors.ts +95 -0
  50. package/Fee/package.json +6 -0
  51. package/Fee.ts +57 -0
  52. package/Filter/package.json +6 -0
  53. package/Filter.ts +144 -0
  54. package/Hash/package.json +6 -0
  55. package/Hash.ts +210 -0
  56. package/HdKey/package.json +6 -0
  57. package/HdKey.ts +175 -0
  58. package/Hex/package.json +6 -0
  59. package/Hex.ts +1040 -0
  60. package/Json/package.json +6 -0
  61. package/Json.ts +84 -0
  62. package/Kzg/package.json +6 -0
  63. package/Kzg.ts +51 -0
  64. package/LICENSE +21 -0
  65. package/Log/package.json +6 -0
  66. package/Log.ts +248 -0
  67. package/Mnemonic/package.json +6 -0
  68. package/Mnemonic.ts +249 -0
  69. package/P256/package.json +6 -0
  70. package/P256.ts +230 -0
  71. package/PersonalMessage/package.json +6 -0
  72. package/PersonalMessage.ts +70 -0
  73. package/Provider/package.json +6 -0
  74. package/Provider.ts +354 -0
  75. package/PublicKey/package.json +6 -0
  76. package/PublicKey.ts +545 -0
  77. package/README.md +75 -26
  78. package/Rlp/package.json +6 -0
  79. package/Rlp.ts +390 -0
  80. package/RpcRequest/package.json +6 -0
  81. package/RpcRequest.ts +192 -0
  82. package/RpcResponse/package.json +6 -0
  83. package/RpcResponse.ts +389 -0
  84. package/RpcSchema/package.json +6 -0
  85. package/RpcSchema.ts +273 -0
  86. package/RpcTransport/package.json +6 -0
  87. package/RpcTransport.ts +198 -0
  88. package/Secp256k1/package.json +6 -0
  89. package/Secp256k1.ts +304 -0
  90. package/Signature/package.json +6 -0
  91. package/Signature.ts +909 -0
  92. package/Siwe/package.json +6 -0
  93. package/Siwe.ts +516 -0
  94. package/Solidity/package.json +6 -0
  95. package/Solidity.ts +109 -0
  96. package/Transaction/package.json +6 -0
  97. package/Transaction.ts +429 -0
  98. package/TransactionEnvelope/package.json +6 -0
  99. package/TransactionEnvelope.ts +205 -0
  100. package/TransactionEnvelopeEip1559/package.json +6 -0
  101. package/TransactionEnvelopeEip1559.ts +656 -0
  102. package/TransactionEnvelopeEip2930/package.json +6 -0
  103. package/TransactionEnvelopeEip2930.ts +624 -0
  104. package/TransactionEnvelopeEip4844/package.json +6 -0
  105. package/TransactionEnvelopeEip4844.ts +764 -0
  106. package/TransactionEnvelopeEip7702/package.json +6 -0
  107. package/TransactionEnvelopeEip7702.ts +639 -0
  108. package/TransactionEnvelopeLegacy/package.json +6 -0
  109. package/TransactionEnvelopeLegacy.ts +674 -0
  110. package/TransactionReceipt/package.json +6 -0
  111. package/TransactionReceipt.ts +341 -0
  112. package/TransactionRequest/package.json +6 -0
  113. package/TransactionRequest.ts +151 -0
  114. package/TypedData/package.json +6 -0
  115. package/TypedData.ts +931 -0
  116. package/ValidatorData/package.json +6 -0
  117. package/ValidatorData.ts +87 -0
  118. package/Value/package.json +6 -0
  119. package/Value.ts +242 -0
  120. package/WebAuthnP256/package.json +6 -0
  121. package/WebAuthnP256.ts +803 -0
  122. package/WebCryptoP256/package.json +6 -0
  123. package/WebCryptoP256.ts +190 -0
  124. package/Withdrawal/package.json +6 -0
  125. package/Withdrawal.ts +95 -0
  126. package/_cjs/Abi.js +17 -0
  127. package/_cjs/Abi.js.map +1 -0
  128. package/_cjs/AbiConstructor.js +42 -0
  129. package/_cjs/AbiConstructor.js.map +1 -0
  130. package/_cjs/AbiError.js +98 -0
  131. package/_cjs/AbiError.js.map +1 -0
  132. package/_cjs/AbiEvent.js +338 -0
  133. package/_cjs/AbiEvent.js.map +1 -0
  134. package/_cjs/AbiFunction.js +85 -0
  135. package/_cjs/AbiFunction.js.map +1 -0
  136. package/_cjs/AbiItem.js +180 -0
  137. package/_cjs/AbiItem.js.map +1 -0
  138. package/_cjs/AbiParameters.js +229 -0
  139. package/_cjs/AbiParameters.js.map +1 -0
  140. package/_cjs/AccessList.js +51 -0
  141. package/_cjs/AccessList.js.map +1 -0
  142. package/_cjs/AccountProof.js +3 -0
  143. package/_cjs/AccountProof.js.map +1 -0
  144. package/_cjs/Address.js +121 -0
  145. package/_cjs/Address.js.map +1 -0
  146. package/_cjs/AesGcm.js +55 -0
  147. package/_cjs/AesGcm.js.map +1 -0
  148. package/_cjs/Authorization.js +99 -0
  149. package/_cjs/Authorization.js.map +1 -0
  150. package/_cjs/Base58.js +52 -0
  151. package/_cjs/Base58.js.map +1 -0
  152. package/_cjs/Base64.js +76 -0
  153. package/_cjs/Base64.js.map +1 -0
  154. package/_cjs/Blobs.js +255 -0
  155. package/_cjs/Blobs.js.map +1 -0
  156. package/_cjs/Block.js +87 -0
  157. package/_cjs/Block.js.map +1 -0
  158. package/_cjs/Bloom.js +23 -0
  159. package/_cjs/Bloom.js.map +1 -0
  160. package/_cjs/Bls.js +79 -0
  161. package/_cjs/Bls.js.map +1 -0
  162. package/_cjs/BlsPoint.js +32 -0
  163. package/_cjs/BlsPoint.js.map +1 -0
  164. package/_cjs/Bytes.js +279 -0
  165. package/_cjs/Bytes.js.map +1 -0
  166. package/_cjs/Caches.js +14 -0
  167. package/_cjs/Caches.js.map +1 -0
  168. package/_cjs/ContractAddress.js +39 -0
  169. package/_cjs/ContractAddress.js.map +1 -0
  170. package/_cjs/Ens.js +37 -0
  171. package/_cjs/Ens.js.map +1 -0
  172. package/_cjs/Errors.js +99 -0
  173. package/_cjs/Errors.js.map +1 -0
  174. package/_cjs/Fee.js +3 -0
  175. package/_cjs/Fee.js.map +1 -0
  176. package/_cjs/Filter.js +43 -0
  177. package/_cjs/Filter.js.map +1 -0
  178. package/_cjs/Hash.js +40 -0
  179. package/_cjs/Hash.js.map +1 -0
  180. package/_cjs/HdKey.js +30 -0
  181. package/_cjs/HdKey.js.map +1 -0
  182. package/_cjs/Hex.js +324 -0
  183. package/_cjs/Hex.js.map +1 -0
  184. package/_cjs/Json.js +25 -0
  185. package/_cjs/Json.js.map +1 -0
  186. package/_cjs/Kzg.js +14 -0
  187. package/_cjs/Kzg.js.map +1 -0
  188. package/_cjs/Log.js +35 -0
  189. package/_cjs/Log.js.map +1 -0
  190. package/_cjs/Mnemonic.js +56 -0
  191. package/_cjs/Mnemonic.js.map +1 -0
  192. package/_cjs/P256.js +52 -0
  193. package/_cjs/P256.js.map +1 -0
  194. package/_cjs/PersonalMessage.js +16 -0
  195. package/_cjs/PersonalMessage.js.map +1 -0
  196. package/_cjs/Provider.js +90 -0
  197. package/_cjs/Provider.js.map +1 -0
  198. package/_cjs/PublicKey.js +192 -0
  199. package/_cjs/PublicKey.js.map +1 -0
  200. package/_cjs/Rlp.js +179 -0
  201. package/_cjs/Rlp.js.map +1 -0
  202. package/_cjs/RpcRequest.js +27 -0
  203. package/_cjs/RpcRequest.js.map +1 -0
  204. package/_cjs/RpcResponse.js +368 -0
  205. package/_cjs/RpcResponse.js.map +1 -0
  206. package/_cjs/RpcSchema.js +7 -0
  207. package/_cjs/RpcSchema.js.map +1 -0
  208. package/_cjs/RpcTransport.js +95 -0
  209. package/_cjs/RpcTransport.js.map +1 -0
  210. package/_cjs/Secp256k1.js +57 -0
  211. package/_cjs/Secp256k1.js.map +1 -0
  212. package/_cjs/Signature.js +305 -0
  213. package/_cjs/Signature.js.map +1 -0
  214. package/_cjs/Siwe.js +231 -0
  215. package/_cjs/Siwe.js.map +1 -0
  216. package/_cjs/Solidity.js +104 -0
  217. package/_cjs/Solidity.js.map +1 -0
  218. package/_cjs/Transaction.js +106 -0
  219. package/_cjs/Transaction.js.map +1 -0
  220. package/_cjs/TransactionEnvelope.js +80 -0
  221. package/_cjs/TransactionEnvelope.js.map +1 -0
  222. package/_cjs/TransactionEnvelopeEip1559.js +182 -0
  223. package/_cjs/TransactionEnvelopeEip1559.js.map +1 -0
  224. package/_cjs/TransactionEnvelopeEip2930.js +166 -0
  225. package/_cjs/TransactionEnvelopeEip2930.js.map +1 -0
  226. package/_cjs/TransactionEnvelopeEip4844.js +224 -0
  227. package/_cjs/TransactionEnvelopeEip4844.js.map +1 -0
  228. package/_cjs/TransactionEnvelopeEip7702.js +156 -0
  229. package/_cjs/TransactionEnvelopeEip7702.js.map +1 -0
  230. package/_cjs/TransactionEnvelopeLegacy.js +221 -0
  231. package/_cjs/TransactionEnvelopeLegacy.js.map +1 -0
  232. package/_cjs/TransactionReceipt.js +76 -0
  233. package/_cjs/TransactionReceipt.js.map +1 -0
  234. package/_cjs/TransactionRequest.js +51 -0
  235. package/_cjs/TransactionRequest.js.map +1 -0
  236. package/_cjs/TypedData.js +318 -0
  237. package/_cjs/TypedData.js.map +1 -0
  238. package/_cjs/ValidatorData.js +16 -0
  239. package/_cjs/ValidatorData.js.map +1 -0
  240. package/_cjs/Value.js +96 -0
  241. package/_cjs/Value.js.map +1 -0
  242. package/_cjs/WebAuthnP256.js +245 -0
  243. package/_cjs/WebAuthnP256.js.map +1 -0
  244. package/_cjs/WebCryptoP256.js +46 -0
  245. package/_cjs/WebCryptoP256.js.map +1 -0
  246. package/_cjs/Withdrawal.js +24 -0
  247. package/_cjs/Withdrawal.js.map +1 -0
  248. package/_cjs/index.js +66 -0
  249. package/_cjs/index.js.map +1 -0
  250. package/_cjs/internal/abi.js +11 -0
  251. package/_cjs/internal/abi.js.map +1 -0
  252. package/_cjs/internal/abiConstructor.js +3 -0
  253. package/_cjs/internal/abiConstructor.js.map +1 -0
  254. package/_cjs/internal/abiError.js +3 -0
  255. package/_cjs/internal/abiError.js.map +1 -0
  256. package/_cjs/internal/abiEvent.js +3 -0
  257. package/_cjs/internal/abiEvent.js.map +1 -0
  258. package/_cjs/internal/abiFunction.js +3 -0
  259. package/_cjs/internal/abiFunction.js.map +1 -0
  260. package/_cjs/internal/abiItem.js +110 -0
  261. package/_cjs/internal/abiItem.js.map +1 -0
  262. package/_cjs/internal/abiParameters.js +376 -0
  263. package/_cjs/internal/abiParameters.js.map +1 -0
  264. package/_cjs/internal/base58.js +89 -0
  265. package/_cjs/internal/base58.js.map +1 -0
  266. package/_cjs/internal/bytes.js +88 -0
  267. package/_cjs/internal/bytes.js.map +1 -0
  268. package/_cjs/internal/cursor.js +210 -0
  269. package/_cjs/internal/cursor.js.map +1 -0
  270. package/_cjs/internal/ens.js +43 -0
  271. package/_cjs/internal/ens.js.map +1 -0
  272. package/_cjs/internal/errors.js +28 -0
  273. package/_cjs/internal/errors.js.map +1 -0
  274. package/_cjs/internal/hdKey.js +19 -0
  275. package/_cjs/internal/hdKey.js.map +1 -0
  276. package/_cjs/internal/hex.js +66 -0
  277. package/_cjs/internal/hex.js.map +1 -0
  278. package/_cjs/internal/lru.js +34 -0
  279. package/_cjs/internal/lru.js.map +1 -0
  280. package/_cjs/internal/mnemonic/wordlists.js +24 -0
  281. package/_cjs/internal/mnemonic/wordlists.js.map +1 -0
  282. package/_cjs/internal/promise.js +49 -0
  283. package/_cjs/internal/promise.js.map +1 -0
  284. package/_cjs/internal/register.js +3 -0
  285. package/_cjs/internal/register.js.map +1 -0
  286. package/_cjs/internal/rpcSchema.js +3 -0
  287. package/_cjs/internal/rpcSchema.js.map +1 -0
  288. package/_cjs/internal/rpcSchemas/eth.js +3 -0
  289. package/_cjs/internal/rpcSchemas/eth.js.map +1 -0
  290. package/_cjs/internal/rpcSchemas/wallet.js +3 -0
  291. package/_cjs/internal/rpcSchemas/wallet.js.map +1 -0
  292. package/_cjs/internal/rpcTransport.js +19 -0
  293. package/_cjs/internal/rpcTransport.js.map +1 -0
  294. package/_cjs/internal/types.js +3 -0
  295. package/_cjs/internal/types.js.map +1 -0
  296. package/_cjs/internal/uid.js +17 -0
  297. package/_cjs/internal/uid.js.map +1 -0
  298. package/_cjs/internal/webauthn.js +28 -0
  299. package/_cjs/internal/webauthn.js.map +1 -0
  300. package/_cjs/package.json +1 -0
  301. package/_cjs/trusted-setups/Paths.js +6 -0
  302. package/_cjs/trusted-setups/Paths.js.map +1 -0
  303. package/_cjs/trusted-setups/index.js +5 -0
  304. package/_cjs/trusted-setups/index.js.map +1 -0
  305. package/_cjs/trusted-setups/internal/paths.js +11 -0
  306. package/_cjs/trusted-setups/internal/paths.js.map +1 -0
  307. package/_cjs/version.js +5 -0
  308. package/_cjs/version.js.map +1 -0
  309. package/_cjs/window/index.js +3 -0
  310. package/_cjs/window/index.js.map +1 -0
  311. package/_esm/Abi.js +19 -0
  312. package/_esm/Abi.js.map +1 -0
  313. package/_esm/AbiConstructor.js +102 -0
  314. package/_esm/AbiConstructor.js.map +1 -0
  315. package/_esm/AbiError.js +364 -0
  316. package/_esm/AbiError.js.map +1 -0
  317. package/_esm/AbiEvent.js +1038 -0
  318. package/_esm/AbiEvent.js.map +1 -0
  319. package/_esm/AbiFunction.js +549 -0
  320. package/_esm/AbiFunction.js.map +1 -0
  321. package/_esm/AbiItem.js +574 -0
  322. package/_esm/AbiItem.js.map +1 -0
  323. package/_esm/AbiParameters.js +543 -0
  324. package/_esm/AbiParameters.js.map +1 -0
  325. package/_esm/AccessList.js +105 -0
  326. package/_esm/AccessList.js.map +1 -0
  327. package/_esm/AccountProof.js +2 -0
  328. package/_esm/AccountProof.js.map +1 -0
  329. package/_esm/Address.js +268 -0
  330. package/_esm/Address.js.map +1 -0
  331. package/_esm/AesGcm.js +124 -0
  332. package/_esm/AesGcm.js.map +1 -0
  333. package/_esm/Authorization.js +441 -0
  334. package/_esm/Authorization.js.map +1 -0
  335. package/_esm/Base58.js +142 -0
  336. package/_esm/Base58.js.map +1 -0
  337. package/_esm/Base64.js +236 -0
  338. package/_esm/Base64.js.map +1 -0
  339. package/_esm/Blobs.js +624 -0
  340. package/_esm/Blobs.js.map +1 -0
  341. package/_esm/Block.js +177 -0
  342. package/_esm/Block.js.map +1 -0
  343. package/_esm/Bloom.js +57 -0
  344. package/_esm/Bloom.js.map +1 -0
  345. package/_esm/Bls.js +141 -0
  346. package/_esm/Bls.js.map +1 -0
  347. package/_esm/BlsPoint.js +59 -0
  348. package/_esm/BlsPoint.js.map +1 -0
  349. package/_esm/Bytes.js +719 -0
  350. package/_esm/Bytes.js.map +1 -0
  351. package/_esm/Caches.js +19 -0
  352. package/_esm/Caches.js.map +1 -0
  353. package/_esm/ContractAddress.js +110 -0
  354. package/_esm/ContractAddress.js.map +1 -0
  355. package/_esm/Ens.js +84 -0
  356. package/_esm/Ens.js.map +1 -0
  357. package/_esm/Errors.js +105 -0
  358. package/_esm/Errors.js.map +1 -0
  359. package/_esm/Fee.js +2 -0
  360. package/_esm/Fee.js.map +1 -0
  361. package/_esm/Filter.js +100 -0
  362. package/_esm/Filter.js.map +1 -0
  363. package/_esm/Hash.js +126 -0
  364. package/_esm/Hash.js.map +1 -0
  365. package/_esm/HdKey.js +107 -0
  366. package/_esm/HdKey.js.map +1 -0
  367. package/_esm/Hex.js +763 -0
  368. package/_esm/Hex.js.map +1 -0
  369. package/_esm/Json.js +62 -0
  370. package/_esm/Json.js.map +1 -0
  371. package/_esm/Kzg.js +30 -0
  372. package/_esm/Kzg.js.map +1 -0
  373. package/_esm/Log.js +181 -0
  374. package/_esm/Log.js.map +1 -0
  375. package/_esm/Mnemonic.js +154 -0
  376. package/_esm/Mnemonic.js.map +1 -0
  377. package/_esm/P256.js +131 -0
  378. package/_esm/P256.js.map +1 -0
  379. package/_esm/PersonalMessage.js +46 -0
  380. package/_esm/PersonalMessage.js.map +1 -0
  381. package/_esm/Provider.js +122 -0
  382. package/_esm/Provider.js.map +1 -0
  383. package/_esm/PublicKey.js +395 -0
  384. package/_esm/PublicKey.js.map +1 -0
  385. package/_esm/Rlp.js +267 -0
  386. package/_esm/Rlp.js.map +1 -0
  387. package/_esm/RpcRequest.js +131 -0
  388. package/_esm/RpcRequest.js.map +1 -0
  389. package/_esm/RpcResponse.js +457 -0
  390. package/_esm/RpcResponse.js.map +1 -0
  391. package/_esm/RpcSchema.js +46 -0
  392. package/_esm/RpcSchema.js.map +1 -0
  393. package/_esm/RpcTransport.js +110 -0
  394. package/_esm/RpcTransport.js.map +1 -0
  395. package/_esm/Secp256k1.js +173 -0
  396. package/_esm/Secp256k1.js.map +1 -0
  397. package/_esm/Signature.js +696 -0
  398. package/_esm/Signature.js.map +1 -0
  399. package/_esm/Siwe.js +374 -0
  400. package/_esm/Siwe.js.map +1 -0
  401. package/_esm/Solidity.js +104 -0
  402. package/_esm/Solidity.js.map +1 -0
  403. package/_esm/Transaction.js +176 -0
  404. package/_esm/Transaction.js.map +1 -0
  405. package/_esm/TransactionEnvelope.js +139 -0
  406. package/_esm/TransactionEnvelope.js.map +1 -0
  407. package/_esm/TransactionEnvelopeEip1559.js +455 -0
  408. package/_esm/TransactionEnvelopeEip1559.js.map +1 -0
  409. package/_esm/TransactionEnvelopeEip2930.js +439 -0
  410. package/_esm/TransactionEnvelopeEip2930.js.map +1 -0
  411. package/_esm/TransactionEnvelopeEip4844.js +542 -0
  412. package/_esm/TransactionEnvelopeEip4844.js.map +1 -0
  413. package/_esm/TransactionEnvelopeEip7702.js +442 -0
  414. package/_esm/TransactionEnvelopeEip7702.js.map +1 -0
  415. package/_esm/TransactionEnvelopeLegacy.js +495 -0
  416. package/_esm/TransactionEnvelopeLegacy.js.map +1 -0
  417. package/_esm/TransactionReceipt.js +229 -0
  418. package/_esm/TransactionReceipt.js.map +1 -0
  419. package/_esm/TransactionRequest.js +89 -0
  420. package/_esm/TransactionRequest.js.map +1 -0
  421. package/_esm/TypedData.js +635 -0
  422. package/_esm/TypedData.js.map +1 -0
  423. package/_esm/ValidatorData.js +52 -0
  424. package/_esm/ValidatorData.js.map +1 -0
  425. package/_esm/Value.js +196 -0
  426. package/_esm/Value.js.map +1 -0
  427. package/_esm/WebAuthnP256.js +471 -0
  428. package/_esm/WebAuthnP256.js.map +1 -0
  429. package/_esm/WebCryptoP256.js +116 -0
  430. package/_esm/WebCryptoP256.js.map +1 -0
  431. package/_esm/Withdrawal.js +72 -0
  432. package/_esm/Withdrawal.js.map +1 -0
  433. package/_esm/index.js +3366 -0
  434. package/_esm/index.js.map +1 -0
  435. package/_esm/internal/abi.js +9 -0
  436. package/_esm/internal/abi.js.map +1 -0
  437. package/_esm/internal/abiConstructor.js +2 -0
  438. package/_esm/internal/abiConstructor.js.map +1 -0
  439. package/_esm/internal/abiError.js +2 -0
  440. package/_esm/internal/abiError.js.map +1 -0
  441. package/_esm/internal/abiEvent.js +2 -0
  442. package/_esm/internal/abiEvent.js.map +1 -0
  443. package/_esm/internal/abiFunction.js +2 -0
  444. package/_esm/internal/abiFunction.js.map +1 -0
  445. package/_esm/internal/abiItem.js +122 -0
  446. package/_esm/internal/abiItem.js.map +1 -0
  447. package/_esm/internal/abiParameters.js +419 -0
  448. package/_esm/internal/abiParameters.js.map +1 -0
  449. package/_esm/internal/base58.js +91 -0
  450. package/_esm/internal/base58.js.map +1 -0
  451. package/_esm/internal/bytes.js +86 -0
  452. package/_esm/internal/bytes.js.map +1 -0
  453. package/_esm/internal/cursor.js +207 -0
  454. package/_esm/internal/cursor.js.map +1 -0
  455. package/_esm/internal/ens.js +47 -0
  456. package/_esm/internal/ens.js.map +1 -0
  457. package/_esm/internal/errors.js +26 -0
  458. package/_esm/internal/errors.js.map +1 -0
  459. package/_esm/internal/hdKey.js +17 -0
  460. package/_esm/internal/hdKey.js.map +1 -0
  461. package/_esm/internal/hex.js +64 -0
  462. package/_esm/internal/hex.js.map +1 -0
  463. package/_esm/internal/lru.js +36 -0
  464. package/_esm/internal/lru.js.map +1 -0
  465. package/_esm/internal/mnemonic/wordlists.js +11 -0
  466. package/_esm/internal/mnemonic/wordlists.js.map +1 -0
  467. package/_esm/internal/promise.js +52 -0
  468. package/_esm/internal/promise.js.map +1 -0
  469. package/_esm/internal/register.js +2 -0
  470. package/_esm/internal/register.js.map +1 -0
  471. package/_esm/internal/rpcSchema.js +2 -0
  472. package/_esm/internal/rpcSchema.js.map +1 -0
  473. package/_esm/internal/rpcSchemas/eth.js +2 -0
  474. package/_esm/internal/rpcSchemas/eth.js.map +1 -0
  475. package/_esm/internal/rpcSchemas/wallet.js +2 -0
  476. package/_esm/internal/rpcSchemas/wallet.js.map +1 -0
  477. package/_esm/internal/rpcTransport.js +20 -0
  478. package/_esm/internal/rpcTransport.js.map +1 -0
  479. package/_esm/internal/types.js +2 -0
  480. package/_esm/internal/types.js.map +1 -0
  481. package/_esm/internal/uid.js +15 -0
  482. package/_esm/internal/uid.js.map +1 -0
  483. package/_esm/internal/webauthn.js +35 -0
  484. package/_esm/internal/webauthn.js.map +1 -0
  485. package/_esm/package.json +1 -0
  486. package/_esm/trusted-setups/Paths.js +3 -0
  487. package/_esm/trusted-setups/Paths.js.map +1 -0
  488. package/_esm/trusted-setups/index.js +2 -0
  489. package/_esm/trusted-setups/index.js.map +1 -0
  490. package/_esm/trusted-setups/internal/paths.js +12 -0
  491. package/_esm/trusted-setups/internal/paths.js.map +1 -0
  492. package/_esm/version.js +3 -0
  493. package/_esm/version.js.map +1 -0
  494. package/_esm/window/index.js +2 -0
  495. package/_esm/window/index.js.map +1 -0
  496. package/_test/Abi.test-d/package.json +6 -0
  497. package/_test/AbiConstructor.test-d/package.json +6 -0
  498. package/_test/AbiError.test-d/package.json +6 -0
  499. package/_test/AbiEvent.snap-d/package.json +6 -0
  500. package/_test/AbiEvent.snap-d.ts +329 -0
  501. package/_test/AbiFunction.snap-d/package.json +6 -0
  502. package/_test/AbiFunction.snap-d.ts +262 -0
  503. package/_test/AbiItem.snap-d/package.json +6 -0
  504. package/_test/AbiItem.snap-d.ts +131 -0
  505. package/_test/AbiParameters.bench/package.json +6 -0
  506. package/_test/AbiParameters.snap-d/package.json +6 -0
  507. package/_test/AbiParameters.snap-d.ts +66 -0
  508. package/_test/Address.bench/package.json +6 -0
  509. package/_test/Base58.bench/package.json +6 -0
  510. package/_test/Hex.bench/package.json +6 -0
  511. package/_test/Hex.test-d/package.json +6 -0
  512. package/_test/PublicKey.test-d/package.json +6 -0
  513. package/_test/Rlp.bench/package.json +6 -0
  514. package/_test/Rlp.test-d/package.json +6 -0
  515. package/_test/Signature.snap-d/package.json +6 -0
  516. package/_test/Signature.snap-d.ts +96 -0
  517. package/_test/TransactionEnvelopeEip1559.test-d/package.json +6 -0
  518. package/_test/TransactionEnvelopeEip2930.test-d/package.json +6 -0
  519. package/_test/TransactionEnvelopeEip4844.test-d/package.json +6 -0
  520. package/_test/TransactionEnvelopeEip7702.test-d/package.json +6 -0
  521. package/_test/TransactionEnvelopeLegacy.test-d/package.json +6 -0
  522. package/_test/TypedData.test-d/package.json +6 -0
  523. package/_types/Abi.d.ts +137 -0
  524. package/_types/Abi.d.ts.map +1 -0
  525. package/_types/AbiConstructor.d.ts +305 -0
  526. package/_types/AbiConstructor.d.ts.map +1 -0
  527. package/_types/AbiError.d.ts +522 -0
  528. package/_types/AbiError.d.ts.map +1 -0
  529. package/_types/AbiEvent.d.ts +892 -0
  530. package/_types/AbiEvent.d.ts.map +1 -0
  531. package/_types/AbiFunction.d.ts +602 -0
  532. package/_types/AbiFunction.d.ts.map +1 -0
  533. package/_types/AbiItem.d.ts +544 -0
  534. package/_types/AbiItem.d.ts.map +1 -0
  535. package/_types/AbiParameters.d.ts +466 -0
  536. package/_types/AbiParameters.d.ts.map +1 -0
  537. package/_types/AccessList.d.ts +83 -0
  538. package/_types/AccessList.d.ts.map +1 -0
  539. package/_types/AccountProof.d.ts +32 -0
  540. package/_types/AccountProof.d.ts.map +1 -0
  541. package/_types/Address.d.ts +244 -0
  542. package/_types/Address.d.ts.map +1 -0
  543. package/_types/AesGcm.d.ts +116 -0
  544. package/_types/AesGcm.d.ts.map +1 -0
  545. package/_types/Authorization.d.ts +461 -0
  546. package/_types/Authorization.d.ts.map +1 -0
  547. package/_types/Base58.d.ts +131 -0
  548. package/_types/Base58.d.ts.map +1 -0
  549. package/_types/Base64.d.ts +244 -0
  550. package/_types/Base64.d.ts.map +1 -0
  551. package/_types/Blobs.d.ts +556 -0
  552. package/_types/Blobs.d.ts.map +1 -0
  553. package/_types/Block.d.ts +190 -0
  554. package/_types/Block.d.ts.map +1 -0
  555. package/_types/Bloom.d.ts +54 -0
  556. package/_types/Bloom.d.ts.map +1 -0
  557. package/_types/Bls.d.ts +365 -0
  558. package/_types/Bls.d.ts.map +1 -0
  559. package/_types/BlsPoint.d.ts +187 -0
  560. package/_types/BlsPoint.d.ts.map +1 -0
  561. package/_types/Bytes.d.ts +674 -0
  562. package/_types/Bytes.d.ts.map +1 -0
  563. package/_types/Caches.d.ts +13 -0
  564. package/_types/Caches.d.ts.map +1 -0
  565. package/_types/ContractAddress.d.ts +115 -0
  566. package/_types/ContractAddress.d.ts.map +1 -0
  567. package/_types/Ens.d.ts +72 -0
  568. package/_types/Ens.d.ts.map +1 -0
  569. package/_types/Errors.d.ts +33 -0
  570. package/_types/Errors.d.ts.map +1 -0
  571. package/_types/Fee.d.ts +41 -0
  572. package/_types/Fee.d.ts.map +1 -0
  573. package/_types/Filter.d.ts +100 -0
  574. package/_types/Filter.d.ts.map +1 -0
  575. package/_types/Hash.d.ts +135 -0
  576. package/_types/Hash.d.ts.map +1 -0
  577. package/_types/HdKey.d.ts +146 -0
  578. package/_types/HdKey.d.ts.map +1 -0
  579. package/_types/Hex.d.ts +711 -0
  580. package/_types/Hex.d.ts.map +1 -0
  581. package/_types/Json.d.ts +53 -0
  582. package/_types/Json.d.ts.map +1 -0
  583. package/_types/Kzg.d.ts +42 -0
  584. package/_types/Kzg.d.ts.map +1 -0
  585. package/_types/Log.d.ts +194 -0
  586. package/_types/Log.d.ts.map +1 -0
  587. package/_types/Mnemonic.d.ts +176 -0
  588. package/_types/Mnemonic.d.ts.map +1 -0
  589. package/_types/P256.d.ts +207 -0
  590. package/_types/P256.d.ts.map +1 -0
  591. package/_types/PersonalMessage.d.ts +49 -0
  592. package/_types/PersonalMessage.d.ts.map +1 -0
  593. package/_types/Provider.d.ts +268 -0
  594. package/_types/Provider.d.ts.map +1 -0
  595. package/_types/PublicKey.d.ts +327 -0
  596. package/_types/PublicKey.d.ts.map +1 -0
  597. package/_types/Rlp.d.ts +153 -0
  598. package/_types/Rlp.d.ts.map +1 -0
  599. package/_types/RpcRequest.d.ts +144 -0
  600. package/_types/RpcRequest.d.ts.map +1 -0
  601. package/_types/RpcResponse.d.ts +266 -0
  602. package/_types/RpcResponse.d.ts.map +1 -0
  603. package/_types/RpcSchema.d.ts +248 -0
  604. package/_types/RpcSchema.d.ts.map +1 -0
  605. package/_types/RpcTransport.d.ts +65 -0
  606. package/_types/RpcTransport.d.ts.map +1 -0
  607. package/_types/Secp256k1.d.ts +277 -0
  608. package/_types/Secp256k1.d.ts.map +1 -0
  609. package/_types/Signature.d.ts +601 -0
  610. package/_types/Signature.d.ts.map +1 -0
  611. package/_types/Siwe.d.ts +249 -0
  612. package/_types/Siwe.d.ts.map +1 -0
  613. package/_types/Solidity.d.ts +100 -0
  614. package/_types/Solidity.d.ts.map +1 -0
  615. package/_types/Transaction.d.ts +235 -0
  616. package/_types/Transaction.d.ts.map +1 -0
  617. package/_types/TransactionEnvelope.d.ts +141 -0
  618. package/_types/TransactionEnvelope.d.ts.map +1 -0
  619. package/_types/TransactionEnvelopeEip1559.d.ts +367 -0
  620. package/_types/TransactionEnvelopeEip1559.d.ts.map +1 -0
  621. package/_types/TransactionEnvelopeEip2930.d.ts +364 -0
  622. package/_types/TransactionEnvelopeEip2930.d.ts.map +1 -0
  623. package/_types/TransactionEnvelopeEip4844.d.ts +419 -0
  624. package/_types/TransactionEnvelopeEip4844.d.ts.map +1 -0
  625. package/_types/TransactionEnvelopeEip7702.d.ts +377 -0
  626. package/_types/TransactionEnvelopeEip7702.d.ts.map +1 -0
  627. package/_types/TransactionEnvelopeLegacy.d.ts +358 -0
  628. package/_types/TransactionEnvelopeLegacy.d.ts.map +1 -0
  629. package/_types/TransactionReceipt.d.ts +271 -0
  630. package/_types/TransactionReceipt.d.ts.map +1 -0
  631. package/_types/TransactionRequest.d.ts +92 -0
  632. package/_types/TransactionRequest.d.ts.map +1 -0
  633. package/_types/TypedData.d.ts +496 -0
  634. package/_types/TypedData.d.ts.map +1 -0
  635. package/_types/ValidatorData.d.ts +64 -0
  636. package/_types/ValidatorData.d.ts.map +1 -0
  637. package/_types/Value.d.ts +159 -0
  638. package/_types/Value.d.ts.map +1 -0
  639. package/_types/WebAuthnP256.d.ts +445 -0
  640. package/_types/WebAuthnP256.d.ts.map +1 -0
  641. package/_types/WebCryptoP256.d.ts +119 -0
  642. package/_types/WebCryptoP256.d.ts.map +1 -0
  643. package/_types/Withdrawal.d.ts +74 -0
  644. package/_types/Withdrawal.d.ts.map +1 -0
  645. package/_types/index.d.ts +3367 -0
  646. package/_types/index.d.ts.map +1 -0
  647. package/_types/internal/abi.d.ts +4 -0
  648. package/_types/internal/abi.d.ts.map +1 -0
  649. package/_types/internal/abiConstructor.d.ts +11 -0
  650. package/_types/internal/abiConstructor.d.ts.map +1 -0
  651. package/_types/internal/abiError.d.ts +11 -0
  652. package/_types/internal/abiError.d.ts.map +1 -0
  653. package/_types/internal/abiEvent.d.ts +60 -0
  654. package/_types/internal/abiEvent.d.ts.map +1 -0
  655. package/_types/internal/abiFunction.d.ts +11 -0
  656. package/_types/internal/abiFunction.d.ts.map +1 -0
  657. package/_types/internal/abiItem.d.ts +100 -0
  658. package/_types/internal/abiItem.d.ts.map +1 -0
  659. package/_types/internal/abiParameters.d.ts +169 -0
  660. package/_types/internal/abiParameters.d.ts.map +1 -0
  661. package/_types/internal/base58.d.ts +17 -0
  662. package/_types/internal/base58.d.ts.map +1 -0
  663. package/_types/internal/bytes.d.ts +52 -0
  664. package/_types/internal/bytes.d.ts.map +1 -0
  665. package/_types/internal/cursor.d.ts +70 -0
  666. package/_types/internal/cursor.d.ts.map +1 -0
  667. package/_types/internal/ens.d.ts +23 -0
  668. package/_types/internal/ens.d.ts.map +1 -0
  669. package/_types/internal/errors.d.ts +7 -0
  670. package/_types/internal/errors.d.ts.map +1 -0
  671. package/_types/internal/hdKey.d.ts +10 -0
  672. package/_types/internal/hdKey.d.ts.map +1 -0
  673. package/_types/internal/hex.d.ts +39 -0
  674. package/_types/internal/hex.d.ts.map +1 -0
  675. package/_types/internal/lru.d.ts +13 -0
  676. package/_types/internal/lru.d.ts.map +1 -0
  677. package/_types/internal/mnemonic/wordlists.d.ts +11 -0
  678. package/_types/internal/mnemonic/wordlists.d.ts.map +1 -0
  679. package/_types/internal/promise.d.ts +27 -0
  680. package/_types/internal/promise.d.ts.map +1 -0
  681. package/_types/internal/register.d.ts +13 -0
  682. package/_types/internal/register.d.ts.map +1 -0
  683. package/_types/internal/rpcSchema.d.ts +12 -0
  684. package/_types/internal/rpcSchema.d.ts.map +1 -0
  685. package/_types/internal/rpcSchemas/eth.d.ts +718 -0
  686. package/_types/internal/rpcSchemas/eth.d.ts.map +1 -0
  687. package/_types/internal/rpcSchemas/wallet.d.ts +416 -0
  688. package/_types/internal/rpcSchemas/wallet.d.ts.map +1 -0
  689. package/_types/internal/rpcTransport.d.ts +38 -0
  690. package/_types/internal/rpcTransport.d.ts.map +1 -0
  691. package/_types/internal/types.d.ts +284 -0
  692. package/_types/internal/types.d.ts.map +1 -0
  693. package/_types/internal/uid.d.ts +3 -0
  694. package/_types/internal/uid.d.ts.map +1 -0
  695. package/_types/internal/webauthn.d.ts +127 -0
  696. package/_types/internal/webauthn.d.ts.map +1 -0
  697. package/_types/trusted-setups/Paths.d.ts +2 -0
  698. package/_types/trusted-setups/Paths.d.ts.map +1 -0
  699. package/_types/trusted-setups/index.d.ts +2 -0
  700. package/_types/trusted-setups/index.d.ts.map +1 -0
  701. package/_types/trusted-setups/internal/paths.d.ts +3 -0
  702. package/_types/trusted-setups/internal/paths.d.ts.map +1 -0
  703. package/_types/version.d.ts +3 -0
  704. package/_types/version.d.ts.map +1 -0
  705. package/_types/window/index.d.ts +7 -0
  706. package/_types/window/index.d.ts.map +1 -0
  707. package/index.ts +3427 -0
  708. package/internal/abi.ts +11 -0
  709. package/internal/abiConstructor.ts +32 -0
  710. package/internal/abiError.ts +30 -0
  711. package/internal/abiEvent.ts +154 -0
  712. package/internal/abiFunction.ts +32 -0
  713. package/internal/abiItem.ts +593 -0
  714. package/internal/abiParameters.ts +741 -0
  715. package/internal/base58.ts +106 -0
  716. package/internal/bytes.ts +152 -0
  717. package/internal/cursor.ts +252 -0
  718. package/internal/ens.ts +64 -0
  719. package/internal/errors.ts +26 -0
  720. package/internal/hdKey.ts +25 -0
  721. package/internal/hex.ts +123 -0
  722. package/internal/lru.ts +34 -0
  723. package/internal/mnemonic/wordlists.ts +10 -0
  724. package/internal/promise.ts +66 -0
  725. package/internal/register.ts +15 -0
  726. package/internal/rpcSchema.ts +20 -0
  727. package/internal/rpcSchemas/eth.ts +727 -0
  728. package/internal/rpcSchemas/wallet.ts +428 -0
  729. package/internal/rpcTransport.ts +74 -0
  730. package/internal/types.ts +414 -0
  731. package/internal/uid.ts +15 -0
  732. package/internal/webauthn.ts +198 -0
  733. package/package.json +500 -20
  734. package/trusted-setups/Paths/package.json +6 -0
  735. package/trusted-setups/Paths.ts +3 -0
  736. package/trusted-setups/index.ts +1 -0
  737. package/trusted-setups/internal/paths.ts +13 -0
  738. package/trusted-setups/internal/setups/mainnet.json +8265 -0
  739. package/trusted-setups/internal/setups/mainnet.txt +4163 -0
  740. package/trusted-setups/package.json +6 -0
  741. package/tsdoc.json +4 -0
  742. package/version/package.json +6 -0
  743. package/version.ts +2 -0
  744. package/window/index.ts +7 -0
  745. package/window/package.json +6 -0
  746. package/cl/ansiesc.js +0 -25
  747. package/cl/deps.js +0 -7
  748. package/cl/editor.js +0 -141
  749. package/cl/index.html +0 -19
  750. package/cl/ox.js +0 -44
  751. package/cl/socket.io.js +0 -1922
  752. package/cl/style.css +0 -37
  753. package/srv/deps.js +0 -88
  754. package/srv/httpSrv.js +0 -82
  755. package/srv/ox.js +0 -44
  756. package/srv/remoteXtermReq.js +0 -70
package/index.ts ADDED
@@ -0,0 +1,3427 @@
1
+ /**
2
+ * Utilities & types for working with [Application Binary Interfaces (ABIs)](https://docs.soliditylang.org/en/latest/abi-spec.html)
3
+ *
4
+ * :::note
5
+ *
6
+ * If you are looking for ABI parameter **encoding** & **decoding** functions, see {@link ox#AbiParameters.(encode:function)} & {@link ox#AbiParameters.(decode:function)}.
7
+ *
8
+ * :::
9
+ *
10
+ * @example
11
+ * ### Instantiating JSON ABIs
12
+ *
13
+ * An {@link ox#Abi.Abi} can be instantiated from a JSON ABI by using {@link ox#Abi.(from:function)}:
14
+ *
15
+ * ```ts twoslash
16
+ * import { Abi } from 'ox'
17
+ *
18
+ * const abi = Abi.from([{
19
+ * type: 'function',
20
+ * name: 'approve',
21
+ * stateMutability: 'nonpayable',
22
+ * inputs: [
23
+ * {
24
+ * name: 'spender',
25
+ * type: 'address',
26
+ * },
27
+ * {
28
+ * name: 'amount',
29
+ * type: 'uint256',
30
+ * },
31
+ * ],
32
+ * outputs: [{ type: 'bool' }],
33
+ * }])
34
+ *
35
+ * abi
36
+ * //^?
37
+ *
38
+ *
39
+ *
40
+ *
41
+ *
42
+ *
43
+ *
44
+ *
45
+ *
46
+ *
47
+ *
48
+ *
49
+ *
50
+ *
51
+ *
52
+ * ```
53
+ *
54
+ * @example
55
+ * ### Instantiating Human Readable ABIs
56
+ *
57
+ * An {@link ox#Abi.Abi} can be instantiated from a human-readable ABI by using {@link ox#Abi.(from:function)}:
58
+ *
59
+ * ```ts twoslash
60
+ * import { Abi } from 'ox'
61
+ *
62
+ * const abi = Abi.from([
63
+ * 'function approve(address spender, uint256 amount) returns (bool)',
64
+ * ])
65
+ *
66
+ * abi
67
+ * //^?
68
+ *
69
+ *
70
+ *
71
+ *
72
+ *
73
+ *
74
+ *
75
+ *
76
+ *
77
+ *
78
+ *
79
+ *
80
+ * ```
81
+ *
82
+ * @example
83
+ * ### Formatting ABIs
84
+ *
85
+ * An {@link ox#Abi.Abi} can be formatted into a human-readable ABI by using {@link ox#Abi.(format:function)}:
86
+ *
87
+ * ```ts twoslash
88
+ * import { Abi } from 'ox'
89
+ * const abi = Abi.from([{
90
+ * type: 'function',
91
+ * name: 'approve',
92
+ * stateMutability: 'nonpayable',
93
+ * inputs: [
94
+ * {
95
+ * name: 'spender',
96
+ * type: 'address',
97
+ * },
98
+ * {
99
+ * name: 'amount',
100
+ * type: 'uint256',
101
+ * },
102
+ * ],
103
+ * outputs: [{ type: 'bool' }],
104
+ * }])
105
+ * //---cut---
106
+ * const formatted = Abi.format(abi)
107
+ *
108
+ * formatted
109
+ * // ^?
110
+ *
111
+ *
112
+ * ```
113
+ *
114
+ * @category ABI
115
+ */
116
+ export * as Abi from './Abi.js'
117
+
118
+ /**
119
+ * Utilities & types for working with [Constructors](https://docs.soliditylang.org/en/latest/abi-spec.html#json) on ABIs.
120
+ *
121
+ * `AbiConstructor` is a sub-type of [`AbiItem`](/api/AbiItem).
122
+ *
123
+ * @example
124
+ * ### Instantiating via JSON ABI
125
+ *
126
+ * An `AbiConstructor` can be instantiated from a JSON ABI by using {@link ox#AbiConstructor.(fromAbi:function)}:
127
+ *
128
+ * ```ts twoslash
129
+ * import { Abi, AbiConstructor } from 'ox'
130
+ *
131
+ * const abi = Abi.from([
132
+ * 'constructor(address owner)',
133
+ * 'function foo()',
134
+ * 'event Transfer(address owner, address to, uint256 tokenId)',
135
+ * 'function bar(string a) returns (uint256 x)',
136
+ * ])
137
+ *
138
+ * const item = AbiConstructor.fromAbi(abi) // [!code focus]
139
+ * // ^?
140
+ *
141
+ *
142
+ *
143
+ *
144
+ *
145
+ *
146
+ *
147
+ *
148
+ *
149
+ * ```
150
+ *
151
+ * @example
152
+ * ### Instantiating via Human-Readable ABI Item
153
+ *
154
+ * An `AbiConstructor` can be instantiated from a human-readable ABI by using {@link ox#AbiConstructor.(from:function)}:
155
+ *
156
+ * ```ts twoslash
157
+ * import { AbiConstructor } from 'ox'
158
+ *
159
+ * const constructor = AbiConstructor.from('constructor(address owner)')
160
+ *
161
+ * constructor
162
+ * //^?
163
+ *
164
+ *
165
+ *
166
+ *
167
+ *
168
+ *
169
+ *
170
+ *
171
+ *
172
+ * ```
173
+ *
174
+ * @example
175
+ * ### Encoding to Deploy Data
176
+ *
177
+ * Constructor arguments can be ABI-encoded using {@link ox#AbiConstructor.(encode:function)} (with bytecode) into deploy data. This data can then be passed to a transaction to deploy a contract.
178
+ *
179
+ * ```ts twoslash
180
+ * import { AbiConstructor } from 'ox'
181
+ *
182
+ * const constructor = AbiConstructor.from('constructor(address, uint256)')
183
+ *
184
+ * const data = AbiConstructor.encode(constructor, { // [!code focus]
185
+ * bytecode: '0x...', // [!code focus]
186
+ * args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 123n], // [!code focus]
187
+ * }) // [!code focus]
188
+ * ```
189
+ *
190
+ * @category ABI
191
+ */
192
+ export * as AbiConstructor from './AbiConstructor.js'
193
+
194
+ /**
195
+ * Utilities & types for working with [Errors](https://docs.soliditylang.org/en/latest/abi-spec.html#json) on ABIs.
196
+ *
197
+ * `AbiError` is a sub-type of [`AbiItem`](/api/AbiItem).
198
+ *
199
+ * @example
200
+ * ### Instantiating via JSON ABI
201
+ *
202
+ * An `AbiError` can be instantiated from a JSON ABI by using {@link ox#AbiError.(fromAbi:function)}:
203
+ *
204
+ * ```ts twoslash
205
+ * import { Abi, AbiError } from 'ox'
206
+ *
207
+ * const abi = Abi.from([
208
+ * 'function foo()',
209
+ * 'error BadSignatureV(uint8 v)',
210
+ * 'function bar(string a) returns (uint256 x)',
211
+ * ])
212
+ *
213
+ * const item = AbiError.fromAbi(abi, 'BadSignatureV') // [!code focus]
214
+ * // ^?
215
+ *
216
+ *
217
+ *
218
+ *
219
+ *
220
+ *
221
+ * ```
222
+ *
223
+ * @example
224
+ * ### Instantiating via Human-Readable ABI Item
225
+ *
226
+ * An `AbiError` can be instantiated from a human-readable ABI by using {@link ox#AbiError.(from:function)}:
227
+ *
228
+ * ```ts twoslash
229
+ * import { AbiError } from 'ox'
230
+ *
231
+ * const error = AbiError.from('error BadSignatureV(uint8 v)')
232
+ *
233
+ * error
234
+ * //^?
235
+ *
236
+ *
237
+ *
238
+ *
239
+ *
240
+ *
241
+ *
242
+ *
243
+ *
244
+ * ```
245
+ *
246
+ * @example
247
+ * ### Decoding Error Data
248
+ *
249
+ * Error data can be ABI-decoded using the {@link ox#AbiError.(decode:function)} function.
250
+ *
251
+ * ```ts twoslash
252
+ * // @noErrors
253
+ * import { Abi, AbiError } from 'ox'
254
+ *
255
+ * const abi = Abi.from([...])
256
+ * const error = AbiError.fromAbi(abi, 'InvalidSignature')
257
+ *
258
+ * const value = AbiError.decode(error, '0xecde634900000000000000000000000000000000000000000000000000000000000001a400000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001') // [!code focus]
259
+ * // @log: [420n, 69n, 1]
260
+ * ```
261
+ *
262
+ * @category ABI
263
+ */
264
+ export * as AbiError from './AbiError.js'
265
+
266
+ /**
267
+ * Utilities & types for working with [Events](https://docs.soliditylang.org/en/latest/abi-spec.html#json) on ABIs.
268
+ *
269
+ * `AbiEvent` is a sub-type of [`AbiItem`](/api/AbiItem).
270
+ *
271
+ * @example
272
+ * ### Instantiating via JSON ABI
273
+ *
274
+ * An `AbiEvent` can be instantiated from a JSON ABI by using {@link ox#AbiEvent.(fromAbi:function)}:
275
+ *
276
+ * ```ts twoslash
277
+ * import { Abi, AbiEvent } from 'ox'
278
+ *
279
+ * const abi = Abi.from([
280
+ * 'function foo()',
281
+ * 'event Transfer(address owner, address to, uint256 tokenId)',
282
+ * 'function bar(string a) returns (uint256 x)',
283
+ * ])
284
+ *
285
+ * const item = AbiEvent.fromAbi(abi, 'Transfer') // [!code focus]
286
+ * // ^?
287
+ *
288
+ *
289
+ *
290
+ *
291
+ *
292
+ *
293
+ * ```
294
+ *
295
+ * @example
296
+ * ### Instantiating via Human-Readable ABI Item
297
+ *
298
+ * An `AbiEvent` can be instantiated from a human-readable ABI by using {@link ox#AbiEvent.(from:function)}:
299
+ *
300
+ * ```ts twoslash
301
+ * import { AbiEvent } from 'ox'
302
+ *
303
+ * const transfer = AbiEvent.from(
304
+ * 'event Transfer(address indexed from, address indexed to, uint256 value)' // [!code hl]
305
+ * )
306
+ *
307
+ * transfer
308
+ * //^?
309
+ *
310
+ *
311
+ *
312
+ *
313
+ *
314
+ *
315
+ *
316
+ *
317
+ *
318
+ *
319
+ *
320
+ *
321
+ *
322
+ * ```
323
+ *
324
+ * @example
325
+ * ### Encoding to Event Topics
326
+ *
327
+ * Encode an `AbiEvent` into topics using {@link ox#AbiEvent.(encode:function)}:
328
+ *
329
+ * ```ts twoslash
330
+ * import { AbiEvent } from 'ox'
331
+ *
332
+ * const transfer = AbiEvent.from(
333
+ * 'event Transfer(address indexed from, address indexed to, uint256 value)'
334
+ * )
335
+ *
336
+ * const { topics } = AbiEvent.encode(transfer, {
337
+ * from: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', // [!code hl]
338
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8' // [!code hl]
339
+ * })
340
+ * // @log: [
341
+ * // @log: '0x406dade31f7ae4b5dbc276258c28dde5ae6d5c2773c5745802c493a2360e55e0',
342
+ * // @log: '0x00000000000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
343
+ * // @log: '0x0000000000000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8'
344
+ * // @log: ]
345
+ * ```
346
+ *
347
+ * @example
348
+ * ### Decoding Event Topics and Data
349
+ *
350
+ * Event topics and data can be decoded using {@link ox#AbiEvent.(decode:function)}:
351
+ *
352
+ * ```ts twoslash
353
+ * import { AbiEvent } from 'ox'
354
+ *
355
+ * const transfer = AbiEvent.from(
356
+ * 'event Transfer(address indexed from, address indexed to, uint256 value)'
357
+ * )
358
+ *
359
+ * const log = {
360
+ * // ...
361
+ * data: '0x0000000000000000000000000000000000000000000000000000000000000001',
362
+ * topics: [
363
+ * '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
364
+ * '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
365
+ * '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
366
+ * ],
367
+ * } as const
368
+ *
369
+ * const decoded = AbiEvent.decode(transfer, log)
370
+ * // @log: {
371
+ * // @log: from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
372
+ * // @log: to: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
373
+ * // @log: value: 1n
374
+ * // @log: }
375
+ * ```
376
+ *
377
+ * @category ABI
378
+ */
379
+ export * as AbiEvent from './AbiEvent.js'
380
+
381
+ /**
382
+ * Utilities & types for working with [Functions](https://docs.soliditylang.org/en/latest/abi-spec.html#json) on ABIs.
383
+ *
384
+ * `AbiFunction` is a sub-type of [`AbiItem`](/api/AbiItem).
385
+ *
386
+ * @example
387
+ * ### Instantiating via JSON ABI
388
+ *
389
+ * An `AbiFunction` can be instantiated from a JSON ABI by using {@link ox#AbiFunction.(fromAbi:function)}:
390
+ *
391
+ * ```ts twoslash
392
+ * import { Abi, AbiFunction } from 'ox'
393
+ *
394
+ * const abi = Abi.from([
395
+ * 'function foo()',
396
+ * 'event Transfer(address owner, address to, uint256 tokenId)',
397
+ * 'function bar(string a) returns (uint256 x)',
398
+ * ])
399
+ *
400
+ * const item = AbiFunction.fromAbi(abi, 'bar') // [!code focus]
401
+ * // ^?
402
+ *
403
+ *
404
+ *
405
+ *
406
+ *
407
+ *
408
+ * ```
409
+ *
410
+ * @example
411
+ * ### Instantiating via Human-Readable ABI Item
412
+ *
413
+ * An `AbiFunction` can be instantiated from a human-readable ABI by using {@link ox#AbiFunction.(from:function)}:
414
+ *
415
+ * ```ts twoslash
416
+ * import { AbiFunction } from 'ox'
417
+ *
418
+ * const bar = AbiFunction.from('function bar(string a) returns (uint256 x)')
419
+ *
420
+ * bar
421
+ * //^?
422
+ *
423
+ *
424
+ *
425
+ *
426
+ *
427
+ *
428
+ *
429
+ *
430
+ *
431
+ *
432
+ *
433
+ *
434
+ *
435
+ * ```
436
+ *
437
+ * @example
438
+ * ### Encoding to Function Data
439
+ *
440
+ * A Function and its arguments can be ABI-encoded into data using the {@link ox#AbiFunction.(encodeData:function)} function. The output of this function can then be passed to `eth_sendTransaction` or `eth_call` as the `data` parameter.
441
+ *
442
+ * ```ts twoslash
443
+ * import { AbiFunction } from 'ox'
444
+ *
445
+ * const approve = AbiFunction.from('function approve(address, uint256)')
446
+ *
447
+ * const data = AbiFunction.encodeData( // [!code focus]
448
+ * approve, // [!code focus]
449
+ * ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 69420n] // [!code focus]
450
+ * ) // [!code focus]
451
+ * // @log: '0x095ea7b3000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000010f2c'
452
+ * ```
453
+ *
454
+ * @example
455
+ * ### Decoding a Function's Result
456
+ *
457
+ * A Function's result can be ABI-decoded using the {@link ox#AbiFunction.(decodeResult:function)} function.
458
+ *
459
+ * ```ts twoslash
460
+ * import { AbiFunction } from 'ox'
461
+ *
462
+ * const data = '0x000000000000000000000000000000000000000000000000000000000000002a'
463
+ * // ↑ Example data that could be returned from a contract call via `eth_call`.
464
+ *
465
+ * const totalSupply = AbiFunction.from('function totalSupply() returns (uint256)')
466
+ *
467
+ * const output = AbiFunction.decodeResult(totalSupply, data) // [!code focus]
468
+ * // @log: 42n
469
+ * ```
470
+ *
471
+ * @category ABI
472
+ */
473
+ export * as AbiFunction from './AbiFunction.js'
474
+
475
+ /**
476
+ * Utilities & types for working with [ABI Items](https://docs.soliditylang.org/en/latest/abi-spec.html#json)
477
+ *
478
+ * The `AbiItem` type is a super-type of:
479
+ * - [`AbiConstructor`](/api/AbiConstructor)
480
+ * - [`AbiFunction`](/api/AbiFunction)
481
+ * - [`AbiEvent`](/api/AbiEvent)
482
+ * - [`AbiError`](/api/AbiError)
483
+ *
484
+ * @example
485
+ * ### Instantiating via JSON ABI
486
+ *
487
+ * An `AbiItem` can be instantiated from a JSON ABI by using {@link ox#AbiItem.(fromAbi:function)}:
488
+ *
489
+ * ```ts twoslash
490
+ * import { Abi, AbiItem } from 'ox'
491
+ *
492
+ * const abi = Abi.from([
493
+ * 'function foo()',
494
+ * 'event Transfer(address owner, address to, uint256 tokenId)',
495
+ * 'function bar(string a) returns (uint256 x)',
496
+ * ])
497
+ *
498
+ * const item = AbiItem.fromAbi(abi, 'Transfer') // [!code focus]
499
+ * // ^?
500
+ *
501
+ *
502
+ *
503
+ *
504
+ *
505
+ *
506
+ * ```
507
+ *
508
+ * @example
509
+ * ### Instantiating via Human-Readable ABI Item
510
+ *
511
+ * A Human Readable ABI can be parsed into a typed ABI object:
512
+ *
513
+ * ```ts twoslash
514
+ * import { AbiItem } from 'ox'
515
+ *
516
+ * const abiItem = AbiItem.from('function approve(address spender, uint256 amount) returns (bool)')
517
+ *
518
+ * abiItem
519
+ * //^?
520
+ *
521
+ *
522
+ *
523
+ *
524
+ *
525
+ *
526
+ *
527
+ *
528
+ *
529
+ *
530
+ *
531
+ *
532
+ *
533
+ * ```
534
+ *
535
+ * @example
536
+ * ### Formatting ABI Items
537
+ *
538
+ * An `AbiItem` can be formatted into a human-readable ABI Item by using {@link ox#AbiItem.(format:function)}:
539
+ *
540
+ * ```ts twoslash
541
+ * import { AbiItem } from 'ox'
542
+ *
543
+ * const abiItem = AbiItem.from('function approve(address spender, uint256 amount) returns (bool)')
544
+ *
545
+ * const formatted = AbiItem.format(abiItem)
546
+ * // @log: 'function approve(address spender, uint256 amount) returns (bool)'
547
+ * ```
548
+ *
549
+ * @category ABI
550
+ */
551
+ export * as AbiItem from './AbiItem.js'
552
+
553
+ /**
554
+ * Utilities & types for encoding, decoding, and working with [ABI Parameters](https://docs.soliditylang.org/en/latest/abi-spec.html#types)
555
+ *
556
+ * @example
557
+ * ### Encoding ABI Parameters
558
+ *
559
+ * ABI Parameters can be ABI-encoded as per the [Application Binary Interface (ABI) Specification](https://docs.soliditylang.org/en/latest/abi-spec) using {@link ox#AbiParameters.(encode:function)}:
560
+ *
561
+ * ```ts twoslash
562
+ * import { AbiParameters } from 'ox'
563
+ *
564
+ * const data = AbiParameters.encode(
565
+ * AbiParameters.from('string, uint, bool'),
566
+ * ['wagmi', 420n, true],
567
+ * )
568
+ * ```
569
+ *
570
+ * :::tip
571
+ *
572
+ * The example above uses {@link ox#AbiParameters.(from:function)} to specify human-readable ABI Parameters.
573
+ *
574
+ * However, you can also pass JSON-ABI Parameters:
575
+ *
576
+ * ```ts
577
+ * import { AbiParameters } from 'ox'
578
+ *
579
+ * const data = AbiParameters.encode(
580
+ * [{ type: 'string' }, { type: 'uint' }, { type: 'bool' }],
581
+ * ['wagmi', 420n, true],
582
+ * )
583
+ * ```
584
+ *
585
+ * :::
586
+ *
587
+ * @example
588
+ * ### Decoding ABI Parameters
589
+ *
590
+ * ABI-encoded data can be decoded using {@link ox#AbiParameters.(decode:function)}:
591
+ *
592
+ * ```ts twoslash
593
+ * import { AbiParameters } from 'ox'
594
+ *
595
+ * const data = AbiParameters.decode(
596
+ * AbiParameters.from('string, uint, bool'),
597
+ * '0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001a4000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000057761676d69000000000000000000000000000000000000000000000000000000',
598
+ * )
599
+ * // @log: ['wagmi', 420n, true]
600
+ * ```
601
+ *
602
+ * @example
603
+ * ### JSON-ABI Parameters
604
+ *
605
+ * JSON-ABI Parameters can be instantiated using {@link ox#AbiParameters.(from:function)}:
606
+ *
607
+ * ```ts twoslash
608
+ * import { AbiParameters } from 'ox'
609
+ *
610
+ * const parameters = AbiParameters.from([
611
+ * {
612
+ * name: 'spender',
613
+ * type: 'address',
614
+ * },
615
+ * {
616
+ * name: 'amount',
617
+ * type: 'uint256',
618
+ * },
619
+ * ])
620
+ *
621
+ * parameters
622
+ * //^?
623
+ *
624
+ *
625
+ *
626
+ *
627
+ *
628
+ *
629
+ *
630
+ * ```
631
+ *
632
+ * @example
633
+ * ### Human Readable ABI Parameters
634
+ *
635
+ * Human Readable ABI Parameters can be instantiated using {@link ox#AbiParameters.(from:function)}:
636
+ *
637
+ * ```ts twoslash
638
+ * import { AbiParameters } from 'ox'
639
+ *
640
+ * const parameters = AbiParameters.from('address spender, uint256 amount')
641
+ *
642
+ * parameters
643
+ * //^?
644
+ *
645
+ *
646
+ *
647
+ *
648
+ *
649
+ *
650
+ *
651
+ * ```
652
+ *
653
+ * @category ABI
654
+ */
655
+ export * as AbiParameters from './AbiParameters.js'
656
+
657
+ /**
658
+ * Utilities & types for working with Access Lists as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/4140e528360fea53c34a766d86a000c6c039100e/src/schemas/transaction.yaml#L73)
659
+ *
660
+ * @category Execution Spec
661
+ */
662
+ export * as AccessList from './AccessList.js'
663
+
664
+ /**
665
+ * Utilities & types for working with Account Proofs as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/state.yaml)
666
+ *
667
+ * @category Execution Spec
668
+ */
669
+ export * as AccountProof from './AccountProof.js'
670
+
671
+ /**
672
+ * Utility functions for working with Ethereum addresses.
673
+ *
674
+ * @example
675
+ * ### Instantiating Addresses
676
+ *
677
+ * An {@link ox#Address.Address} can be instantiated from a hex string using {@link ox#Address.(from:function)}:
678
+ *
679
+ * ```ts twoslash
680
+ * import { Address } from 'ox'
681
+ *
682
+ * const address = Address.from('0xa0cf798816d4b9b9866b5330eea46a18382f251e')
683
+ * // @log: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'
684
+ * ```
685
+ *
686
+ * @example
687
+ * ### Validating Addresses
688
+ *
689
+ * The {@link ox#Address.(validate:function)} function will return `true` if the address is valid, and `false` otherwise:
690
+ *
691
+ * ```ts twoslash
692
+ * import { Address } from 'ox'
693
+ *
694
+ * const valid = Address.validate('0xA0Cf798816D4b9b9866b5330EEa46a18382f251e')
695
+ * // @log: true
696
+ * ```
697
+ *
698
+ * The {@link ox#Address.(assert:function)} function will throw an error if the address is invalid:
699
+ *
700
+ * ```ts twoslash
701
+ * import { Address } from 'ox'
702
+ *
703
+ * Address.assert('0xdeadbeef')
704
+ * // @error: InvalidAddressError: Address "0xdeadbeef" is invalid.
705
+ * ```
706
+ *
707
+ * @example
708
+ * ### Addresses from ECDSA Public Keys
709
+ *
710
+ * An {@link ox#Address.Address} can be computed from an ECDSA public key using {@link ox#Address.(fromPublicKey:function)}:
711
+ *
712
+ * ```ts twoslash
713
+ * import { Address, Secp256k1 } from 'ox'
714
+ *
715
+ * const privateKey = Secp256k1.randomPrivateKey()
716
+ * const publicKey = Secp256k1.getPublicKey({ privateKey })
717
+ *
718
+ * const address = Address.fromPublicKey(publicKey)
719
+ * // @log: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'
720
+ * ```
721
+ *
722
+ * @category Addresses
723
+ */
724
+ export * as Address from './Address.js'
725
+
726
+ /**
727
+ * Utilities & types for working with AES-GCM encryption. Internally uses the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API).
728
+ *
729
+ * @example
730
+ * ### Encrypting Data
731
+ *
732
+ * Data can be encrypted using {@link ox#AesGcm.(encrypt:function)}:
733
+ *
734
+ * ```ts twoslash
735
+ * import { AesGcm, Hex } from 'ox'
736
+ *
737
+ * const key = await AesGcm.getKey({ password: 'qwerty' })
738
+ * const secret = Hex.fromString('i am a secret message')
739
+ *
740
+ * const encrypted = await AesGcm.encrypt(secret, key) // [!code focus]
741
+ * // @log: '0x5e257b25bcf53d5431e54e5a68ca0138306d31bb6154f35a97bb8ea18111e7d82bcf619d3c76c4650688bc5310eed80b8fc86d1e3e'
742
+ * ```
743
+ *
744
+ * @example
745
+ * ### Decrypting Data
746
+ *
747
+ * Data can be decrypted using {@link ox#AesGcm.(decrypt:function)}:
748
+ *
749
+ * ```ts twoslash
750
+ * import { AesGcm, Hex } from 'ox'
751
+ *
752
+ * const key = await AesGcm.getKey({ password: 'qwerty' })
753
+ * const encrypted = await AesGcm.encrypt(Hex.fromString('i am a secret message'), key)
754
+ *
755
+ * const decrypted = await AesGcm.decrypt(encrypted, key) // [!code focus]
756
+ * // @log: Hex.fromString('i am a secret message')
757
+ * ```
758
+ *
759
+ * @category Crypto
760
+ */
761
+ export * as AesGcm from './AesGcm.js'
762
+
763
+ /**
764
+ * Utility functions for working with [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization lists & tuples.
765
+ *
766
+ * @example
767
+ * ### Instantiating Authorizations
768
+ *
769
+ * An Authorization can be instantiated using {@link ox#Authorization.(from:function)}:
770
+ *
771
+ * ```ts twoslash
772
+ * import { Authorization } from 'ox'
773
+ *
774
+ * const authorization = Authorization.from({
775
+ * address: '0x1234567890abcdef1234567890abcdef12345678',
776
+ * chainId: 1,
777
+ * nonce: 69n,
778
+ * })
779
+ * ```
780
+ *
781
+ * @example
782
+ * ### Computing Sign Payload
783
+ *
784
+ * A signing payload can be computed using {@link ox#Authorization.(getSignPayload:function)}. The result can then be passed to signing functions like {@link ox#Secp256k1.(sign:function)}.
785
+ *
786
+ * ```ts twoslash
787
+ * import { Authorization, Secp256k1 } from 'ox'
788
+ *
789
+ * const authorization = Authorization.from({
790
+ * address: '0x1234567890abcdef1234567890abcdef12345678',
791
+ * chainId: 1,
792
+ * nonce: 69n,
793
+ * })
794
+ *
795
+ * const payload = Authorization.getSignPayload(authorization) // [!code focus]
796
+ *
797
+ * const signature = Secp256k1.sign({
798
+ * payload,
799
+ * privateKey: '0x...',
800
+ * })
801
+ * ```
802
+ *
803
+ * @example
804
+ * ### Attaching Signatures to Authorizations
805
+ *
806
+ * A signature can be attached to an Authorization using {@link ox#Authorization.(from:function)}:
807
+ *
808
+ * ```ts twoslash
809
+ * import { Authorization, Secp256k1, TransactionEnvelopeEip7702, Value } from 'ox'
810
+ *
811
+ * const authorization = Authorization.from({
812
+ * address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
813
+ * chainId: 1,
814
+ * nonce: 40n,
815
+ * })
816
+ *
817
+ * const signature = Secp256k1.sign({
818
+ * payload: Authorization.getSignPayload(authorization),
819
+ * privateKey: '0x...',
820
+ * })
821
+ *
822
+ * const authorization_signed = Authorization.from(authorization, { signature }) // [!code focus]
823
+ *
824
+ * const envelope = TransactionEnvelopeEip7702.from({
825
+ * authorizationList: [authorization_signed],
826
+ * chainId: 1,
827
+ * maxFeePerGas: Value.fromGwei('10'),
828
+ * to: '0x0000000000000000000000000000000000000000',
829
+ * value: Value.fromEther('1'),
830
+ * })
831
+ * ```
832
+ *
833
+ * @category Authorization (EIP-7702)
834
+ */
835
+ export * as Authorization from './Authorization.js'
836
+
837
+ /**
838
+ * Utility functions for working with [Base58](https://digitalbazaar.github.io/base58-spec/) values.
839
+ *
840
+ * @example
841
+ * ### Encoding to Base58
842
+ *
843
+ * Values can be encoded to Base58 with:
844
+ *
845
+ * - {@link ox#Base58.(fromString:function)}, or
846
+ *
847
+ * - {@link ox#Base58.(fromBytes:function)}, or
848
+ *
849
+ * - {@link ox#Base58.(fromHex:function)}
850
+ *
851
+ * ```ts twoslash
852
+ * import { Base58 } from 'ox'
853
+ *
854
+ * const value_string = Base58.fromString('Hello World!')
855
+ * // @log: '2NEpo7TZRRrLZSi2U'
856
+ *
857
+ * const value_bytes = Base58.fromBytes(new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))
858
+ * // @log: '2NEpo7TZRRrLZSi2U'
859
+ *
860
+ * const value_hex = Base58.fromHex('0x48656c6c6f20576f726c6421')
861
+ * // @log: '2NEpo7TZRRrLZSi2U'
862
+ * ```
863
+ *
864
+ * @example
865
+ * ### Decoding Base58
866
+ *
867
+ * Values can be decoded from Base58 with:
868
+ *
869
+ * - {@link ox#Base58.(toString:function)}, or
870
+ *
871
+ * - {@link ox#Base58.(toBytes:function)}, or
872
+ *
873
+ * - {@link ox#Base58.(toHex:function)}
874
+ *
875
+ * ```ts twoslash
876
+ * import { Base58 } from 'ox'
877
+ *
878
+ * const value_string = Base58.toString('2NEpo7TZRRrLZSi2U')
879
+ * // @log: 'Hello World!'
880
+ *
881
+ * const value_bytes = Base58.toBytes('2NEpo7TZRRrLZSi2U')
882
+ * // @log: Uint8Array [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]
883
+ *
884
+ * const value_hex = Base58.toHex('2NEpo7TZRRrLZSi2U')
885
+ * // @log: '0x48656c6c6f20576f726c6421'
886
+ * ```
887
+ *
888
+ * @category Data
889
+ */
890
+ export * as Base58 from './Base58.js'
891
+
892
+ /**
893
+ * Utility functions for working with [RFC-4648](https://datatracker.ietf.org/doc/html/rfc4648) Base64.
894
+ *
895
+ * @example
896
+ * ### Encoding to Base64
897
+ *
898
+ * Values can be encoded to Base64 with:
899
+ *
900
+ * - {@link ox#Base64.(fromString:function)}, or
901
+ *
902
+ * - {@link ox#Base64.(fromBytes:function)}, or
903
+ *
904
+ * - {@link ox#Base64.(fromHex:function)}
905
+ *
906
+ * ```ts twoslash
907
+ * import { Base64 } from 'ox'
908
+ *
909
+ * const value_string = Base64.fromString('Hello World!')
910
+ * // @log: 'SGVsbG8gV29ybGQh=='
911
+ *
912
+ * const value_bytes = Base64.fromBytes(new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))
913
+ * // @log: 'SGVsbG8gV29ybGQh=='
914
+ *
915
+ * const value_hex = Base64.fromHex('0x48656c6c6f20576f726c6421')
916
+ * // @log: 'SGVsbG8gV29ybGQh=='
917
+ * ```
918
+ *
919
+ * ### Decoding Base64
920
+ *
921
+ * Values can be decoded from Base64 with:
922
+ *
923
+ * - {@link ox#Base64.(toString:function)}, or
924
+ *
925
+ * - {@link ox#Base64.(toBytes:function)}, or
926
+ *
927
+ * - {@link ox#Base64.(toHex:function)}
928
+ *
929
+ * ```ts twoslash
930
+ * import { Base64 } from 'ox'
931
+ *
932
+ * const value_string = Base64.toString('SGVsbG8gV29ybGQh==')
933
+ * // @log: 'Hello World!'
934
+ *
935
+ * const value_bytes = Base64.toBytes('SGVsbG8gV29ybGQh==')
936
+ * // @log: Uint8Array [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]
937
+ *
938
+ * const value_hex = Base64.toHex('SGVsbG8gV29ybGQh==')
939
+ * // @log: '0x48656c6c6f20576f726c6421'
940
+ * ```
941
+ *
942
+ * @category Data
943
+ */
944
+ export * as Base64 from './Base64.js'
945
+
946
+ /**
947
+ * Utility functions for working with [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) Blobs.
948
+ *
949
+ * @category Blobs (EIP-4844)
950
+ */
951
+ export * as Blobs from './Blobs.js'
952
+
953
+ /**
954
+ * Utilities & types for working with Blocks as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/block.yaml)
955
+ *
956
+ * @example
957
+ * ### Converting from RPC Format
958
+ *
959
+ * Blocks can be converted from RPC format to internal format using {@link ox#Block.(fromRpc:function)}:
960
+ *
961
+ * ```ts twoslash
962
+ * import 'ox/window'
963
+ * import { Block } from 'ox'
964
+ *
965
+ * const block = await window.ethereum!
966
+ * .request({
967
+ * method: 'eth_getBlockByNumber',
968
+ * params: ['latest', false],
969
+ * })
970
+ * .then(Block.fromRpc) // [!code hl]
971
+ * // @log: {
972
+ * // @log: // ...
973
+ * // @log: hash: '0xebc3644804e4040c0a74c5a5bbbc6b46a71a5d4010fe0c92ebb2fdf4a43ea5dd',
974
+ * // @log: number: 19868020n,
975
+ * // @log: size: 520n,
976
+ * // @log: timestamp: 1662222222n,
977
+ * // @log: // ...
978
+ * // @log: }
979
+ * ```
980
+ *
981
+ * @category Execution Spec
982
+ */
983
+ export * as Block from './Block.js'
984
+
985
+ /**
986
+ * Utility functions for working with Bloom Filters as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/block.yaml)
987
+ *
988
+ * @category Execution Spec
989
+ */
990
+ export * as Bloom from './Bloom.js'
991
+
992
+ /**
993
+ * Utility functions for [BLS12-381](https://hackmd.io/@benjaminion/bls12-381) cryptography.
994
+ *
995
+ * :::info
996
+ *
997
+ * The `Bls` module is a friendly wrapper over [`@noble/curves/bls12-381`](https://github.com/paulmillr/noble-curves), an **audited** implementation of BLS12-381.
998
+ *
999
+ * :::
1000
+ *
1001
+ * @example
1002
+ * ### Computing a Random Private Key
1003
+ *
1004
+ * A random private key can be computed using {@link ox#Bls.(randomPrivateKey:function)}:
1005
+ *
1006
+ * ```ts twoslash
1007
+ * import { Bls } from 'ox'
1008
+ *
1009
+ * const privateKey = Bls.randomPrivateKey()
1010
+ * // @log: '0x...'
1011
+ * ```
1012
+ *
1013
+ * @example
1014
+ * ### Getting a Public Key
1015
+ *
1016
+ * A public key can be derived from a private key using {@link ox#Bls.(getPublicKey:function)}:
1017
+ *
1018
+ * ```ts twoslash
1019
+ * import { Bls } from 'ox'
1020
+ *
1021
+ * const privateKey = Bls.randomPrivateKey()
1022
+ * const publicKey = Bls.getPublicKey({ privateKey })
1023
+ * // @log: { x: 3251...5152n, y: 1251...5152n, z: 1n }
1024
+ * ```
1025
+ *
1026
+ * @example
1027
+ * ### Signing a Payload
1028
+ *
1029
+ * A payload can be signed using {@link ox#Bls.(sign:function)}:
1030
+ *
1031
+ * ```ts twoslash
1032
+ * import { Bls } from 'ox'
1033
+ *
1034
+ * const privateKey = Bls.randomPrivateKey()
1035
+ * const signature = Bls.sign({ payload: '0xdeadbeef', privateKey })
1036
+ * // @log: { x: 1251...5152n, y: 1251...5152n, z: 1n }
1037
+ * ```
1038
+ *
1039
+ * @example
1040
+ * ### Verifying a Signature
1041
+ *
1042
+ * A signature can be verified using {@link ox#Secp256k1.(verify:function)}:
1043
+ *
1044
+ * ```ts twoslash
1045
+ * import { Bls } from 'ox'
1046
+ *
1047
+ * const privateKey = Bls.randomPrivateKey()
1048
+ * const publicKey = Bls.getPublicKey({ privateKey })
1049
+ * const signature = Bls.sign({ payload: '0xdeadbeef', privateKey })
1050
+ *
1051
+ * const isValid = Bls.verify({ // [!code focus]
1052
+ * payload: '0xdeadbeef', // [!code focus]
1053
+ * publicKey, // [!code focus]
1054
+ * signature, // [!code focus]
1055
+ * }) // [!code focus]
1056
+ * // @log: true
1057
+ * ```
1058
+ *
1059
+ * @example
1060
+ * ### Aggregating Public Keys & Signatures
1061
+ *
1062
+ * Public keys and signatures can be aggregated using {@link ox#Bls.(aggregate:function)}:
1063
+ *
1064
+ * ```ts twoslash
1065
+ * import { Bls } from 'ox'
1066
+ *
1067
+ * const publicKeys = [
1068
+ * Bls.getPublicKey({ privateKey: '0x...' }),
1069
+ * Bls.getPublicKey({ privateKey: '0x...' }),
1070
+ * ]
1071
+ * const publicKey = Bls.aggregate(publicKeys)
1072
+ *
1073
+ * const signatures = [
1074
+ * Bls.sign({ payload: '0x...', privateKey: '0x...' }),
1075
+ * Bls.sign({ payload: '0x...', privateKey: '0x...' }),
1076
+ * ]
1077
+ * const signature = Bls.aggregate(signatures)
1078
+ * ```
1079
+ *
1080
+ * @example
1081
+ * ### Verify Aggregated Signatures
1082
+ *
1083
+ * We can also pass a public key and signature that was aggregated with {@link ox#Bls.(aggregate:function)} to `Bls.verify`.
1084
+ *
1085
+ * ```ts twoslash
1086
+ * import { Bls, Hex } from 'ox'
1087
+ *
1088
+ * const payload = Hex.random(32)
1089
+ * const privateKeys = Array.from({ length: 100 }, () => Bls.randomPrivateKey())
1090
+ *
1091
+ * const publicKeys = privateKeys.map((privateKey) =>
1092
+ * Bls.getPublicKey({ privateKey }),
1093
+ * )
1094
+ * const signatures = privateKeys.map((privateKey) =>
1095
+ * Bls.sign({ payload, privateKey }),
1096
+ * )
1097
+ *
1098
+ * const publicKey = Bls.aggregate(publicKeys) // [!code focus]
1099
+ * const signature = Bls.aggregate(signatures) // [!code focus]
1100
+ *
1101
+ * const valid = Bls.verify({ payload, publicKey, signature }) // [!code focus]
1102
+ * ```
1103
+ *
1104
+ * @category Crypto
1105
+ */
1106
+ export * as Bls from './Bls.js'
1107
+
1108
+ /**
1109
+ * Utility functions for working with BLS12-381 points.
1110
+ *
1111
+ * :::info
1112
+ *
1113
+ * The `BlsPoint` module is a friendly wrapper over [`@noble/curves/bls12-381`](https://github.com/paulmillr/noble-curves), an **audited** implementation of BLS12-381.
1114
+ *
1115
+ * :::
1116
+ *
1117
+ * @example
1118
+ * ### Public Keys or Signatures to Hex
1119
+ *
1120
+ * BLS points can be converted to hex using {@link ox#BlsPoint.(toHex:function)}:
1121
+ *
1122
+ * ```ts twoslash
1123
+ * import { Bls, BlsPoint } from 'ox'
1124
+ *
1125
+ * const publicKey = Bls.getPublicKey({ privateKey: '0x...' })
1126
+ * const publicKeyHex = BlsPoint.toHex(publicKey)
1127
+ * // @log: '0xacafff52270773ad1728df2807c0f1b0b271fa6b37dfb8b2f75448573c76c81bcd6790328a60e40ef5a13343b32d9e66'
1128
+ *
1129
+ * const signature = Bls.sign({ payload: '0xdeadbeef', privateKey: '0x...' })
1130
+ * const signatureHex = BlsPoint.toHex(signature)
1131
+ * // @log: '0xb4698f7611999fba87033b9cf72312c76c683bbc48175e2d4cb275907d6a267ab9840a66e3051e5ed36fd13aa712f9a9024f9fa9b67f716dfb74ae4efb7d9f1b7b43b4679abed6644cf476c12e79f309351ea8452487cd93f66e29e04ebe427c'
1132
+ * ```
1133
+ *
1134
+ * @example
1135
+ * ### Hex to Public Keys or Signatures
1136
+ *
1137
+ * BLS points can be converted from hex using {@link ox#BlsPoint.(fromHex:function)}:
1138
+ *
1139
+ * ```ts twoslash
1140
+ * import { Bls, BlsPoint } from 'ox'
1141
+ *
1142
+ * const publicKey = BlsPoint.fromHex('0xacafff52270773ad1728df2807c0f1b0b271fa6b37dfb8b2f75448573c76c81bcd6790328a60e40ef5a13343b32d9e66', 'G1')
1143
+ * // @log: { x: 172...514n, y: 175...235n, z: 1n }
1144
+ *
1145
+ * const signature = BlsPoint.fromHex('0xb4698f7611999fba87033b9cf72312c76c683bbc48175e2d4cb275907d6a267ab9840a66e3051e5ed36fd13aa712f9a9024f9fa9b67f716dfb74ae4efb7d9f1b7b43b4679abed6644cf476c12e79f309351ea8452487cd93f66e29e04ebe427c', 'G2')
1146
+ * // @log: { x: 1251...5152n, y: 1251...5152n, z: 1n }
1147
+ * ```
1148
+ *
1149
+ * @category Crypto
1150
+ */
1151
+ export * as BlsPoint from './BlsPoint.js'
1152
+
1153
+ /**
1154
+ * A set of Ethereum-related utility functions for working with [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) instances.
1155
+ *
1156
+ * @example
1157
+ * ### Instantiating Bytes
1158
+ *
1159
+ * Values can be instantiated as {@link ox#Bytes.Bytes} using:
1160
+ *
1161
+ * - {@link ox#Bytes.(fromArray:function)}
1162
+ *
1163
+ * - {@link ox#Bytes.(fromBoolean:function)}
1164
+ *
1165
+ * - {@link ox#Bytes.(fromHex:function)}
1166
+ *
1167
+ * - {@link ox#Bytes.(fromNumber:function)}
1168
+ *
1169
+ * - {@link ox#Bytes.(fromString:function)}
1170
+ *
1171
+ * ```ts twoslash
1172
+ * import { Bytes } from 'ox'
1173
+ *
1174
+ * const value_array = Bytes.from([1, 2, 3, 4, 5])
1175
+ * // @log: Uint8Array [1, 2, 3, 4, 5]
1176
+ *
1177
+ * const value_boolean = Bytes.fromBoolean(true)
1178
+ * // @log: Uint8Array [1]
1179
+ *
1180
+ * const value_hex = Bytes.fromHex('0x1234567890abcdef')
1181
+ * // @log: Uint8Array [18, 52, 86, 120, 144, 175, 207, 15]
1182
+ *
1183
+ * const value_number = Bytes.fromNumber(1234567890)
1184
+ * // @log: Uint8Array [4, 160, 216]
1185
+ *
1186
+ * const value_string = Bytes.fromString('Hello World!')
1187
+ * // @log: Uint8Array [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]
1188
+ * ```
1189
+ *
1190
+ * @example
1191
+ * ### Converting from Bytes
1192
+ *
1193
+ * Values can be converted from {@link ox#Bytes.Bytes} using:
1194
+ *
1195
+ * - {@link ox#Bytes.(toBigInt:function)}
1196
+ *
1197
+ * - {@link ox#Bytes.(toBoolean:function)}
1198
+ *
1199
+ * - {@link ox#Bytes.(toHex:function)}
1200
+ *
1201
+ * - {@link ox#Bytes.(toNumber:function)}
1202
+ *
1203
+ * - {@link ox#Bytes.(toString:function)}
1204
+ *
1205
+ * ```ts twoslash
1206
+ * import { Bytes } from 'ox'
1207
+ *
1208
+ * const value_bigint = Bytes.toBigInt(Bytes.from([4, 160, 216]))
1209
+ * // @log: 1234567890n
1210
+ *
1211
+ * const value_boolean = Bytes.toBoolean(Bytes.from([1]))
1212
+ * // @log: true
1213
+ *
1214
+ * const value_hex = Bytes.toHex(Bytes.from([222, 173, 190, 239]))
1215
+ * // @log: '0xdeadbeef'
1216
+ *
1217
+ * const value_number = Bytes.toNumber(Bytes.from([4, 160, 216]))
1218
+ * // @log: 1234567890
1219
+ *
1220
+ * const value_string = Bytes.toString(Bytes.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))
1221
+ * // @log: 'Hello World!'
1222
+ * ```
1223
+ *
1224
+ * @example
1225
+ * ### Concatenating Bytes
1226
+ *
1227
+ * Values can be concatenated using {@link ox#Bytes.(concat:function)}:
1228
+ *
1229
+ * ```ts twoslash
1230
+ * import { Bytes } from 'ox'
1231
+ *
1232
+ * const a = Bytes.from([1, 2, 3])
1233
+ * const b = Bytes.from([4, 5, 6])
1234
+ * const c = Bytes.concat(a, b)
1235
+ * // @log: Uint8Array [1, 2, 3, 4, 5, 6]
1236
+ * ```
1237
+ *
1238
+ * @example
1239
+ * ### Slicing Bytes
1240
+ *
1241
+ * Values can be sliced using {@link ox#Bytes.(slice:function)}:
1242
+ *
1243
+ * ```ts twoslash
1244
+ * import { Bytes } from 'ox'
1245
+ *
1246
+ * const value = Bytes.slice(Bytes.from([1, 2, 3, 4, 5, 6]), 2, 4)
1247
+ * // @log: Uint8Array [3, 4]
1248
+ * ```
1249
+ *
1250
+ * @example
1251
+ * ### Padding Bytes
1252
+ *
1253
+ * Values can be padded with zeroes using {@link ox#Bytes.(padLeft:function)} or {@link ox#Bytes.(padRight:function)}:
1254
+ *
1255
+ * ```ts twoslash
1256
+ * import { Bytes } from 'ox'
1257
+ *
1258
+ * const value_1 = Bytes.padLeft(Bytes.from([1, 2, 3]), 5)
1259
+ * // @log: Uint8Array [0, 0, 1, 2, 3]
1260
+ *
1261
+ * const value_2 = Bytes.padRight(Bytes.from([1, 2, 3]), 5)
1262
+ * // @log: Uint8Array [1, 2, 3, 0, 0]
1263
+ * ```
1264
+ *
1265
+ * @example
1266
+ * ### Trimming Bytes
1267
+ *
1268
+ * Zeroes in values can be trimmed using {@link ox#Bytes.(trimLeft:function)} or {@link ox#Bytes.(trimRight:function)}:
1269
+ *
1270
+ * ```ts twoslash
1271
+ * import { Bytes } from 'ox'
1272
+ *
1273
+ * const value = Bytes.trimLeft(Bytes.from([0, 0, 1, 2, 3]))
1274
+ * // @log: Uint8Array [1, 2, 3]
1275
+ * ```
1276
+ *
1277
+ * @category Data
1278
+ */
1279
+ export * as Bytes from './Bytes.js'
1280
+
1281
+ export * as Caches from './Caches.js'
1282
+
1283
+ /**
1284
+ * Utility functions for computing Contract Addresses.
1285
+ *
1286
+ * @example
1287
+ * ### Computing Contract Addresses (CREATE)
1288
+ *
1289
+ * A Contract Address that was instantiated using the `CREATE` opcode can be computed using {@link ox#ContractAddress.(fromCreate:function)}:
1290
+ *
1291
+ * ```ts twoslash
1292
+ * import { ContractAddress } from 'ox'
1293
+ *
1294
+ * ContractAddress.fromCreate({
1295
+ * from: '0x1a1e021a302c237453d3d45c7b82b19ceeb7e2e6',
1296
+ * nonce: 0n,
1297
+ * })
1298
+ * // @log: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2'
1299
+ * ```
1300
+ *
1301
+ * @example
1302
+ * ### Computing Contract Addresses (CREATE2)
1303
+ *
1304
+ * A Contract Address that was instantiated using the `CREATE2` opcode can be computed using {@link ox#ContractAddress.(fromCreate2:function)}:
1305
+ *
1306
+ * ```ts twoslash
1307
+ * import { Bytes, ContractAddress, Hex } from 'ox'
1308
+ *
1309
+ * ContractAddress.fromCreate2({
1310
+ * from: '0x1a1e021a302c237453d3d45c7b82b19ceeb7e2e6',
1311
+ * bytecode: Bytes.from('0x6394198df16000526103ff60206004601c335afa6040516060f3'),
1312
+ * salt: Hex.fromString('hello world'),
1313
+ * })
1314
+ * // @log: '0x59fbB593ABe27Cb193b6ee5C5DC7bbde312290aB'
1315
+ * ```
1316
+ *
1317
+ * @category Addresses
1318
+ */
1319
+ export * as ContractAddress from './ContractAddress.js'
1320
+
1321
+ /**
1322
+ * Utility functions for working with ENS names.
1323
+ *
1324
+ * @example
1325
+ * ### Normalizing ENS Names
1326
+ *
1327
+ * ENS names can be normalized using {@link ox#Ens.(normalize:function)}:
1328
+ *
1329
+ * ```ts twoslash
1330
+ * import { Ens } from 'ox'
1331
+ *
1332
+ * const name = Ens.normalize('w𝝣vm.eth')
1333
+ * // @log: 'wξvm.eth'
1334
+ * ```
1335
+ *
1336
+ * @example
1337
+ * ### Namehashing ENS Names
1338
+ *
1339
+ * ENS names can be namehashed using {@link ox#Ens.(namehash:function)}:
1340
+ *
1341
+ * ```ts twoslash
1342
+ * import { Ens } from 'ox'
1343
+ *
1344
+ * const name = Ens.namehash('alice.eth')
1345
+ * // @log: '0x787192fc5378cc32aa956ddfdedbf26b24e8d78e40109add0eea2c1a012c3dec'
1346
+ * ```
1347
+ *
1348
+ * @category ENS
1349
+ */
1350
+ export * as Ens from './Ens.js'
1351
+
1352
+ export * as Errors from './Errors.js'
1353
+
1354
+ /**
1355
+ * Utilities & types for working with Filters as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/filter.yaml)
1356
+ *
1357
+ * @category Execution Spec
1358
+ */
1359
+ export * as Filter from './Filter.js'
1360
+
1361
+ /**
1362
+ * Utility functions for hashing (keccak256, sha256, etc).
1363
+ *
1364
+ * @example
1365
+ * ```ts twoslash
1366
+ * import { Hash } from 'ox'
1367
+ *
1368
+ * const value = Hash.keccak256('0xdeadbeef')
1369
+ * // '0xd4fd4e189132273036449fc9e11198c739161b4c0116a9a2dccdfa1c492006f1'
1370
+ * ```
1371
+ *
1372
+ * @category Crypto
1373
+ */
1374
+ export * as Hash from './Hash.js'
1375
+
1376
+ /**
1377
+ * Utility functions for generating and working with [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) HD Wallets.
1378
+ *
1379
+ * :::info
1380
+ *
1381
+ * The `HdKey` module is a friendly wrapper over [`@scure/bip32`](https://github.com/paulmillr/scure-bip32), an **audited** implementation of [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) HD Wallets.
1382
+ *
1383
+ * :::
1384
+ *
1385
+ *
1386
+ * @category Crypto
1387
+ */
1388
+ export * as HdKey from './HdKey.js'
1389
+
1390
+ /**
1391
+ * A set of Ethereum-related utility functions for working with hexadecimal string values (e.g. `"0xdeadbeef"`).
1392
+ *
1393
+ * @example
1394
+ * ### Instantiating Hex
1395
+ *
1396
+ * Values can be instantiated as {@link ox#Hex.Hex} using:
1397
+ *
1398
+ * - {@link ox#Hex.(fromBoolean:function)}
1399
+ *
1400
+ * - {@link ox#Hex.(fromBytes:function)}
1401
+ *
1402
+ * - {@link ox#Hex.(fromNumber:function)}
1403
+ *
1404
+ * - {@link ox#Hex.(fromString:function)}
1405
+ *
1406
+ * ```ts twoslash
1407
+ * import { Bytes, Hex } from 'ox'
1408
+ *
1409
+ * const value_boolean = Hex.fromBoolean(true)
1410
+ * // @log: '0x1'
1411
+ *
1412
+ * const value_bytes = Hex.fromBytes(Bytes.from([1, 2, 3]))
1413
+ * // @log: '0x010203'
1414
+ *
1415
+ * const value_number = Hex.fromNumber(1234567890)
1416
+ * // @log: '0x499602d2'
1417
+ *
1418
+ * const value_string = Hex.fromString('Hello World!')
1419
+ * // @log: '0x48656c6c6f20576f726c6421'
1420
+ * ```
1421
+ *
1422
+ * @example
1423
+ * ### Converting from Hex
1424
+ *
1425
+ * Values can be converted from {@link ox#Hex.Hex} using:
1426
+ *
1427
+ * - {@link ox#Hex.(toBoolean:function)}
1428
+ *
1429
+ * - {@link ox#Hex.(toBytes:function)}
1430
+ *
1431
+ * - {@link ox#Hex.(toNumber:function)}
1432
+ *
1433
+ * - {@link ox#Hex.(toString:function)}
1434
+ *
1435
+ * ```ts twoslash
1436
+ * import { Hex } from 'ox'
1437
+ *
1438
+ * const value_boolean = Hex.toBoolean('0x1')
1439
+ * // @log: true
1440
+ *
1441
+ * const value_bytes = Hex.toBytes('0x010203')
1442
+ * // @log: Uint8Array [1, 2, 3]
1443
+ *
1444
+ * const value_number = Hex.toNumber('0x499602d2')
1445
+ * // @log: 1234567890
1446
+ *
1447
+ * const value_string = Hex.toString('0x48656c6c6f20576f726c6421')
1448
+ * // @log: 'Hello World!'
1449
+ * ```
1450
+ *
1451
+ * @example
1452
+ * ### Concatenating Hex
1453
+ *
1454
+ * Hex values can be concatenated using {@link ox#Hex.(concat:function)}:
1455
+ *
1456
+ * ```ts twoslash
1457
+ * import { Hex } from 'ox'
1458
+ *
1459
+ * const a = Hex.fromString('0x1234567890abcdef')
1460
+ * const b = Hex.fromString('0xdeadbeef')
1461
+ * const c = Hex.concat(a, b)
1462
+ * // @log: '0x1234567890abcdefdeadbeef'
1463
+ * ```
1464
+ *
1465
+ * @example
1466
+ * ### Slicing Hex
1467
+ *
1468
+ * Hex values can be sliced using {@link ox#Hex.(slice:function)}:
1469
+ *
1470
+ * ```ts twoslash
1471
+ * import { Hex } from 'ox'
1472
+ *
1473
+ * const value = Hex.slice('0x1234567890abcdefdeadbeef', 2, 8)
1474
+ * // @log: '0x34567890'
1475
+ * ```
1476
+ *
1477
+ * @example
1478
+ * ### Padding Hex
1479
+ *
1480
+ * Hex values can be padded with zeroes using {@link ox#Hex.(padLeft:function)} or {@link ox#Hex.(padRight:function)}:
1481
+ *
1482
+ * ```ts twoslash
1483
+ * import { Hex } from 'ox'
1484
+ *
1485
+ * const value = Hex.padLeft('0x1234567890abcdef', 16)
1486
+ * // @log: '0x00000000000000001234567890abcdef'
1487
+ * ```
1488
+ *
1489
+ * @example
1490
+ * ### Trimming Hex
1491
+ *
1492
+ * Hex values can be trimmed of zeroes using {@link ox#Hex.(trimLeft:function)} or {@link ox#Hex.(trimRight:function)}:
1493
+ *
1494
+ * ```ts twoslash
1495
+ * import { Hex } from 'ox'
1496
+ *
1497
+ * const value = Hex.trimLeft('0x00000000000000001234567890abcdef')
1498
+ * // @log: '0x1234567890abcdef'
1499
+ * ```
1500
+ *
1501
+ * @category Data
1502
+ */
1503
+ export * as Hex from './Hex.js'
1504
+
1505
+ /**
1506
+ * @category Execution Spec
1507
+ */
1508
+ export * as Fee from './Fee.js'
1509
+
1510
+ /**
1511
+ * Utility functions for working with JSON (with support for `bigint`).
1512
+ *
1513
+ * @example
1514
+ * ### Stringifying JSON
1515
+ *
1516
+ * JSON values can be stringified (with `bigint` support) using {@link ox#Json.(stringify:function)}:
1517
+ *
1518
+ * ```ts twoslash
1519
+ * import { Json } from 'ox'
1520
+ *
1521
+ * const json = Json.stringify({
1522
+ * foo: 'bar',
1523
+ * baz: 69420694206942069420694206942069420694206942069420n,
1524
+ * })
1525
+ * // @log: '{"foo":"bar","baz":69420694206942069420694206942069420694206942069420}'
1526
+ * ```
1527
+ *
1528
+ * @example
1529
+ * ### Parsing JSON
1530
+ *
1531
+ * JSON values can be parsed (with `bigint` support) using {@link ox#Json.(parse:function)}:
1532
+ *
1533
+ * ```ts twoslash
1534
+ * import { Json } from 'ox'
1535
+ *
1536
+ * const value = Json.parse('{"foo":"bar","baz":69420694206942069420694206942069420694206942069420}')
1537
+ * // @log: { foo: 'bar', baz: 69420694206942069420694206942069420694206942069420n }
1538
+ * ```
1539
+ *
1540
+ * @category JSON
1541
+ */
1542
+ export * as Json from './Json.js'
1543
+
1544
+ /**
1545
+ * Utility functions for working with KZG Commitments.
1546
+ *
1547
+ * Mainly for [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) Blobs.
1548
+ *
1549
+ * @category Blobs (EIP-4844)
1550
+ */
1551
+ export * as Kzg from './Kzg.js'
1552
+
1553
+ /**
1554
+ * Utilities & types for working with Logs as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/receipt.yaml)
1555
+ *
1556
+ * :::tip
1557
+ *
1558
+ * Utilities for Log encoding & decoding can be found on the {@link ox#AbiEvent} module.
1559
+ *
1560
+ * :::
1561
+ *
1562
+ * @example
1563
+ * ### Converting from RPC Format
1564
+ *
1565
+ * Logs can be converted from their RPC format using {@link ox#Log.(fromRpc:function)}:
1566
+ *
1567
+ * ```ts twoslash
1568
+ * import 'ox/window'
1569
+ * import { AbiEvent, Hex, Log } from 'ox'
1570
+ *
1571
+ * const transfer = AbiEvent.from(
1572
+ * 'event Transfer(address indexed from, address indexed to, uint256 indexed value)',
1573
+ * )
1574
+ *
1575
+ * const { topics } = AbiEvent.encode(transfer)
1576
+ *
1577
+ * const logs = await window.ethereum!.request({
1578
+ * method: 'eth_getLogs',
1579
+ * params: [
1580
+ * {
1581
+ * address: '0xfba3912ca04dd458c843e2ee08967fc04f3579c2',
1582
+ * fromBlock: Hex.fromNumber(19760235n),
1583
+ * toBlock: Hex.fromNumber(19760240n),
1584
+ * topics,
1585
+ * },
1586
+ * ],
1587
+ * })
1588
+ *
1589
+ * const log = Log.fromRpc(logs[0]) // [!code focus]
1590
+ * // @log: {
1591
+ * // @log: address: '0xfba3912ca04dd458c843e2ee08967fc04f3579c2',
1592
+ * // @log: blockHash: '0xabe69134e80a12f6a93d0aa18215b5b86c2fb338bae911790ca374a8716e01a4',
1593
+ * // @log: blockNumber: 19760236n,
1594
+ * // @log: data: '0x',
1595
+ * // @log: logIndex: 271,
1596
+ * // @log: removed: false,
1597
+ * // @log: topics: [
1598
+ * // @log: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
1599
+ * // @log: "0x0000000000000000000000000000000000000000000000000000000000000000",
1600
+ * // @log: "0x0000000000000000000000000c04d9e9278ec5e4d424476d3ebec70cb5d648d1",
1601
+ * // @log: "0x000000000000000000000000000000000000000000000000000000000000025b",
1602
+ * // @log: transactionHash:
1603
+ * // @log: '0xcfa52db0bc2cb5bdcb2c5bd8816df7a2f018a0e3964ab1ef4d794cf327966e93',
1604
+ * // @log: transactionIndex: 145,
1605
+ * // @log: }
1606
+ * ```
1607
+ *
1608
+ * @category Execution Spec
1609
+ */
1610
+ export * as Log from './Log.js'
1611
+
1612
+ /**
1613
+ * Utility functions for generating and working with [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) mnemonics.
1614
+ *
1615
+ * :::info
1616
+ *
1617
+ * The `Mnemonic` module is a friendly wrapper over [`@scure/bip39`](https://github.com/paulmillr/scure-bip39), an **audited** implementation of [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)
1618
+ *
1619
+ * :::
1620
+ *
1621
+ * @example
1622
+ * ### Generating a Random Mnemonic
1623
+ *
1624
+ * Random mnemonics can be generated using {@link ox#Mnemonic.(random:function)}:
1625
+ *
1626
+ * ```ts twoslash
1627
+ * import { Mnemonic } from 'ox'
1628
+ *
1629
+ * const mnemonic = Mnemonic.random(Mnemonic.english)
1630
+ * // @log: 'buyer zoo end danger ice capable shrug naive twist relief mass bonus'
1631
+ * ```
1632
+ *
1633
+ * @example
1634
+ * ### Converting to Private Key
1635
+ *
1636
+ * Mnemonics can be converted to a private key using {@link ox#Mnemonic.(toPrivateKey:function)}:
1637
+ *
1638
+ * ```ts twoslash
1639
+ * import { Mnemonic } from 'ox'
1640
+ *
1641
+ * const privateKey = Mnemonic.toPrivateKey('buyer zoo end danger ice capable shrug naive twist relief mass bonus')
1642
+ * // @log: '0x...'
1643
+ * ```
1644
+ *
1645
+ * @example
1646
+ * ### Converting to HD Key
1647
+ *
1648
+ * Mnemonics can be converted to a HD Key using {@link ox#Mnemonic.(toHdKey:function)}:
1649
+ *
1650
+ * ```ts twoslash
1651
+ * import { Mnemonic } from 'ox'
1652
+ *
1653
+ * const hdKey = Mnemonic.toHdKey('buyer zoo end danger ice capable shrug naive twist relief mass bonus')
1654
+ * ```
1655
+ *
1656
+ * @example
1657
+ * ### Converting to Seed
1658
+ *
1659
+ * Mnemonics can be converted to a master seed using {@link ox#Mnemonic.(toSeed:function)}:
1660
+ *
1661
+ * ```ts twoslash
1662
+ * import { Mnemonic } from 'ox'
1663
+ *
1664
+ * const mnemonic = 'buyer zoo end danger ice capable shrug naive twist relief mass bonus'
1665
+ * const seed = Mnemonic.toSeed(mnemonic)
1666
+ * // @log: Uint8Array [...64 bytes]
1667
+ * ```
1668
+ *
1669
+ * @category Crypto
1670
+ */
1671
+ export * as Mnemonic from './Mnemonic.js'
1672
+
1673
+ /**
1674
+ * Utilities & types for working with [EIP-191 Personal Messages](https://eips.ethereum.org/EIPS/eip-191#version-0x45-e)
1675
+ *
1676
+ * @example
1677
+ * ### Computing Sign Payload
1678
+ *
1679
+ * An EIP-191 personal sign payload can be computed using {@link ox#PersonalMessage.(getSignPayload:function)}:
1680
+ *
1681
+ * ```ts twoslash
1682
+ * import { Hex, PersonalMessage, Secp256k1 } from 'ox'
1683
+ *
1684
+ * const payload = PersonalMessage.getSignPayload(Hex.fromString('hello world')) // [!code focus]
1685
+ *
1686
+ * const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
1687
+ * ```
1688
+ *
1689
+ * @category Signed & Typed Data
1690
+ */
1691
+ export * as PersonalMessage from './PersonalMessage.js'
1692
+
1693
+ /**
1694
+ * Utilities & types for working with [EIP-1193 Providers](https://eips.ethereum.org/EIPS/eip-1193)
1695
+ *
1696
+ * @example
1697
+ * ### Instantiating External Providers
1698
+ *
1699
+ * External EIP-1193 Providers can be instantiated with {@link ox#Provider.(from:function)}:
1700
+ *
1701
+ * ```ts twoslash
1702
+ * import 'ox/window'
1703
+ * import { Provider } from 'ox'
1704
+ *
1705
+ * const provider = Provider.from(window.ethereum)
1706
+ *
1707
+ * const blockNumber = await provider.request({ method: 'eth_blockNumber' })
1708
+ * ```
1709
+ *
1710
+ * :::tip
1711
+ *
1712
+ * There are also libraries that distribute EIP-1193 Provider objects that you can use with `Provider.from`:
1713
+ *
1714
+ * - [`@walletconnect/ethereum-provider`](https://www.npmjs.com/package/\@walletconnect/ethereum-provider)
1715
+ *
1716
+ * - [`@coinbase/wallet-sdk`](https://www.npmjs.com/package/\@coinbase/wallet-sdk)
1717
+ *
1718
+ * - [`@metamask/detect-provider`](https://www.npmjs.com/package/\@metamask/detect-provider)
1719
+ *
1720
+ * - [`@safe-global/safe-apps-provider`](https://github.com/safe-global/safe-apps-sdk/tree/main/packages/safe-apps-provider)
1721
+ *
1722
+ * - [`mipd`](https://github.com/wevm/mipd): EIP-6963 Multi Injected Providers
1723
+ *
1724
+ * :::
1725
+ *
1726
+ * @example
1727
+ * ### Instantiating with an RPC Transport
1728
+ *
1729
+ * Ox's {@link ox#RpcTransport} is also EIP-1193 compliant, and can be used to instantiate an EIP-1193 Provider. This means you can use any HTTP RPC endpoint as an EIP-1193 Provider.
1730
+ *
1731
+ * ```ts twoslash
1732
+ * import { Provider, RpcTransport } from 'ox'
1733
+ *
1734
+ * const transport = RpcTransport.fromHttp('https://1.rpc.thirdweb.com')
1735
+ * const provider = Provider.from(transport)
1736
+ * ```
1737
+ *
1738
+ * @example
1739
+ * ### Instantiating a Provider with Events
1740
+ *
1741
+ * Event emitters for EIP-1193 Providers can be created using {@link ox#Provider.(createEmitter:function)}:
1742
+ *
1743
+ * Useful for Wallets that distribute an EIP-1193 Provider (e.g. webpage injection via `window.ethereum`).
1744
+ *
1745
+ * ```ts twoslash
1746
+ * import { Provider, RpcRequest, RpcResponse } from 'ox'
1747
+ *
1748
+ * // 1. Instantiate a Provider Emitter.
1749
+ * const emitter = Provider.createEmitter() // [!code ++]
1750
+ *
1751
+ * const store = RpcRequest.createStore()
1752
+ *
1753
+ * const provider = Provider.from({
1754
+ * // 2. Pass the Emitter to the Provider.
1755
+ * ...emitter, // [!code ++]
1756
+ * async request(args) {
1757
+ * return await fetch('https://1.rpc.thirdweb.com', {
1758
+ * body: JSON.stringify(store.prepare(args)),
1759
+ * method: 'POST',
1760
+ * headers: {
1761
+ * 'Content-Type': 'application/json',
1762
+ * },
1763
+ * })
1764
+ * .then((res) => res.json())
1765
+ * .then(RpcResponse.parse)
1766
+ * },
1767
+ * })
1768
+ *
1769
+ * // 3. Emit Provider Events.
1770
+ * emitter.emit('accountsChanged', ['0x...']) // [!code ++]
1771
+ * ```
1772
+ *
1773
+ * @category Providers (EIP-1193)
1774
+ */
1775
+ export * as Provider from './Provider.js'
1776
+
1777
+ /**
1778
+ * Utility functions for working with ECDSA public keys.
1779
+ *
1780
+ * @example
1781
+ * ### Serializing Public Keys
1782
+ *
1783
+ * Public Keys can be serialized to Hex or Bytes using {@link ox#PublicKey.(toHex:function)}:
1784
+ *
1785
+ * ```ts twoslash
1786
+ * import { PublicKey } from 'ox'
1787
+ *
1788
+ * const publicKey = PublicKey.from({
1789
+ * prefix: 4,
1790
+ * x: 59295962801117472859457908919941473389380284132224861839820747729565200149877n,
1791
+ * y: 24099691209996290925259367678540227198235484593389470330605641003500238088869n,
1792
+ * })
1793
+ *
1794
+ * const serialized = PublicKey.toHex(publicKey) // [!code focus]
1795
+ * // @log: '0x048318535b54105d4a7aae60c08fc45f9687181b4fdfc625bd1a753fa7397fed753547f11ca8696646f2f3acb08e31016afac23e630c5d11f59f61fef57b0d2aa5'
1796
+ * ```
1797
+ *
1798
+ * @example
1799
+ * ### Deserializing Public Keys
1800
+ *
1801
+ * Public Keys can be deserialized from Hex or Bytes using {@link ox#PublicKey.(fromHex:function)}:
1802
+ *
1803
+ * ```ts twoslash
1804
+ * import { PublicKey } from 'ox'
1805
+ *
1806
+ * const publicKey = PublicKey.fromHex('0x8318535b54105d4a7aae60c08fc45f9687181b4fdfc625bd1a753fa7397fed753547f11ca8696646f2f3acb08e31016afac23e630c5d11f59f61fef57b0d2aa5')
1807
+ * // @log: {
1808
+ * // @log: prefix: 4,
1809
+ * // @log: x: 59295962801117472859457908919941473389380284132224861839820747729565200149877n,
1810
+ * // @log: y: 24099691209996290925259367678540227198235484593389470330605641003500238088869n,
1811
+ * // @log: }
1812
+ * ```
1813
+ *
1814
+ * @category Crypto
1815
+ */
1816
+ export * as PublicKey from './PublicKey.js'
1817
+
1818
+ export type { Register } from './internal/register.js'
1819
+
1820
+ /**
1821
+ * Utility functions for encoding and decoding [Recursive Length Prefix](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/) structures.
1822
+ *
1823
+ * @example
1824
+ * ```ts twoslash
1825
+ * import { Hex, Rlp } from 'ox'
1826
+ *
1827
+ * const data = Rlp.fromHex([Hex.fromString('hello'), Hex.fromString('world')])
1828
+ * // @log: '0xcc8568656c6c6f85776f726c64'
1829
+ *
1830
+ * const values = Rlp.toHex(data)
1831
+ * // @log: [Hex.fromString('hello'), Hex.fromString('world')]
1832
+ * ```
1833
+ *
1834
+ * @category Data
1835
+ */
1836
+ export * as Rlp from './Rlp.js'
1837
+
1838
+ /**
1839
+ * Utility types for working with Ethereum JSON-RPC namespaces & schemas.
1840
+ *
1841
+ * @category JSON-RPC
1842
+ */
1843
+ export * as RpcSchema from './RpcSchema.js'
1844
+
1845
+ /**
1846
+ * Utility types & functions for working with [JSON-RPC 2.0 Requests](https://www.jsonrpc.org/specification#request_object) and Ethereum JSON-RPC methods as
1847
+ * defined on the [Ethereum API specification](https://github.com/ethereum/execution-apis)
1848
+ *
1849
+ * @example
1850
+ * ### Instantiating a Request Store
1851
+ *
1852
+ * A Request Store can be instantiated using {@link ox#RpcRequest.(createStore:function)}:
1853
+ *
1854
+ * ```ts twoslash
1855
+ * import { RpcRequest } from 'ox'
1856
+ *
1857
+ * const store = RpcRequest.createStore()
1858
+ *
1859
+ * const request_1 = store.prepare({
1860
+ * method: 'eth_blockNumber',
1861
+ * })
1862
+ * // @log: { id: 0, jsonrpc: '2.0', method: 'eth_blockNumber' }
1863
+ *
1864
+ * const request_2 = store.prepare({
1865
+ * method: 'eth_call',
1866
+ * params: [
1867
+ * {
1868
+ * to: '0x0000000000000000000000000000000000000000',
1869
+ * data: '0xdeadbeef',
1870
+ * },
1871
+ * ],
1872
+ * })
1873
+ * // @log: { id: 1, jsonrpc: '2.0', method: 'eth_call', params: [{ to: '0x0000000000000000000000000000000000000000', data: '0xdeadbeef' }] }
1874
+ * ```
1875
+ *
1876
+ * @category JSON-RPC
1877
+ */
1878
+ export * as RpcRequest from './RpcRequest.js'
1879
+
1880
+ /**
1881
+ * Utility types & functions for working with [JSON-RPC 2.0 Responses](https://www.jsonrpc.org/specification#response_object)
1882
+ *
1883
+ * @example
1884
+ * ### Instantiating an RPC Response
1885
+ *
1886
+ * RPC Responses can be instantiated using {@link ox#RpcResponse.(from:function)}:
1887
+ *
1888
+ * ```ts twoslash
1889
+ * import { RpcResponse } from 'ox'
1890
+ *
1891
+ * const response = RpcResponse.from({
1892
+ * id: 0,
1893
+ * jsonrpc: '2.0',
1894
+ * result: '0x69420',
1895
+ * })
1896
+ * ```
1897
+ *
1898
+ * :::note
1899
+ *
1900
+ * Type-safe instantiation from a `request` object is also supported. If a `request` is provided, then the `id` and `jsonrpc` properties will be overridden with the values from the request.
1901
+ *
1902
+ * ```ts twoslash
1903
+ * import { RpcRequest, RpcResponse } from 'ox'
1904
+ *
1905
+ * const request = RpcRequest.from({ id: 0, method: 'eth_blockNumber' })
1906
+ *
1907
+ * const response = RpcResponse.from(
1908
+ * { result: '0x69420' },
1909
+ * { request },
1910
+ * )
1911
+ * ```
1912
+ *
1913
+ * :::
1914
+ *
1915
+ * @example
1916
+ * ### Parsing an RPC Response
1917
+ *
1918
+ * RPC Responses can be parsed using {@link ox#RpcResponse.(parse:function)}:
1919
+ *
1920
+ * ```ts twoslash
1921
+ * import { RpcRequest, RpcResponse } from 'ox'
1922
+ *
1923
+ * // 1. Create a request store.
1924
+ * const store = RpcRequest.createStore()
1925
+ *
1926
+ * // 2. Get a request object.
1927
+ * const request = store.prepare({
1928
+ * method: 'eth_getBlockByNumber',
1929
+ * params: ['0x1', false],
1930
+ * })
1931
+ *
1932
+ * // 3. Send the JSON-RPC request via HTTP.
1933
+ * const block = await fetch('https://1.rpc.thirdweb.com', {
1934
+ * body: JSON.stringify(request),
1935
+ * headers: {
1936
+ * 'Content-Type': 'application/json',
1937
+ * },
1938
+ * method: 'POST',
1939
+ * })
1940
+ * .then((response) => response.json())
1941
+ * // 4. Parse the JSON-RPC response into a type-safe result. // [!code focus]
1942
+ * .then((response) => RpcResponse.parse(response, { request })) // [!code focus]
1943
+ *
1944
+ * block // [!code focus]
1945
+ * // ^?
1946
+ *
1947
+ *
1948
+ *
1949
+ *
1950
+ *
1951
+ *
1952
+ *
1953
+ *
1954
+ *
1955
+ *
1956
+ *
1957
+ * ```
1958
+ *
1959
+ * @category JSON-RPC
1960
+ */
1961
+ export * as RpcResponse from './RpcResponse.js'
1962
+
1963
+ /**
1964
+ * Utility functions for working with JSON-RPC Transports.
1965
+ *
1966
+ * :::note
1967
+ * This is a convenience module distributed for experimenting with network connectivity on Ox.
1968
+ *
1969
+ * Consider using networking functionality from a higher-level library such as [Viem's Transports](https://viem.sh/docs/clients/transports/http)
1970
+ * if you need more features such as: retry logic, WebSockets/IPC, middleware, batch JSON-RPC, etc.
1971
+ * :::
1972
+ *
1973
+ * @example
1974
+ * ### HTTP Instantiation
1975
+ *
1976
+ * ```ts twoslash
1977
+ * import { RpcTransport } from 'ox'
1978
+ *
1979
+ * const transport = RpcTransport.fromHttp('https://1.rpc.thirdweb.com')
1980
+ *
1981
+ * const blockNumber = await transport.request({ method: 'eth_blockNumber' })
1982
+ * // @log: '0x1a2b3c'
1983
+ * ```
1984
+ *
1985
+ * @category JSON-RPC
1986
+ */
1987
+ export * as RpcTransport from './RpcTransport.js'
1988
+
1989
+ /**
1990
+ * Utility functions for [secp256k1](https://www.secg.org/sec2-v2.pdf) ECDSA cryptography.
1991
+ *
1992
+ * :::info
1993
+ *
1994
+ * The `Secp256k1` module is a friendly wrapper over [`@noble/curves/secp256k1`](https://github.com/paulmillr/noble-curves), an **audited** implementation of [secp256k1](https://www.secg.org/sec2-v2.pdf)
1995
+ *
1996
+ * :::
1997
+ *
1998
+ * @example
1999
+ * ### Computing a Random Private Key
2000
+ *
2001
+ * A random private key can be computed using {@link ox#Secp256k1.(randomPrivateKey:function)}:
2002
+ *
2003
+ * ```ts twoslash
2004
+ * import { Secp256k1 } from 'ox'
2005
+ *
2006
+ * const privateKey = Secp256k1.randomPrivateKey()
2007
+ * // @log: '0x...'
2008
+ * ```
2009
+ *
2010
+ * @example
2011
+ * ### Getting a Public Key
2012
+ *
2013
+ * A public key can be derived from a private key using {@link ox#Secp256k1.(getPublicKey:function)}:
2014
+ *
2015
+ * ```ts twoslash
2016
+ * import { Secp256k1 } from 'ox'
2017
+ *
2018
+ * const privateKey = Secp256k1.randomPrivateKey()
2019
+ *
2020
+ * const publicKey = Secp256k1.getPublicKey({ privateKey }) // [!code focus]
2021
+ * // @log: { x: 3251...5152n, y: 1251...5152n }
2022
+ * ```
2023
+ *
2024
+ * @example
2025
+ * ### Signing a Payload
2026
+ *
2027
+ * A payload can be signed using {@link ox#Secp256k1.(sign:function)}:
2028
+ *
2029
+ * ```ts twoslash
2030
+ * import { Secp256k1 } from 'ox'
2031
+ *
2032
+ * const privateKey = Secp256k1.randomPrivateKey()
2033
+ *
2034
+ * const signature = Secp256k1.sign({ payload: '0xdeadbeef', privateKey }) // [!code focus]
2035
+ * // @log: { r: 1251...5152n, s: 1251...5152n, yParity: 1 }
2036
+ * ```
2037
+ *
2038
+ * @example
2039
+ * ### Verifying a Signature
2040
+ *
2041
+ * A signature can be verified using {@link ox#Secp256k1.(verify:function)}:
2042
+ *
2043
+ * ```ts twoslash
2044
+ * import { Secp256k1 } from 'ox'
2045
+ *
2046
+ * const privateKey = Secp256k1.randomPrivateKey()
2047
+ * const publicKey = Secp256k1.getPublicKey({ privateKey })
2048
+ * const signature = Secp256k1.sign({ payload: '0xdeadbeef', privateKey })
2049
+ *
2050
+ * const isValid = Secp256k1.verify({ // [!code focus]
2051
+ * payload: '0xdeadbeef', // [!code focus]
2052
+ * publicKey, // [!code focus]
2053
+ * signature, // [!code focus]
2054
+ * }) // [!code focus]
2055
+ * // @log: true
2056
+ * ```
2057
+ *
2058
+ * @category Crypto
2059
+ */
2060
+ export * as Secp256k1 from './Secp256k1.js'
2061
+
2062
+ /**
2063
+ * Utility functions for [NIST P256](https://csrc.nist.gov/csrc/media/events/workshop-on-elliptic-curve-cryptography-standards/documents/papers/session6-adalier-mehmet.pdf) ECDSA cryptography.
2064
+ *
2065
+ * :::info
2066
+ *
2067
+ * The `P256` module is a friendly wrapper over [`@noble/curves/p256`](https://github.com/paulmillr/noble-curves), an **audited** implementation of [P256](https://www.secg.org/sec2-v2.pdf)
2068
+ *
2069
+ * :::
2070
+ *
2071
+ * @example
2072
+ * ### Computing a Random Private Key
2073
+ *
2074
+ * A random private key can be computed using {@link ox#P256.(randomPrivateKey:function)}:
2075
+ *
2076
+ * ```ts twoslash
2077
+ * import { P256 } from 'ox'
2078
+ *
2079
+ * const privateKey = P256.randomPrivateKey()
2080
+ * // @log: '0x...'
2081
+ * ```
2082
+ *
2083
+ * @example
2084
+ * ### Getting a Public Key
2085
+ *
2086
+ * A public key can be derived from a private key using {@link ox#P256.(getPublicKey:function)}:
2087
+ *
2088
+ * ```ts twoslash
2089
+ * import { P256 } from 'ox'
2090
+ *
2091
+ * const privateKey = P256.randomPrivateKey()
2092
+ *
2093
+ * const publicKey = P256.getPublicKey({ privateKey }) // [!code focus]
2094
+ * // @log: { x: 3251...5152n, y: 1251...5152n }
2095
+ * ```
2096
+ *
2097
+ * @example
2098
+ * ### Signing a Payload
2099
+ *
2100
+ * A payload can be signed using {@link ox#P256.(sign:function)}:
2101
+ *
2102
+ * ```ts twoslash
2103
+ * import { P256 } from 'ox'
2104
+ *
2105
+ * const privateKey = P256.randomPrivateKey()
2106
+ *
2107
+ * const signature = P256.sign({ payload: '0xdeadbeef', privateKey }) // [!code focus]
2108
+ * // @log: { r: 1251...5152n, s: 1251...5152n, yParity: 1 }
2109
+ * ```
2110
+ *
2111
+ * @example
2112
+ * ### Verifying a Signature
2113
+ *
2114
+ * A signature can be verified using {@link ox#P256.(verify:function)}:
2115
+ *
2116
+ * ```ts twoslash
2117
+ * import { P256 } from 'ox'
2118
+ *
2119
+ * const privateKey = P256.randomPrivateKey()
2120
+ * const publicKey = P256.getPublicKey({ privateKey })
2121
+ * const signature = P256.sign({ payload: '0xdeadbeef', privateKey })
2122
+ *
2123
+ * const isValid = P256.verify({ // [!code focus]
2124
+ * payload: '0xdeadbeef', // [!code focus]
2125
+ * publicKey, // [!code focus]
2126
+ * signature, // [!code focus]
2127
+ * }) // [!code focus]
2128
+ * // @log: true
2129
+ * ```
2130
+ *
2131
+ * @category Crypto
2132
+ */
2133
+ export * as P256 from './P256.js'
2134
+
2135
+ /**
2136
+ * Utility functions for working with ECDSA signatures.
2137
+ *
2138
+ * @example
2139
+ * ### Serializing a Signature
2140
+ *
2141
+ * Signatures can be serialized to Hex or Bytes using {@link ox#Signature.(toHex:function)}:
2142
+ *
2143
+ * ```ts twoslash
2144
+ * import { Signature } from 'ox'
2145
+ *
2146
+ * const signature = Signature.toHex({
2147
+ * r: 49782753348462494199823712700004552394425719014458918871452329774910450607807n,
2148
+ * s: 33726695977844476214676913201140481102225469284307016937915595756355928419768n,
2149
+ * yParity: 1
2150
+ * })
2151
+ * // @log: '0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c'
2152
+ * ```
2153
+ *
2154
+ * @example
2155
+ * ### Deserializing a Signature
2156
+ *
2157
+ * Signatures can be deserialized from Hex or Bytes using {@link ox#Signature.(fromHex:function)}:
2158
+ *
2159
+ * ```ts twoslash
2160
+ * import { Signature } from 'ox'
2161
+ *
2162
+ * Signature.fromHex('0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c')
2163
+ * // @log: { r: 5231...n, s: 3522...n, yParity: 0 }
2164
+ * ```
2165
+ *
2166
+ * @category Crypto
2167
+ */
2168
+ export * as Signature from './Signature.js'
2169
+
2170
+ /**
2171
+ * Utility functions for working with
2172
+ * [EIP-4361: Sign-In with Ethereum](https://eips.ethereum.org/EIPS/eip-4361)
2173
+ *
2174
+ * @example
2175
+ * ### Creating a SIWE Message
2176
+ *
2177
+ * SIWE messages can be created using {@link ox#Siwe.(createMessage:function)}:
2178
+ *
2179
+ * ```ts twoslash
2180
+ * import { Siwe } from 'ox'
2181
+ *
2182
+ * Siwe.createMessage({
2183
+ * address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
2184
+ * chainId: 1,
2185
+ * domain: 'example.com',
2186
+ * nonce: 'foobarbaz',
2187
+ * uri: 'https://example.com/path',
2188
+ * version: '1',
2189
+ * })
2190
+ * // @log: "example.com wants you to sign in with your Ethereum account:
2191
+ * // @log: 0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
2192
+ * // @log:
2193
+ * // @log:
2194
+ * // @log: URI: https://example.com/path
2195
+ * // @log: Version: 1
2196
+ * // @log: Chain ID: 1
2197
+ * // @log: Nonce: foobarbaz
2198
+ * // @log: Issued At: 2023-02-01T00:00:00.000Z"
2199
+ * ```
2200
+ *
2201
+ * @example
2202
+ * ### Generating SIWE Nonces
2203
+ *
2204
+ * SIWE nonces can be generated using {@link ox#Siwe.(generateNonce:function)}:
2205
+ *
2206
+ * ```ts twoslash
2207
+ * import { Siwe } from 'ox'
2208
+ *
2209
+ * Siwe.generateNonce()
2210
+ * // @log: '65ed4681d4efe0270b923ff5f4b097b1c95974dc33aeebecd5724c42fd86dfd25dc70b27ef836b2aa22e68f19ebcccc1'
2211
+ * ```
2212
+ *
2213
+ * @example
2214
+ * ### Parsing a SIWE Message
2215
+ *
2216
+ * SIWE messages can be parsed using {@link ox#Siwe.(parseMessage:function)}:
2217
+ *
2218
+ * ```ts twoslash
2219
+ * import { Siwe } from 'ox'
2220
+ *
2221
+ * Siwe.parseMessage(`example.com wants you to sign in with your Ethereum account:
2222
+ * 0xA0Cf798816D4b9b9866b5330EEa46a18382f251e
2223
+ *
2224
+ * I accept the ExampleOrg Terms of Service: https://example.com/tos
2225
+ *
2226
+ * URI: https://example.com/path
2227
+ * Version: 1
2228
+ * Chain ID: 1
2229
+ * Nonce: foobarbaz
2230
+ * Issued At: 2023-02-01T00:00:00.000Z`)
2231
+ * // @log: {
2232
+ * // @log: address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
2233
+ * // @log: chainId: 1,
2234
+ * // @log: domain: 'example.com',
2235
+ * // @log: issuedAt: '2023-02-01T00:00:00.000Z',
2236
+ * // @log: nonce: 'foobarbaz',
2237
+ * // @log: statement: 'I accept the ExampleOrg Terms of Service: https://example.com/tos',
2238
+ * // @log: uri: 'https://example.com/path',
2239
+ * // @log: version: '1',
2240
+ * // @log: }
2241
+ * ```
2242
+ *
2243
+ * @example
2244
+ * ### Validating a SIWE Message
2245
+ *
2246
+ * SIWE messages can be validated using {@link ox#Siwe.(validateMessage:function)}:
2247
+ *
2248
+ * ```ts twoslash
2249
+ * import { Siwe } from 'ox'
2250
+ *
2251
+ * Siwe.validateMessage({
2252
+ * address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
2253
+ * domain: 'example.com',
2254
+ * message: {
2255
+ * address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
2256
+ * chainId: 1,
2257
+ * domain: 'example.com',
2258
+ * nonce: 'foobarbaz',
2259
+ * uri: 'https://example.com/path',
2260
+ * version: '1',
2261
+ * },
2262
+ * nonce: 'foobarbaz',
2263
+ * })
2264
+ * // @log: true
2265
+ * ```
2266
+ *
2267
+ * @category Sign-In with Ethereum (EIP-4361)
2268
+ */
2269
+ export * as Siwe from './Siwe.js'
2270
+
2271
+ export * as Solidity from './Solidity.js'
2272
+
2273
+ /**
2274
+ * Utilities & types for working with **Transactions** as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/transaction.yaml)
2275
+ *
2276
+ * @example
2277
+ * ### Converting from RPC Format
2278
+ *
2279
+ * Transactions can be converted from RPC format using {@link ox#Transaction.(fromRpc:function)}:
2280
+ *
2281
+ * ```ts twoslash
2282
+ * import { Transaction } from 'ox'
2283
+ *
2284
+ * const transaction = Transaction.fromRpc({
2285
+ * hash: '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
2286
+ * nonce: '0x357',
2287
+ * blockHash:
2288
+ * '0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b',
2289
+ * blockNumber: '0x12f296f',
2290
+ * transactionIndex: '0x2',
2291
+ * from: '0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6',
2292
+ * to: '0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad',
2293
+ * value: '0x9b6e64a8ec60000',
2294
+ * gas: '0x43f5d',
2295
+ * maxFeePerGas: '0x2ca6ae494',
2296
+ * maxPriorityFeePerGas: '0x41cc3c0',
2297
+ * input:
2298
+ * '0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000006643504700000000000000000000000000000000000000000000000000000000000000040b080604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec600000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000009b6e64a8ec60000000000000000000000000000000000000000000000000000019124bb5ae978c000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b80000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b8000000000000000000000000000000fee13a103a10d593b9ae06b3e05f2e7e1c00000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c56c7a0eaa804f854b536a5f3d5f49d2ec4b12b800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000190240001b9872b',
2299
+ * r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',
2300
+ * s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',
2301
+ * yParity: '0x0',
2302
+ * chainId: '0x1',
2303
+ * accessList: [],
2304
+ * type: '0x2',
2305
+ * })
2306
+ * ```
2307
+ *
2308
+ * @category Execution Spec
2309
+ */
2310
+ export * as Transaction from './Transaction.js'
2311
+
2312
+ /**
2313
+ * Errors & Types for working with Transaction Envelopes.
2314
+ *
2315
+ * :::note
2316
+ * Refer to the following modules for specific Transaction Envelope types:
2317
+ * - [`TransactionEnvelopeLegacy`](/api/TransactionEnvelopeLegacy)
2318
+ * - [`TransactionEnvelopeEip1559`](/api/TransactionEnvelopeEip1559)
2319
+ * - [`TransactionEnvelopeEip2930`](/api/TransactionEnvelopeEip2930)
2320
+ * - [`TransactionEnvelopeEip4844`](/api/TransactionEnvelopeEip4844)
2321
+ * - [`TransactionEnvelopeEip7702`](/api/TransactionEnvelopeEip7702)
2322
+ * :::
2323
+ *
2324
+ * @category Transaction Envelopes
2325
+ */
2326
+ export * as TransactionEnvelope from './TransactionEnvelope.js'
2327
+
2328
+ /**
2329
+ * Utility functions for working
2330
+ * with **Legacy Transaction Envelopes**.
2331
+ *
2332
+ * @example
2333
+ * ### Instantiating
2334
+ *
2335
+ * Transaction Envelopes can be instantiated using {@link ox#TransactionEnvelopeLegacy.(from:function)}:
2336
+ *
2337
+ * ```ts twoslash
2338
+ * import { TransactionEnvelopeLegacy, Value } from 'ox'
2339
+ *
2340
+ * const envelope = TransactionEnvelopeLegacy.from({
2341
+ * gasPrice: Value.fromGwei('10'),
2342
+ * to: '0x0000000000000000000000000000000000000000',
2343
+ * value: Value.fromEther('1'),
2344
+ * })
2345
+ * ```
2346
+ *
2347
+ * * @example
2348
+ * ### Signing
2349
+ *
2350
+ * Transaction Envelopes can be signed using {@link ox#TransactionEnvelopeLegacy.(getSignPayload:function)} and a signing function such as {@link ox#Secp256k1.(sign:function)} or {@link ox#P256.(sign:function)}:
2351
+ *
2352
+ * ```ts twoslash
2353
+ * // @noErrors
2354
+ * import { Secp256k1, TransactionEnvelopeLegacy } from 'ox'
2355
+ *
2356
+ * const envelope = TransactionEnvelopeLegacy.from({
2357
+ * nonce: 0n,
2358
+ * gasPrice: 1000000000n,
2359
+ * gas: 21000n,
2360
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2361
+ * value: 1000000000000000000n,
2362
+ * })
2363
+ *
2364
+ * const signature = Secp256k1.sign({ // [!code focus]
2365
+ * payload: TransactionEnvelopeLegacy.getSignPayload(envelope), // [!code focus]
2366
+ * privateKey: '0x...' // [!code focus]
2367
+ * }) // [!code focus]
2368
+ *
2369
+ * const envelope_signed = TransactionEnvelopeLegacy.from(envelope, { signature })
2370
+ * ```
2371
+ *
2372
+ * @example
2373
+ * ### Serializing
2374
+ *
2375
+ * Transaction Envelopes can be serialized using {@link ox#TransactionEnvelopeLegacy.(serialize:function)}:
2376
+ *
2377
+ * ```ts twoslash
2378
+ * import { TransactionEnvelopeLegacy, Value } from 'ox'
2379
+ *
2380
+ * const envelope = TransactionEnvelopeLegacy.from({
2381
+ * chainId: 1,
2382
+ * gasPrice: Value.fromGwei('10'),
2383
+ * to: '0x0000000000000000000000000000000000000000',
2384
+ * value: Value.fromEther('1'),
2385
+ * })
2386
+ *
2387
+ * const serialized = TransactionEnvelopeLegacy.serialize(envelope) // [!code focus]
2388
+ * ```
2389
+ *
2390
+ * @example
2391
+ * ### Sending
2392
+ *
2393
+ * We can send a Transaction Envelope to the network by serializing the signed envelope with `.serialize`, and then broadcasting it over JSON-RPC with `eth_sendRawTransaction`.
2394
+ *
2395
+ * In this example, we will use {@link ox#RpcTransport.(fromHttp:function)} to broadcast a `eth_sendRawTransaction` request over HTTP JSON-RPC.
2396
+ *
2397
+ * ```ts twoslash
2398
+ * import { RpcTransport, TransactionEnvelopeLegacy, Secp256k1, Value } from 'ox'
2399
+ *
2400
+ * // Construct the Envelope.
2401
+ * const envelope = TransactionEnvelopeLegacy.from({
2402
+ * chainId: 1,
2403
+ * gasPrice: Value.fromGwei('10'),
2404
+ * nonce: 69n,
2405
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2406
+ * value: Value.fromEther('1.5'),
2407
+ * })
2408
+ *
2409
+ * // Sign over the Envelope.
2410
+ * const signature = Secp256k1.sign({
2411
+ * payload: TransactionEnvelopeLegacy.getSignPayload(envelope),
2412
+ * privateKey: '0x...',
2413
+ * })
2414
+ *
2415
+ * // Serialize the Envelope with the Signature. // [!code focus]
2416
+ * const serialized = TransactionEnvelopeLegacy.serialize(envelope, { // [!code focus]
2417
+ * signature // [!code focus]
2418
+ * }) // [!code focus]
2419
+ *
2420
+ * // Broadcast the Envelope with `eth_sendRawTransaction`. // [!code focus]
2421
+ * const transport = RpcTransport.fromHttp('https://1.rpc.thirdweb.com') // [!code focus]
2422
+ * const hash = await transport.request({ // [!code focus]
2423
+ * method: 'eth_sendRawTransaction', // [!code focus]
2424
+ * params: [serialized], // [!code focus]
2425
+ * }) // [!code focus]
2426
+ * ```
2427
+ *
2428
+ * If you are interfacing with an RPC that supports `eth_sendTransaction`, you can also use
2429
+ * {@link ox#TransactionEnvelopeLegacy.(toRpc:function)} to convert an Envelope to an RPC-compatible format.
2430
+ * This means you can skip the ceremony of manually filling & signing the Transaction.
2431
+ *
2432
+ * ```ts twoslash
2433
+ * import 'ox/window'
2434
+ * import { Provider, TransactionEnvelopeLegacy, Value } from 'ox'
2435
+ *
2436
+ * const envelope = TransactionEnvelopeLegacy.from({
2437
+ * chainId: 1,
2438
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2439
+ * value: Value.fromEther('1.5'),
2440
+ * })
2441
+ *
2442
+ * const envelope_rpc = TransactionEnvelopeLegacy.toRpc(envelope)
2443
+ *
2444
+ * const provider = Provider.from(window.ethereum)
2445
+ * const hash = await provider.request({
2446
+ * method: 'eth_sendTransaction',
2447
+ * params: [envelope_rpc],
2448
+ * })
2449
+ * ```
2450
+ *
2451
+ * @example
2452
+ * ### Computing Hashes
2453
+ *
2454
+ * Transaction Hashes can be computed using {@link ox#TransactionEnvelopeLegacy.(hash:function)}:
2455
+ *
2456
+ * ```ts twoslash
2457
+ * import { Secp256k1, TransactionEnvelopeLegacy } from 'ox'
2458
+ *
2459
+ * const envelope = TransactionEnvelopeLegacy.from({
2460
+ * chainId: 1,
2461
+ * nonce: 0n,
2462
+ * gasPrice: 1000000000n,
2463
+ * gas: 21000n,
2464
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2465
+ * value: 1000000000000000000n,
2466
+ * data: '0x',
2467
+ * })
2468
+ *
2469
+ * const signature = Secp256k1.sign({
2470
+ * payload: TransactionEnvelopeLegacy.getSignPayload(envelope),
2471
+ * privateKey: '0x...'
2472
+ * })
2473
+ *
2474
+ * const envelope_signed = TransactionEnvelopeLegacy.from(envelope, { signature })
2475
+ *
2476
+ * const hash = TransactionEnvelopeLegacy.hash(envelope_signed) // [!code focus]
2477
+ * ```
2478
+ *
2479
+ * @category Transaction Envelopes
2480
+ */
2481
+ export * as TransactionEnvelopeLegacy from './TransactionEnvelopeLegacy.js'
2482
+
2483
+ /**
2484
+ * Utility functions for working with [EIP-1559 Typed Transaction Envelopes](https://eips.ethereum.org/EIPS/eip-1559)
2485
+ *
2486
+ * @example
2487
+ * ### Instantiating
2488
+ *
2489
+ * Transaction Envelopes can be instantiated using {@link ox#TransactionEnvelopeEip1559.(from:function)}:
2490
+ *
2491
+ * ```ts twoslash
2492
+ * import { TransactionEnvelopeEip1559, Value } from 'ox'
2493
+ *
2494
+ * const envelope = TransactionEnvelopeEip1559.from({
2495
+ * chainId: 1,
2496
+ * maxFeePerGas: Value.fromGwei('10'),
2497
+ * maxPriorityFeePerGas: Value.fromGwei('1'),
2498
+ * to: '0x0000000000000000000000000000000000000000',
2499
+ * value: Value.fromEther('1'),
2500
+ * })
2501
+ * // @log: {
2502
+ * // @log: chainId: 1,
2503
+ * // @log: maxFeePerGas: 10000000000n,
2504
+ * // @log: maxPriorityFeePerGas: 1000000000n,
2505
+ * // @log: to: '0x0000000000000000000000000000000000000000',
2506
+ * // @log: type: 'eip1559',
2507
+ * // @log: value: 1000000000000000000n,
2508
+ * // @log: }
2509
+ * ```
2510
+ *
2511
+ * @example
2512
+ * ### Signing
2513
+ *
2514
+ * Transaction Envelopes can be signed using {@link ox#TransactionEnvelopeEip1559.(getSignPayload:function)} and a signing function such as {@link ox#Secp256k1.(sign:function)} or {@link ox#P256.(sign:function)}:
2515
+ *
2516
+ * ```ts twoslash
2517
+ * import { Secp256k1, TransactionEnvelopeEip1559 } from 'ox'
2518
+ *
2519
+ * const envelope = TransactionEnvelopeEip1559.from({
2520
+ * chainId: 1,
2521
+ * nonce: 0n,
2522
+ * gasPrice: 1000000000n,
2523
+ * gas: 21000n,
2524
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2525
+ * value: 1000000000000000000n,
2526
+ * })
2527
+ *
2528
+ * const signature = Secp256k1.sign({ // [!code focus]
2529
+ * payload: TransactionEnvelopeEip1559.getSignPayload(envelope), // [!code focus]
2530
+ * privateKey: '0x...' // [!code focus]
2531
+ * }) // [!code focus]
2532
+ *
2533
+ * const envelope_signed = TransactionEnvelopeEip1559.from(envelope, { signature })
2534
+ * ```
2535
+ *
2536
+ * @example
2537
+ * ### Serializing
2538
+ *
2539
+ * Transaction Envelopes can be serialized using {@link ox#TransactionEnvelopeEip1559.(serialize:function)}:
2540
+ *
2541
+ * ```ts twoslash
2542
+ * import { TransactionEnvelopeEip1559, Value } from 'ox'
2543
+ *
2544
+ * const envelope = TransactionEnvelopeEip1559.from({
2545
+ * chainId: 1,
2546
+ * maxFeePerGas: Value.fromGwei('10'),
2547
+ * maxPriorityFeePerGas: Value.fromGwei('1'),
2548
+ * to: '0x0000000000000000000000000000000000000000',
2549
+ * value: Value.fromEther('1'),
2550
+ * })
2551
+ *
2552
+ * const serialized = TransactionEnvelopeEip1559.serialize(envelope) // [!code focus]
2553
+ * ```
2554
+ *
2555
+ * @example
2556
+ * ### Sending
2557
+ *
2558
+ * We can send a Transaction Envelope to the network by serializing the signed envelope with `.serialize`, and then broadcasting it over JSON-RPC with `eth_sendRawTransaction`.
2559
+ *
2560
+ * In this example, we will use {@link ox#RpcTransport.(fromHttp:function)} to broadcast a `eth_sendRawTransaction` request over HTTP JSON-RPC.
2561
+ *
2562
+ * ```ts twoslash
2563
+ * import { RpcTransport, TransactionEnvelopeEip1559, Secp256k1, Value } from 'ox'
2564
+ *
2565
+ * // Construct the Envelope.
2566
+ * const envelope = TransactionEnvelopeEip1559.from({
2567
+ * chainId: 1,
2568
+ * maxFeePerGas: Value.fromGwei('10'),
2569
+ * maxPriorityFeePerGas: Value.fromGwei('1'),
2570
+ * nonce: 69n,
2571
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2572
+ * value: Value.fromEther('1.5'),
2573
+ * })
2574
+ *
2575
+ * // Sign over the Envelope.
2576
+ * const signature = Secp256k1.sign({
2577
+ * payload: TransactionEnvelopeEip1559.getSignPayload(envelope),
2578
+ * privateKey: '0x...',
2579
+ * })
2580
+ *
2581
+ * // Serialize the Envelope with the Signature. // [!code focus]
2582
+ * const serialized = TransactionEnvelopeEip1559.serialize(envelope, { // [!code focus]
2583
+ * signature // [!code focus]
2584
+ * }) // [!code focus]
2585
+ *
2586
+ * // Broadcast the Envelope with `eth_sendRawTransaction`. // [!code focus]
2587
+ * const transport = RpcTransport.fromHttp('https://1.rpc.thirdweb.com') // [!code focus]
2588
+ * const hash = await transport.request({ // [!code focus]
2589
+ * method: 'eth_sendRawTransaction', // [!code focus]
2590
+ * params: [serialized], // [!code focus]
2591
+ * }) // [!code focus]
2592
+ * ```
2593
+ *
2594
+ * If you are interfacing with an RPC that supports `eth_sendTransaction`, you can also use
2595
+ * {@link ox#TransactionEnvelopeEip1559.(toRpc:function)} to convert an Envelope to an RPC-compatible format.
2596
+ * This means you can skip the ceremony of manually filling & signing the Transaction.
2597
+ *
2598
+ * ```ts twoslash
2599
+ * import 'ox/window'
2600
+ * import { Provider, TransactionEnvelopeEip1559, Value } from 'ox'
2601
+ *
2602
+ * const envelope = TransactionEnvelopeEip1559.from({
2603
+ * chainId: 1,
2604
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2605
+ * value: Value.fromEther('1.5'),
2606
+ * })
2607
+ *
2608
+ * const envelope_rpc = TransactionEnvelopeEip1559.toRpc(envelope)
2609
+ *
2610
+ * const provider = Provider.from(window.ethereum)
2611
+ * const hash = await provider.request({
2612
+ * method: 'eth_sendTransaction',
2613
+ * params: [envelope_rpc],
2614
+ * })
2615
+ * ```
2616
+ *
2617
+ * @example
2618
+ * ### Computing Hashes
2619
+ *
2620
+ * Transaction Hashes can be computed using {@link ox#TransactionEnvelopeEip1559.(hash:function)}:
2621
+ *
2622
+ * ```ts twoslash
2623
+ * import { Secp256k1, TransactionEnvelopeEip1559, Value } from 'ox'
2624
+ *
2625
+ * const envelope = TransactionEnvelopeEip1559.from({
2626
+ * chainId: 1,
2627
+ * nonce: 0n,
2628
+ * maxFeePerGas: Value.fromGwei('10'),
2629
+ * maxPriorityFeePerGas: Value.fromGwei('1'),
2630
+ * gas: 21000n,
2631
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2632
+ * value: 1000000000000000000n,
2633
+ * data: '0x',
2634
+ * })
2635
+ *
2636
+ * const signature = Secp256k1.sign({
2637
+ * payload: TransactionEnvelopeEip1559.getSignPayload(envelope),
2638
+ * privateKey: '0x...'
2639
+ * })
2640
+ *
2641
+ * const envelope_signed = TransactionEnvelopeEip1559.from(envelope, { signature })
2642
+ *
2643
+ * const hash = TransactionEnvelopeEip1559.hash(envelope_signed) // [!code focus]
2644
+ * ```
2645
+ *
2646
+ * @category Transaction Envelopes
2647
+ */
2648
+ export * as TransactionEnvelopeEip1559 from './TransactionEnvelopeEip1559.js'
2649
+
2650
+ /**
2651
+ * Utility functions for working with [EIP-2930 Typed Transaction Envelopes](https://eips.ethereum.org/EIPS/eip-2930)
2652
+ *
2653
+ * @example
2654
+ * ### Instantiating
2655
+ *
2656
+ * Transaction Envelopes can be instantiated using {@link ox#TransactionEnvelopeEip2930.(from:function)}:
2657
+ *
2658
+ * ```ts twoslash
2659
+ * // @noErrors
2660
+ * import { TransactionEnvelopeEip2930, Value } from 'ox'
2661
+ *
2662
+ * const envelope = TransactionEnvelopeEip2930.from({
2663
+ * chainId: 1,
2664
+ * accessList: [...],
2665
+ * gasPrice: Value.fromGwei('10'),
2666
+ * to: '0x0000000000000000000000000000000000000000',
2667
+ * value: Value.fromEther('1'),
2668
+ * })
2669
+ * ```
2670
+ *
2671
+ * @example
2672
+ * ### Signing
2673
+ *
2674
+ * Transaction Envelopes can be signed using {@link ox#TransactionEnvelopeEip2930.(getSignPayload:function)} and a signing function such as {@link ox#Secp256k1.(sign:function)} or {@link ox#P256.(sign:function)}:
2675
+ *
2676
+ * ```ts twoslash
2677
+ * import { Secp256k1, TransactionEnvelopeEip2930 } from 'ox'
2678
+ *
2679
+ * const envelope = TransactionEnvelopeEip2930.from({
2680
+ * chainId: 1,
2681
+ * nonce: 0n,
2682
+ * gasPrice: 1000000000n,
2683
+ * gas: 21000n,
2684
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2685
+ * value: 1000000000000000000n,
2686
+ * })
2687
+ *
2688
+ * const payload = TransactionEnvelopeEip2930.getSignPayload(envelope) // [!code focus]
2689
+ * // @log: '0x...'
2690
+ *
2691
+ * const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
2692
+ * ```
2693
+ *
2694
+ * @example
2695
+ * ### Serializing
2696
+ *
2697
+ * Transaction Envelopes can be serialized using {@link ox#TransactionEnvelopeEip2930.(serialize:function)}:
2698
+ *
2699
+ * ```ts twoslash
2700
+ * import { Secp256k1, TransactionEnvelopeEip2930, Value } from 'ox'
2701
+ *
2702
+ * const envelope = TransactionEnvelopeEip2930.from({
2703
+ * chainId: 1,
2704
+ * nonce: 0n,
2705
+ * gasPrice: 1000000000n,
2706
+ * gas: 21000n,
2707
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2708
+ * value: 1000000000000000000n,
2709
+ * })
2710
+ *
2711
+ * const serialized = TransactionEnvelopeEip2930.serialize(envelope) // [!code focus]
2712
+ * ```
2713
+ *
2714
+ * @example
2715
+ * ### Sending
2716
+ *
2717
+ * We can send a Transaction Envelope to the network by serializing the signed envelope with `.serialize`, and then broadcasting it over JSON-RPC with `eth_sendRawTransaction`.
2718
+ *
2719
+ * In this example, we will use {@link ox#RpcTransport.(fromHttp:function)} to broadcast a `eth_sendRawTransaction` request over HTTP JSON-RPC.
2720
+ *
2721
+ * ```ts twoslash
2722
+ * import { RpcTransport, TransactionEnvelopeEip2930, Secp256k1, Value } from 'ox'
2723
+ *
2724
+ * // Construct the Envelope.
2725
+ * const envelope = TransactionEnvelopeEip2930.from({
2726
+ * accessList: [],
2727
+ * chainId: 1,
2728
+ * gasPrice: Value.fromGwei('10'),
2729
+ * nonce: 69n,
2730
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2731
+ * value: Value.fromEther('1.5'),
2732
+ * })
2733
+ *
2734
+ * // Sign over the Envelope.
2735
+ * const signature = Secp256k1.sign({
2736
+ * payload: TransactionEnvelopeEip2930.getSignPayload(envelope),
2737
+ * privateKey: '0x...',
2738
+ * })
2739
+ *
2740
+ * // Serialize the Envelope with the Signature. // [!code focus]
2741
+ * const serialized = TransactionEnvelopeEip2930.serialize(envelope, { // [!code focus]
2742
+ * signature // [!code focus]
2743
+ * }) // [!code focus]
2744
+ *
2745
+ * // Broadcast the Envelope with `eth_sendRawTransaction`. // [!code focus]
2746
+ * const transport = RpcTransport.fromHttp('https://1.rpc.thirdweb.com') // [!code focus]
2747
+ * const hash = await transport.request({ // [!code focus]
2748
+ * method: 'eth_sendRawTransaction', // [!code focus]
2749
+ * params: [serialized], // [!code focus]
2750
+ * }) // [!code focus]
2751
+ * ```
2752
+ *
2753
+ * If you are interfacing with an RPC that supports `eth_sendTransaction`, you can also use
2754
+ * {@link ox#TransactionEnvelopeEip2930.(toRpc:function)} to convert an Envelope to an RPC-compatible format.
2755
+ * This means you can skip the ceremony of manually filling & signing the Transaction.
2756
+ *
2757
+ * ```ts twoslash
2758
+ * import 'ox/window'
2759
+ * import { Provider, TransactionEnvelopeEip2930, Value } from 'ox'
2760
+ *
2761
+ * const envelope = TransactionEnvelopeEip2930.from({
2762
+ * accessList: [],
2763
+ * chainId: 1,
2764
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2765
+ * value: Value.fromEther('1.5'),
2766
+ * })
2767
+ *
2768
+ * const envelope_rpc = TransactionEnvelopeEip2930.toRpc(envelope)
2769
+ *
2770
+ * const provider = Provider.from(window.ethereum)
2771
+ * const hash = await provider.request({
2772
+ * method: 'eth_sendTransaction',
2773
+ * params: [envelope_rpc],
2774
+ * })
2775
+ * ```
2776
+ *
2777
+ * @example
2778
+ * ### Computing Hashes
2779
+ *
2780
+ * Transaction Hashes can be computed using {@link ox#TransactionEnvelopeEip2930.(hash:function)}:
2781
+ *
2782
+ * ```ts twoslash
2783
+ * import { Secp256k1, TransactionEnvelopeEip2930 } from 'ox'
2784
+ *
2785
+ * const envelope = TransactionEnvelopeEip2930.from({
2786
+ * chainId: 1,
2787
+ * nonce: 0n,
2788
+ * gasPrice: 1000000000n,
2789
+ * gas: 21000n,
2790
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2791
+ * value: 1000000000000000000n,
2792
+ * data: '0x',
2793
+ * })
2794
+ *
2795
+ * const signature = Secp256k1.sign({
2796
+ * payload: TransactionEnvelopeEip2930.getSignPayload(envelope),
2797
+ * privateKey: '0x...'
2798
+ * })
2799
+ *
2800
+ * const envelope_signed = TransactionEnvelopeEip2930.from(envelope, { signature })
2801
+ *
2802
+ * const hash = TransactionEnvelopeEip2930.hash(envelope_signed) // [!code focus]
2803
+ * ```
2804
+ *
2805
+ * @category Transaction Envelopes
2806
+ */
2807
+ export * as TransactionEnvelopeEip2930 from './TransactionEnvelopeEip2930.js'
2808
+
2809
+ /**
2810
+ * Utility functions for working with [EIP-4844 Typed Transaction Envelopes](https://eips.ethereum.org/EIPS/eip-4844)
2811
+ *
2812
+ * @example
2813
+ * ### Instantiating Blobs
2814
+ *
2815
+ * Blobs can be instantiated using {@link ox#Blobs.(from:function)}:
2816
+ *
2817
+ * ```ts twoslash
2818
+ * import { Blobs, Hex } from 'ox'
2819
+ *
2820
+ * const blobs = Blobs.from(Hex.fromString('Hello World!'))
2821
+ * ```
2822
+ *
2823
+ * @example
2824
+ * ### Instantiating
2825
+ *
2826
+ * Transaction Envelopes can be instantiated using {@link ox#TransactionEnvelopeEip4844.(from:function)}:
2827
+ *
2828
+ * ```ts twoslash
2829
+ * // @noErrors
2830
+ * import { Blobs, Hex, TransactionEnvelopeEip4844, Value } from 'ox'
2831
+ * import { kzg } from './kzg'
2832
+ *
2833
+ * const blobs = Blobs.from(Hex.fromString('Hello World!'))
2834
+ * const blobVersionedHashes = Blobs.toVersionedHashes(blobs, { kzg })
2835
+ *
2836
+ * const envelope = TransactionEnvelopeEip4844.from({
2837
+ * chainId: 1,
2838
+ * blobVersionedHashes,
2839
+ * maxFeePerBlobGas: Value.fromGwei('3'),
2840
+ * maxFeePerGas: Value.fromGwei('10'),
2841
+ * maxPriorityFeePerGas: Value.fromGwei('1'),
2842
+ * to: '0x0000000000000000000000000000000000000000',
2843
+ * value: Value.fromEther('1'),
2844
+ * })
2845
+ * ```
2846
+ *
2847
+ * @example
2848
+ * ### Signing
2849
+ *
2850
+ * Transaction Envelopes can be signed using {@link ox#TransactionEnvelopeEip4844.(getSignPayload:function)} and a signing function such as {@link ox#Secp256k1.(sign:function)} or {@link ox#P256.(sign:function)}:
2851
+ *
2852
+ * ```ts twoslash
2853
+ * // @noErrors
2854
+ * import { Blobs, Secp256k1, TransactionEnvelopeEip4844 } from 'ox'
2855
+ * import { kzg } from './kzg'
2856
+ *
2857
+ * const blobs = Blobs.from('0xdeadbeef')
2858
+ * const blobVersionedHashes = Blobs.toVersionedHashes(blobs, { kzg })
2859
+ * const sidecars = Blobs.toSidecars(blobs, { kzg })
2860
+ *
2861
+ * const envelope = TransactionEnvelopeEip4844.from({
2862
+ * blobVersionedHashes,
2863
+ * chainId: 1,
2864
+ * nonce: 0n,
2865
+ * maxFeePerBlobGas: Value.fromGwei('3'),
2866
+ * maxFeePerGas: Value.fromGwei('10'),
2867
+ * maxPriorityFeePerGas: Value.fromGwei('1'),
2868
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2869
+ * value: Value.fromEther('1'),
2870
+ * })
2871
+ *
2872
+ * const signature = Secp256k1.sign({ // [!code focus]
2873
+ * payload: TransactionEnvelopeEip4844.getSignPayload(envelope), // [!code focus]
2874
+ * privateKey: '0x...' // [!code focus]
2875
+ * }) // [!code focus]
2876
+ *
2877
+ * const envelope_signed = TransactionEnvelopeEip4844.from(envelope, {
2878
+ * sidecars,
2879
+ * signature
2880
+ * })
2881
+ * ```
2882
+ *
2883
+ * @example
2884
+ * ### Serializing
2885
+ *
2886
+ * Transaction Envelopes can be serialized using {@link ox#TransactionEnvelopeEip4844.(serialize:function)}:
2887
+ *
2888
+ * ```ts twoslash
2889
+ * // @noErrors
2890
+ * import { Blobs, TransactionEnvelopeEip4844 } from 'ox'
2891
+ * import { kzg } from './kzg'
2892
+ *
2893
+ * const blobs = Blobs.from('0xdeadbeef')
2894
+ * const blobVersionedHashes = Blobs.toVersionedHashes(blobs, { kzg })
2895
+ *
2896
+ * const envelope = TransactionEnvelopeEip4844.from({
2897
+ * blobVersionedHashes,
2898
+ * chainId: 1,
2899
+ * maxFeePerBlobGas: Value.fromGwei('3'),
2900
+ * maxFeePerGas: Value.fromGwei('10'),
2901
+ * maxPriorityFeePerGas: Value.fromGwei('1'),
2902
+ * to: '0x0000000000000000000000000000000000000000',
2903
+ * value: Value.fromEther('1'),
2904
+ * })
2905
+ *
2906
+ * const serialized = TransactionEnvelopeEip4844.serialize(envelope) // [!code focus]
2907
+ * ```
2908
+ *
2909
+ * @example
2910
+ * ### Sending
2911
+ *
2912
+ * We can send a Transaction Envelope to the network by serializing the signed envelope with `.serialize`, and then broadcasting it over JSON-RPC with `eth_sendRawTransaction`.
2913
+ *
2914
+ * In this example, we will use {@link ox#RpcTransport.(fromHttp:function)} to broadcast a `eth_sendRawTransaction` request over HTTP JSON-RPC.
2915
+ *
2916
+ * ```ts twoslash
2917
+ * // @noErrors
2918
+ * import { Blobs, RpcTransport, TransactionEnvelopeEip4844, Secp256k1, Value } from 'ox'
2919
+ * import { kzg } from './kzg'
2920
+ *
2921
+ * // Compute the Blob Versioned Hashes.
2922
+ * const blobs = Blobs.from('0xdeadbeef')
2923
+ * const blobVersionedHashes = Blobs.toVersionedHashes(blobs, { kzg })
2924
+ * const sidecars = Blobs.toSidecars(blobs, { kzg })
2925
+ *
2926
+ * // Construct the Envelope.
2927
+ * const envelope = TransactionEnvelopeEip4844.from({
2928
+ * chainId: 1,
2929
+ * blobVersionedHashes,
2930
+ * maxFeePerBlobGas: Value.fromGwei('3'),
2931
+ * maxFeePerGas: Value.fromGwei('10'),
2932
+ * maxPriorityFeePerGas: Value.fromGwei('1'),
2933
+ * nonce: 0n,
2934
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
2935
+ * value: Value.fromEther('1.5'),
2936
+ * })
2937
+ *
2938
+ * // Sign over the Envelope.
2939
+ * const signature = Secp256k1.sign({
2940
+ * payload: TransactionEnvelopeEip4844.getSignPayload(envelope),
2941
+ * privateKey: '0x...',
2942
+ * })
2943
+ *
2944
+ * // Serialize the Envelope with the Signature. // [!code focus]
2945
+ * const serialized = TransactionEnvelopeEip4844.serialize(envelope, { // [!code focus]
2946
+ * sidecars, // [!code focus]
2947
+ * signature // [!code focus]
2948
+ * }) // [!code focus]
2949
+ *
2950
+ * // Broadcast the Envelope with `eth_sendRawTransaction`. // [!code focus]
2951
+ * const transport = RpcTransport.fromHttp('https://1.rpc.thirdweb.com') // [!code focus]
2952
+ * const hash = await transport.request({ // [!code focus]
2953
+ * method: 'eth_sendRawTransaction', // [!code focus]
2954
+ * params: [serialized], // [!code focus]
2955
+ * }) // [!code focus]
2956
+ * ```
2957
+ *
2958
+ * @example
2959
+ * ### Computing Hashes
2960
+ *
2961
+ * Transaction Hashes can be computed using {@link ox#TransactionEnvelopeEip4844.(hash:function)}:
2962
+ *
2963
+ * ```ts twoslash
2964
+ * // @noErrors
2965
+ * import { Blobs, Secp256k1, TransactionEnvelopeEip4844, Value } from 'ox'
2966
+ * import { kzg } from './kzg'
2967
+ *
2968
+ * const blobs = Blobs.from('0xdeadbeef')
2969
+ * const blobVersionedHashes = Blobs.toVersionedHashes(blobs, { kzg })
2970
+ *
2971
+ * const envelope = TransactionEnvelopeEip4844.from({
2972
+ * blobVersionedHashes,
2973
+ * chainId: 1,
2974
+ * maxFeePerGas: Value.fromGwei('10'),
2975
+ * to: '0x0000000000000000000000000000000000000000',
2976
+ * value: Value.fromEther('1'),
2977
+ * })
2978
+ *
2979
+ * const signature = Secp256k1.sign({
2980
+ * payload: TransactionEnvelopeEip4844.getSignPayload(envelope),
2981
+ * privateKey: '0x...'
2982
+ * })
2983
+ *
2984
+ * const envelope_signed = TransactionEnvelopeEip4844.from(envelope, { signature })
2985
+ *
2986
+ * const hash = TransactionEnvelopeEip4844.hash(envelope_signed) // [!code focus]
2987
+ * ```
2988
+ *
2989
+ * @category Transaction Envelopes
2990
+ */
2991
+ export * as TransactionEnvelopeEip4844 from './TransactionEnvelopeEip4844.js'
2992
+
2993
+ /**
2994
+ * Utility functions for working with [EIP-7702 Typed Transaction Envelopes](https://eips.ethereum.org/EIPS/eip-7702)
2995
+ *
2996
+ * @example
2997
+ * ### Instantiating
2998
+ *
2999
+ * Transaction Envelopes can be instantiated using {@link ox#TransactionEnvelopeEip7702.(from:function)}:
3000
+ *
3001
+ * ```ts twoslash
3002
+ * import { Authorization, Secp256k1, TransactionEnvelopeEip7702, Value } from 'ox'
3003
+ *
3004
+ * const authorization = Authorization.from({
3005
+ * address: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
3006
+ * chainId: 1,
3007
+ * nonce: 0n,
3008
+ * })
3009
+ *
3010
+ * const signature = Secp256k1.sign({
3011
+ * payload: Authorization.getSignPayload(authorization),
3012
+ * privateKey: '0x...',
3013
+ * })
3014
+ *
3015
+ * const authorizationList = [Authorization.from(authorization, { signature })]
3016
+ *
3017
+ * const envelope = TransactionEnvelopeEip7702.from({ // [!code focus]
3018
+ * authorizationList, // [!code focus]
3019
+ * chainId: 1, // [!code focus]
3020
+ * maxFeePerGas: Value.fromGwei('10'), // [!code focus]
3021
+ * maxPriorityFeePerGas: Value.fromGwei('1'), // [!code focus]
3022
+ * to: '0x0000000000000000000000000000000000000000', // [!code focus]
3023
+ * value: Value.fromEther('1'), // [!code focus]
3024
+ * }) // [!code focus]
3025
+ * ```
3026
+ *
3027
+ * :::tip
3028
+ *
3029
+ * See {@link ox#Authorization} for more details on instantiating and signing EIP-7702 Authorizations.
3030
+ *
3031
+ * :::
3032
+ *
3033
+ * @example
3034
+ * ### Signing
3035
+ *
3036
+ * Transaction Envelopes can be signed using {@link ox#TransactionEnvelopeEip7702.(getSignPayload:function)} and a signing function such as {@link ox#Secp256k1.(sign:function)} or {@link ox#P256.(sign:function)}:
3037
+ *
3038
+ * ```ts twoslash
3039
+ * import { Authorization, Secp256k1, TransactionEnvelopeEip7702, Value } from 'ox'
3040
+ *
3041
+ * const authorization = Authorization.from({
3042
+ * address: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
3043
+ * chainId: 1,
3044
+ * nonce: 0n,
3045
+ * })
3046
+ *
3047
+ * const signature_auth = Secp256k1.sign({
3048
+ * payload: Authorization.getSignPayload(authorization),
3049
+ * privateKey: '0x...',
3050
+ * })
3051
+ *
3052
+ * const authorizationList = [Authorization.from(authorization, { signature: signature_auth })]
3053
+ *
3054
+ * const envelope = TransactionEnvelopeEip7702.from({
3055
+ * authorizationList,
3056
+ * chainId: 1,
3057
+ * maxFeePerGas: Value.fromGwei('10'),
3058
+ * maxPriorityFeePerGas: Value.fromGwei('1'),
3059
+ * to: '0x0000000000000000000000000000000000000000',
3060
+ * value: Value.fromEther('1'),
3061
+ * })
3062
+ *
3063
+ * const signature = Secp256k1.sign({ // [!code focus]
3064
+ * payload: TransactionEnvelopeEip7702.getSignPayload(envelope), // [!code focus]
3065
+ * privateKey: '0x...', // [!code focus]
3066
+ * })
3067
+ *
3068
+ * const envelope_signed = TransactionEnvelopeEip7702.from(envelope, { signature })
3069
+ * ```
3070
+ *
3071
+ * @example
3072
+ * ### Sending
3073
+ *
3074
+ * We can send a Transaction Envelope to the network by serializing the signed envelope with `.serialize`, and then broadcasting it over JSON-RPC with `eth_sendRawTransaction`.
3075
+ *
3076
+ * In this example, we will use {@link ox#RpcTransport.(fromHttp:function)} to broadcast a `eth_sendRawTransaction` request over HTTP JSON-RPC.
3077
+ *
3078
+ * ```ts twoslash
3079
+ * import { Authorization, RpcTransport, TransactionEnvelopeEip7702, Secp256k1, Value } from 'ox'
3080
+ *
3081
+ * const authorization = Authorization.from({
3082
+ * address: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
3083
+ * chainId: 1,
3084
+ * nonce: 0n,
3085
+ * })
3086
+ *
3087
+ * const signature_auth = Secp256k1.sign({
3088
+ * payload: Authorization.getSignPayload(authorization),
3089
+ * privateKey: '0x...',
3090
+ * })
3091
+ *
3092
+ * const authorizationList = [Authorization.from(authorization, { signature: signature_auth })]
3093
+ *
3094
+ * const envelope = TransactionEnvelopeEip7702.from({
3095
+ * authorizationList,
3096
+ * chainId: 1,
3097
+ * maxFeePerGas: Value.fromGwei('10'),
3098
+ * maxPriorityFeePerGas: Value.fromGwei('1'),
3099
+ * nonce: 69n,
3100
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
3101
+ * value: Value.fromEther('1.5'),
3102
+ * })
3103
+ *
3104
+ * const signature = Secp256k1.sign({
3105
+ * payload: TransactionEnvelopeEip7702.getSignPayload(envelope),
3106
+ * privateKey: '0x...',
3107
+ * })
3108
+ *
3109
+ * // Serialize the Envelope with the Signature. // [!code focus]
3110
+ * const serialized = TransactionEnvelopeEip7702.serialize(envelope, { // [!code focus]
3111
+ * signature // [!code focus]
3112
+ * }) // [!code focus]
3113
+ *
3114
+ * // Broadcast the Envelope with `eth_sendRawTransaction`. // [!code focus]
3115
+ * const transport = RpcTransport.fromHttp('https://1.rpc.thirdweb.com') // [!code focus]
3116
+ * const hash = await transport.request({ // [!code focus]
3117
+ * method: 'eth_sendRawTransaction', // [!code focus]
3118
+ * params: [serialized], // [!code focus]
3119
+ * }) // [!code focus]
3120
+ * ```
3121
+ *
3122
+ * @category Transaction Envelopes
3123
+ */
3124
+ export * as TransactionEnvelopeEip7702 from './TransactionEnvelopeEip7702.js'
3125
+
3126
+ /**
3127
+ * Utilities & types for working with **Transaction Receipts** as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/receipt.yaml)
3128
+ *
3129
+ * @example
3130
+ * ### Converting from RPC Format
3131
+ *
3132
+ * Receipts can be converted from RPC format using {@link ox#TransactionReceipt.(fromRpc:function)}:
3133
+ *
3134
+ * ```ts twoslash
3135
+ * import 'ox/window'
3136
+ * import { TransactionReceipt } from 'ox'
3137
+ *
3138
+ * const receipt = await window.ethereum!
3139
+ * .request({
3140
+ * method: 'eth_getTransactionReceipt',
3141
+ * params: [
3142
+ * '0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0',
3143
+ * ],
3144
+ * })
3145
+ * .then(TransactionReceipt.fromRpc) // [!code hl]
3146
+ * // @log: {
3147
+ * // @log: blobGasPrice: 270441n,
3148
+ * // @log: blobGasUsed: 4919n,
3149
+ * // @log: blockHash: "0xc350d807505fb835650f0013632c5515592987ba169bbc6626d9fc54d91f0f0b",
3150
+ * // @log: blockNumber: 19868015n,
3151
+ * // @log: contractAddress: null,
3152
+ * // @log: cumulativeGasUsed: 533781n,
3153
+ * // @log: effectiveGasPrice: 9062804489n,
3154
+ * // @log: from: "0x814e5e0e31016b9a7f138c76b7e7b2bb5c1ab6a6",
3155
+ * // @log: gasUsed: 175034n,
3156
+ * // @log: logs: [],
3157
+ * // @log: logsBloom: "0x00200000000000000000008080000000000000000040000000000000000000000000000000000000000000000000000022000000080000000000000000000000000000080000000000000008000000200000000000000000000200008020400000000000000000280000000000100000000000000000000000000010000000000000000000020000000000000020000000000001000000080000004000000000000000000000000000000000000000000000400000000000001000000000000000000002000000000000000020000000000000000000001000000000000000000000200000000000000000000000000000001000000000c00000000000000000",
3158
+ * // @log: root: undefined,
3159
+ * // @log: status: "success",
3160
+ * // @log: to: "0x3fc91a3afd70395cd496c647d5a6cc9d4b2b7fad",
3161
+ * // @log: transactionHash: "0x353fdfc38a2f26115daadee9f5b8392ce62b84f410957967e2ed56b35338cdd0",
3162
+ * // @log: transactionIndex: 2,
3163
+ * // @log: type: "eip1559",
3164
+ * // @log: }
3165
+ * ```
3166
+ *
3167
+ * @category Execution Spec
3168
+ */
3169
+ export * as TransactionReceipt from './TransactionReceipt.js'
3170
+
3171
+ /**
3172
+ * Utilities & types for working with **Transaction Requests** as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/4aca1d7a3e5aab24c8f6437131289ad386944eaa/src/schemas/transaction.yaml#L358-L423)
3173
+ *
3174
+ * @example
3175
+ * ```ts twoslash
3176
+ * import 'ox/window'
3177
+ * import { Provider, TransactionRequest, Value } from 'ox'
3178
+ *
3179
+ * const provider = Provider.from(window.ethereum!)
3180
+ *
3181
+ * const request = TransactionRequest.toRpc({ // [!code focus]
3182
+ * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', // [!code focus]
3183
+ * value: Value.fromEther('0.01'), // [!code focus]
3184
+ * }) // [!code focus]
3185
+ *
3186
+ * const hash = await provider.request({
3187
+ * method: 'eth_sendTransaction',
3188
+ * params: [request],
3189
+ * })
3190
+ * ```
3191
+ *
3192
+ * @category Execution Spec
3193
+ */
3194
+ export * as TransactionRequest from './TransactionRequest.js'
3195
+
3196
+ /**
3197
+ * Utility functions for working with [EIP-712 Typed Data](https://eips.ethereum.org/EIPS/eip-712)
3198
+ *
3199
+ * @example
3200
+ * ### Getting Sign Payloads
3201
+ *
3202
+ * Typed Data can be converted to a sign payload using {@link ox#TypedData.(getSignPayload:function)}:
3203
+ *
3204
+ * ```ts twoslash
3205
+ * import { Secp256k1, TypedData, Hash } from 'ox'
3206
+ *
3207
+ * const payload = TypedData.getSignPayload({ // [!code focus:99]
3208
+ * domain: {
3209
+ * name: 'Ether Mail',
3210
+ * version: '1',
3211
+ * chainId: 1,
3212
+ * verifyingContract: '0x0000000000000000000000000000000000000000',
3213
+ * },
3214
+ * types: {
3215
+ * Person: [
3216
+ * { name: 'name', type: 'string' },
3217
+ * { name: 'wallet', type: 'address' },
3218
+ * ],
3219
+ * Mail: [
3220
+ * { name: 'from', type: 'Person' },
3221
+ * { name: 'to', type: 'Person' },
3222
+ * { name: 'contents', type: 'string' },
3223
+ * ],
3224
+ * },
3225
+ * primaryType: 'Mail',
3226
+ * message: {
3227
+ * from: {
3228
+ * name: 'Cow',
3229
+ * wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
3230
+ * },
3231
+ * to: {
3232
+ * name: 'Bob',
3233
+ * wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
3234
+ * },
3235
+ * contents: 'Hello, Bob!',
3236
+ * },
3237
+ * })
3238
+ *
3239
+ * const signature = Secp256k1.sign({ payload, privateKey: '0x...' })
3240
+ * ```
3241
+ *
3242
+ * @category Signed & Typed Data
3243
+ */
3244
+ export * as TypedData from './TypedData.js'
3245
+
3246
+ /**
3247
+ * Utilities & types for working with [EIP-191 Validator Data](https://eips.ethereum.org/EIPS/eip-191#0x00)
3248
+ *
3249
+ * @category Signed & Typed Data
3250
+ */
3251
+ export * as ValidatorData from './ValidatorData.js'
3252
+
3253
+ /**
3254
+ * Utility functions for displaying and parsing Ethereum Values as defined under **2.1. Value** in the [Ethereum Yellow Paper](https://ethereum.github.io/yellowpaper/paper.pdf)
3255
+ *
3256
+ * @example
3257
+ * ```ts twoslash
3258
+ * // @noErrors
3259
+ * import { Value } from 'ox'
3260
+ *
3261
+ * const value = Value.fromEther('1')
3262
+ * // @log: 1_000_000_000_000_000_000n
3263
+ *
3264
+ * const formattedValue = Value.formatEther(value)
3265
+ * // @log: '1'
3266
+ *
3267
+ * const value = Value.fromEther('1', 'szabo')
3268
+ * // @log: 1_000_000n
3269
+ * ```
3270
+ *
3271
+ * @category Data
3272
+ */
3273
+ export * as Value from './Value.js'
3274
+
3275
+ /**
3276
+ * Utility functions for [NIST P256](https://csrc.nist.gov/csrc/media/events/workshop-on-elliptic-curve-cryptography-standards/documents/papers/session6-adalier-mehmet.pdf) ECDSA cryptography using the [Web Authentication API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API)
3277
+ *
3278
+ * @example
3279
+ * ### Creating Credentials
3280
+ *
3281
+ * Credentials can be created using {@link ox#WebAuthnP256.(createCredential:function)}:
3282
+ *
3283
+ * ```ts twoslash
3284
+ * import { WebAuthnP256 } from 'ox'
3285
+ *
3286
+ * const credential = await WebAuthnP256.createCredential({ name: 'Example' }) // [!code focus]
3287
+ * // @log: {
3288
+ * // @log: id: 'oZ48...',
3289
+ * // @log: publicKey: { x: 51421...5123n, y: 12345...6789n },
3290
+ * // @log: raw: PublicKeyCredential {},
3291
+ * // @log: }
3292
+ *
3293
+ * const { metadata, signature } = await WebAuthnP256.sign({
3294
+ * credentialId: credential.id,
3295
+ * challenge: '0xdeadbeef',
3296
+ * })
3297
+ * ```
3298
+ *
3299
+ * @example
3300
+ * ### Signing Payloads
3301
+ *
3302
+ * Payloads can be signed using {@link ox#WebAuthnP256.(sign:function)}:
3303
+ *
3304
+ * ```ts twoslash
3305
+ * import { WebAuthnP256 } from 'ox'
3306
+ *
3307
+ * const credential = await WebAuthnP256.createCredential({
3308
+ * name: 'Example',
3309
+ * })
3310
+ *
3311
+ * const { metadata, signature } = await WebAuthnP256.sign({ // [!code focus]
3312
+ * credentialId: credential.id, // [!code focus]
3313
+ * challenge: '0xdeadbeef', // [!code focus]
3314
+ * }) // [!code focus]
3315
+ * // @log: {
3316
+ * // @log: metadata: {
3317
+ * // @log: authenticatorData: '0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000',
3318
+ * // @log: clientDataJSON: '{"type":"webauthn.get","challenge":"9jEFijuhEWrM4SOW-tChJbUEHEP44VcjcJ-Bqo1fTM8","origin":"http://localhost:5173","crossOrigin":false}',
3319
+ * // @log: challengeIndex: 23,
3320
+ * // @log: typeIndex: 1,
3321
+ * // @log: userVerificationRequired: true,
3322
+ * // @log: },
3323
+ * // @log: signature: { r: 51231...4215n, s: 12345...6789n },
3324
+ * // @log: }
3325
+ * ```
3326
+ *
3327
+ * @example
3328
+ * ### Verifying Signatures
3329
+ *
3330
+ * Signatures can be verified using {@link ox#WebAuthnP256.(verify:function)}:
3331
+ *
3332
+ * ```ts twoslash
3333
+ * import { WebAuthnP256 } from 'ox'
3334
+ *
3335
+ * const credential = await WebAuthnP256.createCredential({
3336
+ * name: 'Example',
3337
+ * })
3338
+ *
3339
+ * const { metadata, signature } = await WebAuthnP256.sign({
3340
+ * credentialId: credential.id,
3341
+ * challenge: '0xdeadbeef',
3342
+ * })
3343
+ *
3344
+ * const result = await WebAuthnP256.verify({ // [!code focus]
3345
+ * metadata, // [!code focus]
3346
+ * challenge: '0xdeadbeef', // [!code focus]
3347
+ * publicKey: credential.publicKey, // [!code focus]
3348
+ * signature, // [!code focus]
3349
+ * }) // [!code focus]
3350
+ * // @log: true
3351
+ * ```
3352
+ *
3353
+ * @category Crypto
3354
+ */
3355
+ export * as WebAuthnP256 from './WebAuthnP256.js'
3356
+
3357
+ /**
3358
+ * Utility functions for [NIST P256](https://csrc.nist.gov/csrc/media/events/workshop-on-elliptic-curve-cryptography-standards/documents/papers/session6-adalier-mehmet.pdf) ECDSA cryptography using the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
3359
+ *
3360
+ * @example
3361
+ * ### Creating Key Pairs
3362
+ *
3363
+ * Key pairs can be created using {@link ox#WebCryptoP256.(createKeyPair:function)}:
3364
+ *
3365
+ * ```ts twoslash
3366
+ * import { WebCryptoP256 } from 'ox'
3367
+ *
3368
+ * const { publicKey, privateKey } = await WebCryptoP256.createKeyPair()
3369
+ * // @log: {
3370
+ * // @log: privateKey: CryptoKey {},
3371
+ * // @log: publicKey: {
3372
+ * // @log: x: 59295962801117472859457908919941473389380284132224861839820747729565200149877n,
3373
+ * // @log: y: 24099691209996290925259367678540227198235484593389470330605641003500238088869n,
3374
+ * // @log: prefix: 4,
3375
+ * // @log: },
3376
+ * // @log: }
3377
+ * ```
3378
+ *
3379
+ * @example
3380
+ * ### Signing Payloads
3381
+ *
3382
+ * Payloads can be signed using {@link ox#WebCryptoP256.(sign:function)}:
3383
+ *
3384
+ * ```ts twoslash
3385
+ * import { WebCryptoP256 } from 'ox'
3386
+ *
3387
+ * const { privateKey } = await WebCryptoP256.createKeyPair()
3388
+ *
3389
+ * const signature = await WebCryptoP256.sign({ // [!code focus]
3390
+ * payload: '0xdeadbeef', // [!code focus]
3391
+ * privateKey, // [!code focus]
3392
+ * }) // [!code focus]
3393
+ * // @log: {
3394
+ * // @log: r: 151231...4423n,
3395
+ * // @log: s: 516123...5512n,
3396
+ * // @log: }
3397
+ * ```
3398
+ *
3399
+ * @example
3400
+ * ### Verifying Signatures
3401
+ *
3402
+ * Signatures can be verified using {@link ox#WebCryptoP256.(verify:function)}:
3403
+ *
3404
+ * ```ts twoslash
3405
+ * import { WebCryptoP256 } from 'ox'
3406
+ *
3407
+ * const { privateKey, publicKey } = await WebCryptoP256.createKeyPair()
3408
+ * const signature = await WebCryptoP256.sign({ payload: '0xdeadbeef', privateKey })
3409
+ *
3410
+ * const verified = await WebCryptoP256.verify({ // [!code focus]
3411
+ * payload: '0xdeadbeef', // [!code focus]
3412
+ * publicKey, // [!code focus]
3413
+ * signature, // [!code focus]
3414
+ * }) // [!code focus]
3415
+ * // @log: true
3416
+ * ```
3417
+ *
3418
+ * @category Crypto
3419
+ */
3420
+ export * as WebCryptoP256 from './WebCryptoP256.js'
3421
+
3422
+ /**
3423
+ * Utilities & types for working with Withdrawals as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/withdrawal.yaml)
3424
+ *
3425
+ * @category Execution Spec
3426
+ */
3427
+ export * as Withdrawal from './Withdrawal.js'