### 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] - [toJSON][19] - [serialize][20] - [from][21] - [Properties][22] ## Transaction [index.js:52-336][23] Creates a new transaction object. ### Parameters - `data` **([Buffer][24] \| [Array][25] \| [Object][26])** 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][24]** nonce number - `data.gasLimit` **[Buffer][24]** transaction gas limit - `data.gasPrice` **[Buffer][24]** transaction gas price - `data.to` **[Buffer][24]** to the to address - `data.value` **[Buffer][24]** the amount of ether sent - `data.data` **[Buffer][24]** this will contain the data of the message or the init of a contract - `data.v` **[Buffer][24]** EC recovery ID - `data.r` **[Buffer][24]** EC signature parameter - `data.s` **[Buffer][24]** EC signature parameter - `data.chainId` **[Number][27]** EIP 155 chainId - mainnet: 1, ropsten: 3 - `opts` **[Array][25]** Options - `opts.chain` **([String][28] \| [Number][27])** The chain for the block [default: 'mainnet'] - `opts.hardfork` **[String][28]** Hardfork for the block [default: null, block number-based behaviour] - `opts.common` **[Object][26]** Alternatively pass a Common instance (ethereumjs-common) instead of setting chain/hardfork directly ### Properties - `raw` **[Buffer][24]** The raw rlp encoded transaction ### Examples ```javascript var rawTx = { nonce: '0x00', gasPrice: '0x09184e72a000', gasLimit: '0x2710', to: '0x0000000000000000000000000000000000000000', value: '0x00', data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057', v: '0x1c', r: '0x5e1d3a76fbf824220eafc8c79ad578ad2b67d01b0c2425eb1f1347e8f50882ab', s: '0x5bd428537f05f9830e93792f90ea6a3e2d1ee84952dd96edbae9f658f831ab13' }; var tx = new Transaction(rawTx); ``` ### toCreationAddress [index.js:162-164][29] If the tx's `to` is to the creation address Returns **[Boolean][30]** ### hash [index.js:179-205][31] Computes a sha3-256 hash of the serialized tx #### Parameters - `includeSignature` **[Boolean][30]** whether or not to inculde the signature (optional, default `true`) Returns **[Buffer][24]** ### getChainId [index.js:211-213][32] returns chain ID Returns **[Buffer][24]** ### getSenderAddress [index.js:219-226][33] returns the sender's address Returns **[Buffer][24]** ### getSenderPublicKey [index.js:232-237][34] returns the public key of the sender Returns **[Buffer][24]** ### verifySignature [index.js:243-262][35] Determines if the signature is valid Returns **[Boolean][30]** ### sign [index.js:268-276][36] sign a transaction with a given private key #### Parameters - `privateKey` **[Buffer][24]** Must be 32 bytes in length ### getDataFee [index.js:282-291][37] The amount of gas paid for the data in this tx Returns **BN** ### getBaseFee [index.js:297-303][38] the minimum amount of gas the tx must have (DataFee + TxFee + Creation Fee) Returns **BN** ### getUpfrontCost [index.js:309-313][39] the up front amount that an account must have for this transaction to be valid Returns **BN** ### validate [index.js:320-335][40] validates the signature and checks to see if it has enough gas #### Parameters - `stringError` **[Boolean][30]** whether to return a string with a description of why the validation failed or return a Boolean (optional, default `false`) Returns **([Boolean][30] \| [String][28])** ### toJSON [index.js:136-136][41] - **See: [ethereumjs-util][42]** Returns the transaction in JSON format Returns **([Array][25] \| [String][28])** ### serialize [index.js:136-136][41] - **See: [ethereumjs-util][42]** Returns the rlp encoding of the transaction Returns **[Buffer][24]** ### from [index.js:143-147][43] #### Properties - `from` **[Buffer][24]** (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]: #tojson [20]: #serialize [21]: #from [22]: #properties-1 [23]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L52-L336 "Source code on GitHub" [24]: https://nodejs.org/api/buffer.html [25]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array [26]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object [27]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number [28]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [29]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L162-L164 "Source code on GitHub" [30]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean [31]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L179-L205 "Source code on GitHub" [32]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L211-L213 "Source code on GitHub" [33]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L219-L226 "Source code on GitHub" [34]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L232-L237 "Source code on GitHub" [35]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L243-L262 "Source code on GitHub" [36]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L268-L276 "Source code on GitHub" [37]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L282-L291 "Source code on GitHub" [38]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L297-L303 "Source code on GitHub" [39]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L309-L313 "Source code on GitHub" [40]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L320-L335 "Source code on GitHub" [41]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L136-L136 "Source code on GitHub" [42]: https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/index.md#defineproperties [43]: https://github.com/Conflux-Chain/confluxjs-transaction/blob/8518076331dea1eaab6eb8fd33b3e1c405f28b5c/index.js#L143-L147 "Source code on GitHub"