PrivateTransaction

PrivateTransaction

Creates a new private transaction object.

Constructor

new PrivateTransaction(data)

Source:
Properties:
Name Type Description
raw Buffer

The raw rlp encoded private transaction

Example
var rawTx = {
  nonce: '0x00',
  gasPrice: '0x09184e72a000',
  gasLimit: '0x2710',
  to: '0x0000000000000000000000000000000000000000',
  value: '0x00',
  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
  v: '0x1c',
  r: '0x5e1d3a76fbf824220eafc8c79ad578ad2b67d01b0c2425eb1f1347e8f50882ab',
  s: '0x5bd428537f05f9830e93792f90ea6a3e2d1ee84952dd96edbae9f658f831ab13'
  privateFrom: 'A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo='
  privateFor: ['Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs=']
  restriction: 'restricted'
};
var tx = new PrivateTransaction(rawTx);
Parameters:
Name Type Description
data Buffer | Array | Object

a private transaction can be initiailized with either a buffer containing the RLP serialized private transaction or an array of buffers relating to each of the tx Properties, listed in order below in the example.

Or lastly an Object containing the Properties of the private 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

Properties
Name Type Description
nonce Buffer

nonce number

gasLimit Buffer

transaction gas limit

gasPrice Buffer

transaction gas price

to Buffer

to the to address

value Buffer

the amount of ether sent

data Buffer

this will contain the data of the message or the init of a contract

v Buffer

EC recovery ID

r Buffer

EC signature parameter

s Buffer

EC signature parameter

privateFrom Buffer

The enclave public key of the sender

privateFor Array.<Buffer>

The enclave public keys of the receivers

privacyGroupId Buffer

The enclave id representing the group of receivers

restriction Buffer

The transaction type - "restricted" or "unrestricted"

chainId Number

EIP 155 chainId - mainnet: 1, ropsten:

Members

(static) from

Source:
Properties:
Name Type Description
from Buffer

(read only) sender address of this private transaction, mathematically derived from other parameters.

Methods

(static) serialize() → {Buffer}

Source:
See:

Returns the rlp encoding of the private transaction

Returns:
Type
Buffer

(static) toJSON() → {Array|String}

Source:
See:

Returns the private transaction in JSON format

Returns:
Type
Array | String

getBaseFee() → {BN}

Source:

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

Returns:
Type
BN

getChainId() → {Buffer}

Source:

returns chain ID

Returns:
Type
Buffer

getDataFee() → {BN}

Source:

The amount of gas paid for the data in this tx

Returns:
Type
BN

getSenderAddress() → {Buffer}

Source:

returns the sender's address

Returns:
Type
Buffer

getSenderPublicKey() → {Buffer}

Source:

returns the public key of the sender

Returns:
Type
Buffer

getUpfrontCost() → {BN}

Source:

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

Returns:
Type
BN

hash(includeSignatureopt) → {Buffer}

Source:

Computes a sha3-256 hash of the serialized tx

Parameters:
Name Type Attributes Default Description
includeSignature Boolean <optional>
true

whether or not to inculde the signature

Returns:
Type
Buffer

sign(privateKey)

Source:

sign a private transaction with a given private key

Parameters:
Name Type Description
privateKey Buffer

Must be 32 bytes in length

toCreationAddress() → {Boolean}

Source:

If the tx's to is to the creation address

Returns:
Type
Boolean

validate(stringErroropt) → {Boolean|String}

Source:

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

Parameters:
Name Type Attributes Default Description
stringError Boolean <optional>
false

whether to return a string with a description of why the validation failed or return a Boolean

Returns:
Type
Boolean | String

verifySignature() → {Boolean}

Source:

Determines if the signature is valid

Returns:
Type
Boolean