Files: 53d0a8449b654d395b0965a2e0d05bb3cd6782fa / transaction.js
1041 bytesRaw
1 | // |
2 | // This class parses a serialised Ethereum transaction |
3 | // |
4 | // The input is a Buffer. |
5 | // |
6 | |
7 | const Address = require('./address.js') |
8 | const U256 = require('./u256.js') |
9 | const ethUtils = require('ethereumjs-util') |
10 | const ethTx = require('ethereumjs-tx') |
11 | |
12 | module.exports = class Transaction { |
13 | constructor (tx) { |
14 | this._tx = new ethTx(tx) |
15 | } |
16 | |
17 | get valid () { |
18 | return this._tx.verifySignature() |
19 | } |
20 | |
21 | get nonce () { |
22 | return new U256(this._tx.nonce) |
23 | } |
24 | |
25 | get gasPrice () { |
26 | return new U256(this._tx.gasPrice) |
27 | } |
28 | |
29 | get gasLimit () { |
30 | return new U256(this._tx.gasLimit) |
31 | } |
32 | |
33 | get value () { |
34 | return new U256(this._tx.value) |
35 | } |
36 | |
37 | get data () { |
38 | return Uint8Array.from(this._tx.data) |
39 | } |
40 | |
41 | get from () { |
42 | return new Address(this._tx.getSenderAddress()) |
43 | } |
44 | |
45 | get to () { |
46 | if (this._tx.to.length === 0) { |
47 | return new Address('0x0000000000000000000000000000000000000000') |
48 | } |
49 | return new Address(this._tx.to) |
50 | } |
51 | |
52 | get isSend () { |
53 | } |
54 | |
55 | get isContractCall () { |
56 | } |
57 | |
58 | get isContractDeployment () { |
59 | } |
60 | } |
61 |
Built with git-ssb-web