<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [Transaction][1]
    -   [Parameters][2]
    -   [Properties][3]
    -   [Examples][4]
    -   [toCreationAddress][5]
    -   [hash][6]
        -   [Parameters][7]
    -   [getChainId][8]
    -   [getSenderAddress][9]
    -   [getSenderPublicKey][10]
    -   [verifySignature][11]
    -   [sign][12]
        -   [Parameters][13]
    -   [getDataFee][14]
    -   [getBaseFee][15]
    -   [getUpfrontCost][16]
    -   [validate][17]
        -   [Parameters][18]
    -   [serialize][19]
    -   [from][20]
        -   [Properties][21]

## Transaction

Creates a new transaction object.

### Parameters

-   `data` **([Buffer][22] \| [Array][23] \| [Object][24])** a transaction can be initiailized with either a buffer containing the RLP serialized transaction or an array of buffers relating to each of the tx Properties, listed in order below in the exmple.Or lastly an Object containing the Properties of the transaction like in the Usage example.For Object and Arrays each of the elements can either be a Buffer, a hex-prefixed (0x) String , Number, or an object with a toBuffer method such as Bignum
    -   `data.nonce` **[Buffer][22]** nonce number
    -   `data.gasLimit` **[Buffer][22]** transaction gas limit
    -   `data.gasPrice` **[Buffer][22]** transaction gas price
    -   `data.to` **[Buffer][22]** to the to address
    -   `data.value` **[Buffer][22]** the amount of irc sent
    -   `data.data` **[Buffer][22]** this will contain the data of the message or the init of a contract
    -   `data.v` **[Buffer][22]** EC recovery ID
    -   `data.r` **[Buffer][22]** EC signature parameter
    -   `data.s` **[Buffer][22]** EC signature parameter
    -   `data.chainId` **[Number][25]** EIP 155 chainId - mainnet: 1, ropsten: 3

### Properties

-   `raw` **[Buffer][22]** The raw rlp encoded transaction

### Examples

```javascript
var rawTx = {
  nonce: '00',
  gasPrice: '09184e72a000',
  gasLimit: '2710',
  to: '0000000000000000000000000000000000000000',
  value: '00',
  data: '7f7465737432000000000000000000000000000000000000000000000000000000600057',
  v: '1c',
  r: '5e1d3a76fbf824220eafc8c79ad578ad2b67d01b0c2425eb1f1347e8f50882ab',
  s: '5bd428537f05f9830e93792f90ea6a3e2d1ee84952dd96edbae9f658f831ab13'
};
var tx = new Transaction(rawTx);
```

### toCreationAddress

If the tx's `to` is to the creation address

Returns **[Boolean][26]** 

### hash

Computes a sha3-256 hash of the serialized tx

#### Parameters

-   `includeSignature` **[Boolean][26]** whether or not to inculde the signature (optional, default `true`)

Returns **[Buffer][22]** 

### getChainId

returns the public key of the sender

Returns **[Buffer][22]** 

### getSenderAddress

returns the sender's address

Returns **[Buffer][22]** 

### getSenderPublicKey

returns the public key of the sender

Returns **[Buffer][22]** 

### verifySignature

Determines if the signature is valid

Returns **[Boolean][26]** 

### sign

sign a transaction with a given a private key

#### Parameters

-   `privateKey` **[Buffer][22]** 

### getDataFee

The amount of gas paid for the data in this tx

Returns **BN** 

### getBaseFee

the minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee)

Returns **BN** 

### getUpfrontCost

the up front amount that an account must have for this transaction to be valid

Returns **BN** 

### validate

validates the signature and checks to see if it has enough gas

#### Parameters

-   `stringError` **[Boolean][26]** whether to return a string with a dscription of why the validation failed or return a Bloolean (optional, default `false`)

Returns **([Boolean][26] \| [String][27])** 

### serialize

Returns the rlp encoding of the transaction

Returns **[Buffer][22]** 

### from

#### Properties

-   `from` **[Buffer][22]** (read only) sender address of this transaction, mathematically derived from other parameters.

[1]: #transaction

[2]: #parameters

[3]: #properties

[4]: #examples

[5]: #tocreationaddress

[6]: #hash

[7]: #parameters-1

[8]: #getchainid

[9]: #getsenderaddress

[10]: #getsenderpublickey

[11]: #verifysignature

[12]: #sign

[13]: #parameters-2

[14]: #getdatafee

[15]: #getbasefee

[16]: #getupfrontcost

[17]: #validate

[18]: #parameters-3

[19]: #serialize

[20]: #from

[21]: #properties-1

[22]: https://nodejs.org/api/buffer.html

[23]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[24]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[25]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

[26]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

[27]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
