Skip to content

Commit 5f350ec

Browse files
authored
docs: add opaqueDataToDepositData page (#2616)
1 parent 2eeba74 commit 5f350ec

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
description: Converts opaque data into a structured deposit data format.
3+
---
4+
5+
# opaqueDataToDepositData
6+
7+
Converts an opaque data into a structured deposit data object. This includes extracting and converting the `mint`, `value`, `gas`, `isCreation` flag, and `data` from a hex string.
8+
9+
## Import
10+
11+
```ts
12+
import { opaqueDataToDepositData } from "viem";
13+
```
14+
15+
## Usage
16+
17+
```ts
18+
import { opaqueDataToDepositData } from "viem";
19+
20+
const opaqueData =
21+
"0x00000000000000000000000000000000000000000000000000470DE4DF82000000000000000000000000000000000000000000000000000000470DE4DF82000000000000000186A00001";
22+
23+
const depositData = opaqueDataToDepositData(opaqueData);
24+
// {
25+
// mint: 20000000000000000n,
26+
// value: 20000000000000000n,
27+
// gas: 100000n,
28+
// isCreation: false,
29+
// data: '0x01',
30+
// }
31+
```
32+
33+
## Returns
34+
35+
`OpaqueDataToDepositDataReturnType`
36+
37+
An object containing the parsed deposit data.
38+
39+
## Parameters
40+
41+
### opaqueData
42+
43+
- **Type:** `Hex`
44+
45+
The opaque hex-encoded data.
46+
47+
## Errors
48+
49+
`OpaqueDataToDepositDataErrorType`
50+
51+
An error type that includes potential slice, size, and generic errors encountered during the parsing process.

0 commit comments

Comments
 (0)