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