lib/transaction.js
function (options) {
    if (arguments.length > 0) {
        options = utils.argumentsToObject(['chainID', 'from', 'to', 'value', 'nonce', 'gasPrice', 'gasLimit', 'contract'], arguments);

        this.chainID = options.chainID;
        this.from = account.fromAddress(options.from);
        this.to = account.fromAddress(options.to);
        this.value = utils.toBigNumber(options.value);
        if(!this.value.isInteger())
            throw new Error("Invalid value! The minimum unit is wei (1^-18nas)");
        this.nonce = parseInt(options.nonce); // An error will be thrown is nonce is string. Error: "nonce: integer|Long expected"
        this.timestamp = Math.floor(new Date().getTime()/1000);
        this.contract = options.contract;
        this.gasPrice = utils.toBigNumber(options.gasPrice);
        this.gasLimit = utils.toBigNumber(options.gasLimit);

        this.data = parseContract(this.contract);
        if (this.gasPrice.lessThanOrEqualTo(0)) {
            this.gasPrice = new BigNumber(1000000);
        }

        if (this.gasLimit.lessThanOrEqualTo(0)) {
            this.gasLimit = new BigNumber(20000);
        }
    }
    this.signErrorMessage = "You should sign transaction before this operation.";
}
function (options) {
    if (arguments.length > 0) {
        options = utils.argumentsToObject(['chainID', 'from', 'to', 'value', 'nonce', 'gasPrice', 'gasLimit', 'contract'], arguments);

        this.chainID = options.chainID;
        this.from = account.fromAddress(options.from);
        this.to = account.fromAddress(options.to);
        this.value = utils.toBigNumber(options.value);
        if(!this.value.isInteger())
            throw new Error("Invalid value! The minimum unit is wei (1^-18nas)");
        this.nonce = parseInt(options.nonce); // An error will be thrown is nonce is string. Error: "nonce: integer|Long expected"
        this.timestamp = Math.floor(new Date().getTime()/1000);
        this.contract = options.contract;
        this.gasPrice = utils.toBigNumber(options.gasPrice);
        this.gasLimit = utils.toBigNumber(options.gasLimit);

        this.data = parseContract(this.contract);
        if (this.gasPrice.lessThanOrEqualTo(0)) {
            this.gasPrice = new BigNumber(1000000);
        }

        if (this.gasLimit.lessThanOrEqualTo(0)) {
            this.gasLimit = new BigNumber(20000);
        }
    }
    this.signErrorMessage = "You should sign transaction before this operation.";
}
function ( options ) { if ( arguments . length > 0 ) { options = utils . argumentsToObject ( [ 'chainID' , 'from' , 'to' , 'value' , 'nonce' , 'gasPrice' , 'gasLimit' , 'contract' ] , arguments ) ; this . chainID = options . chainID ; this . from = account . fromAddress ( options . from ) ; this . to = account . fromAddress ( options . to ) ; this . value = utils . toBigNumber ( options . value ) ; if ( ! this . value . isInteger ( ) ) throw new Error ( "Invalid value! The minimum unit is wei (1^-18nas)" ) ; this . nonce = parseInt ( options . nonce ) ; // An error will be thrown is nonce is string. Error: "nonce: integer|Long expected" this . timestamp = Math . floor ( new Date ( ) . getTime ( ) / 1000 ) ; this . contract = options . contract ; this . gasPrice = utils . toBigNumber ( options . gasPrice ) ; this . gasLimit = utils . toBigNumber ( options . gasLimit ) ; this . data = parseContract ( this . contract ) ; if ( this . gasPrice . lessThanOrEqualTo ( 0 ) ) { this . gasPrice = new BigNumber ( 1000000 ) ; } if ( this . gasLimit . lessThanOrEqualTo ( 0 ) ) { this . gasLimit = new BigNumber ( 20000 ) ; } } this . signErrorMessage = "You should sign transaction before this operation." ; }
Represent Transaction parameters

@typedef {Object} TransactionOptions
@property {Number} options.chainID - Transaction chain id.
@property {HexString} options.from - Hex string of the sender account addresss..
@property {HexString} options.to - Hex string of the receiver account addresss..
@property {Number} options.value - Value of transaction.
@property {Number} options.nonce - Transaction nonce.
@property {Number} options.gasPrice - Gas price. The unit is 10^-18 NAS.
@property {Number} options.gasLimit - Transaction gas limit.
@property {Contract} [options.contract]

@example
{
chainID: 1,
from: "n1QZMXSZtW7BUerroSms4axNfyBGyFGkrh5",
to: "n1SAeQRVn33bamxN4ehWUT7JGdxipwn8b17",
value: 10,
nonce: 12,
gasPrice: 1000000,
gasLimit: 2000000
}
 
Transaction constructor.
Class encapsulate main operation with transactions.
@see [For more information about parameters, follow this link]{@link https://github.com/nebulasio/wiki/blob/master/rpc.md#sendrawtransaction}
@constructor

@param {TransactionOptions} options - Transaction options.

@see [Transaction tutorial.]{@link https://github.com/nebulasio/wiki/blob/master/tutorials/%5BEnglish%5D%20Nebulas%20101%20-%2002%20Transaction.md}
@see [Create own smart contract in Nebulas.]{@link https://github.com/nebulasio/wiki/blob/master/tutorials/%5BEnglish%5D%20Nebulas%20101%20-%2003%20Smart%20Contracts%20JavaScript.md}
@see [More about transaction parameters.]{@link https://github.com/nebulasio/wiki/blob/c3f5ce8908c80e9104e3b512a7fdfd75f16ac38c/rpc.md#sendtransaction}

@example
var acc = Account.NewAccount();

var tx = new Transaction({
chainID: 1,
from: acc,
to: "n1SAeQRVn33bamxN4ehWUT7JGdxipwn8b17",
value: 10,
nonce: 12,
gasPrice: 1000000,
gasLimit: 2000000,
contract: {
function: "save",
args: "[0]"
}
});
Represent Transaction parameters