37
37
38
38
### constructor
39
39
40
- ⊕ **new Account**(data? : _`any`_): [Account](account.md)
40
+ ⊕ **new Account**(data: _`any`_): [Account](account.md)
41
41
42
- _Defined in [index.ts:41](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L41)_
43
-
44
- Creates a new account object
45
-
46
- ```
47
- var data = [
48
- '0x02', //nonce
49
- '0x0384', //balance
50
- '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', //stateRoot
51
- '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470', //codeHash
52
- ]
53
-
54
- var data = {
55
- nonce: '',
56
- balance: '0x03e7',
57
- stateRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
58
- codeHash: '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470',
59
- }
60
-
61
- const account = new Account(data)
62
- ```
42
+ _Defined in [index.ts:41](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L41)_
63
43
64
44
**Parameters:**
65
45
@@ -79,9 +59,7 @@ const account = new Account(data)
79
59
80
60
**● balance**: _`Buffer`_
81
61
82
- _Defined in [index.ts:31](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L31)_
83
-
84
- The account's balance in wei.
62
+ _Defined in [index.ts:31](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L31)_
85
63
86
64
---
87
65
@@ -91,9 +69,7 @@ The account's balance in wei.
91
69
92
70
**● codeHash**: _`Buffer`_
93
71
94
- _Defined in [index.ts:41](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L41)_
95
-
96
- The hash of the code of the contract.
72
+ _Defined in [index.ts:41](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L41)_
97
73
98
74
---
99
75
@@ -103,9 +79,7 @@ The hash of the code of the contract.
103
79
104
80
**● nonce**: _`Buffer`_
105
81
106
- _Defined in [index.ts:26](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L26)_
107
-
108
- The account's nonce.
82
+ _Defined in [index.ts:26](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L26)_
109
83
110
84
---
111
85
@@ -115,9 +89,7 @@ The account's nonce.
115
89
116
90
**● stateRoot**: _`Buffer`_
117
91
118
- _Defined in [index.ts:36](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L36)_
119
-
120
- The stateRoot for the storage of the contract.
92
+ _Defined in [index.ts:36](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L36)_
121
93
122
94
---
123
95
@@ -129,9 +101,7 @@ The stateRoot for the storage of the contract.
129
101
130
102
▸ **getCode**(trie: _`Trie`_, cb: _`TrieGetCb`_): `void`
131
103
132
- _Defined in [index.ts:116](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L116)_
133
-
134
- Fetches the code from the trie.
104
+ _Defined in [index.ts:116](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L116)_
135
105
136
106
**Parameters:**
137
107
@@ -150,9 +120,7 @@ Fetches the code from the trie.
150
120
151
121
▸ **getStorage**(trie: _`Trie`_, key: _`Buffer` \| `string`_, cb: _`TrieGetCb`_): `void`
152
122
153
- _Defined in [index.ts:179](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L179)_
154
-
155
- Fetches `key` from the account's storage.
123
+ _Defined in [index.ts:179](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L179)_
156
124
157
125
**Parameters:**
158
126
@@ -172,9 +140,7 @@ Fetches `key` from the account's storage.
172
140
173
141
▸ **isContract**(): `boolean`
174
142
175
- _Defined in [index.ts:107](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L107)_
176
-
177
- Returns a `Boolean` deteremining if the account is a contract.
143
+ _Defined in [index.ts:107](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L107)_
178
144
179
145
**Returns:** `boolean`
180
146
@@ -186,9 +152,7 @@ Returns a `Boolean` deteremining if the account is a contract.
186
152
187
153
▸ **isEmpty**(): `boolean`
188
154
189
- _Defined in [index.ts:232](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L232)_
190
-
191
- Returns a `Boolean` determining if the account is empty.
155
+ _Defined in [index.ts:232](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L232)_
192
156
193
157
**Returns:** `boolean`
194
158
@@ -200,9 +164,7 @@ Returns a `Boolean` determining if the account is empty.
200
164
201
165
▸ **serialize**(): `Buffer`
202
166
203
- _Defined in [index.ts:99](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L99)_
204
-
205
- Returns the RLP serialization of the account as a `Buffer`.
167
+ _Defined in [index.ts:99](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L99)_
206
168
207
169
**Returns:** `Buffer`
208
170
@@ -214,36 +176,7 @@ Returns the RLP serialization of the account as a `Buffer`.
214
176
215
177
▸ **setCode**(trie: _`Trie`_, code: _`Buffer`_, cb: _`function`_): `void`
216
178
217
- _Defined in [index.ts:160](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L160)_
218
-
219
- Stores the code in the trie.
220
-
221
- ```
222
- // Requires manual merkle-patricia-tree install
223
- const SecureTrie = require('merkle-patricia-tree/secure')
224
- const Account = require('./index.js').default
225
-
226
- let code = Buffer.from(
227
- '73095e7baea6a6c7c4c2dfeb977efac326af552d873173095e7baea6a6c7c4c2dfeb977efac326af552d873157',
228
- 'hex',
229
- )
230
-
231
- let raw = {
232
- nonce: '',
233
- balance: '0x03e7',
234
- stateRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
235
- codeHash: '0xb30fb32201fe0486606ad451e1a61e2ae1748343cd3d411ed992ffcc0774edd4',
236
- }
237
- let account = new Account(raw)
238
- let trie = new SecureTrie()
239
-
240
- account.setCode(trie, code, function(err, codeHash) {
241
- console.log(`Code with hash 0x${codeHash.toString('hex')} set to trie`)
242
- account.getCode(trie, function(err, code) {
243
- console.log(`Code ${code.toString('hex')} read from trie`)
244
- })
245
- })
246
- ```
179
+ _Defined in [index.ts:160](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L160)_
247
180
248
181
**Parameters:**
249
182
@@ -261,36 +194,9 @@ account.setCode(trie, code, function(err, codeHash) {
261
194
262
195
### setStorage
263
196
264
- ▸ **setStorage**(trie: _`Trie`_, key: _`Buffer` \| `string`_, val: _`Buffer` \| `string`_, cb: _`function`_): `void`
265
-
266
- _Defined in [index.ts:218](https://github.com/ethereumjs/ethereumjs-account/blob/be66a6a/src/index.ts#L218)_
267
-
268
- Stores a `val` at the `key` in the contract's storage.
269
-
270
- Example for `getStorage` and `setStorage`:
271
-
272
- ```
273
- // Requires manual merkle-patricia-tree install
274
- const SecureTrie = require('merkle-patricia-tree/secure')
275
- const Account = require('./index.js').default
276
-
277
- let raw = {
278
- nonce: '',
279
- balance: '0x03e7',
280
- stateRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
281
- codeHash: '0xb30fb32201fe0486606ad451e1a61e2ae1748343cd3d411ed992ffcc0774edd4',
282
- }
283
- let account = new Account(raw)
284
- let trie = new SecureTrie()
285
- let key = Buffer.from('0000000000000000000000000000000000000000', 'hex')
286
- let value = Buffer.from('01', 'hex')
197
+ ▸ **setStorage**(trie: _`Trie`_, key: _`Buffer` \| `string`_, val: _`Buffer` \| `string`_, cb: _`TriePutCb`_): `void`
287
198
288
- account.setStorage(trie, key, value, function(err, value) {
289
- account.getStorage(trie, key, function(err, value) {
290
- console.log(`Value ${value.toString('hex')} set and retrieved from trie.`)
291
- })
292
- })
293
- ```
199
+ _Defined in [index.ts:218](https://github.com/ethereumjs/ethereumjs-vm/blob/d660c58/packages/account/src/index.ts#L218)_
294
200
295
201
**Parameters:**
296
202
@@ -299,7 +205,7 @@ account.setStorage(trie, key, value, function(err, value) {
299
205
| trie | `Trie` | \- |
300
206
| key | `Buffer` \| `string` | \- |
301
207
| val | `Buffer` \| `string` | \- |
302
- | cb | `function` | |
208
+ | cb | `TriePutCb` | |
303
209
304
210
**Returns:** `void`
305
211
0 commit comments