Skip to content

Latest commit

 

History

History
138 lines (101 loc) · 6.47 KB

Transaction1.md

File metadata and controls

138 lines (101 loc) · 6.47 KB

Transaction1

Model A signed or unsigned FAT-1 Transaction

Kind: global class
Access: protected

new Transaction(builder)

Param Type Description
builder TransactionBuilder | object Either a TransactionBuilder object or a FAT-0 transaction object content

transaction1.getInputs() ⇒ object

Get the inputs object for the transaction (Map of Address => Amount)

Kind: instance method of Transaction1
Returns: object - - The transaction's inputs

transaction1.getOutputs() ⇒ object

Get the outputs object for the transaction (Map of Address => Amount)

Kind: instance method of Transaction1
Returns: object - - The transaction's outputs

transaction1.getMetadata() ⇒ *

Get the metadata if present for the transaction if present

Kind: instance method of Transaction1
Returns: * - - The transaction's metadata (if present, undefined if not)

transaction1.getTokenMetadata() ⇒ Array.<object>

Get the token metadata if present for the coinbase transaction

Kind: instance method of Transaction1
Returns: Array.<object> - - The token metadata (if present, undefined if not)

transaction1.isCoinbase() ⇒ boolean

Check whether this transaction is a coinbase (token minting) transaction

Kind: instance method of Transaction1
Returns: boolean - - Whether the transaction is a coinbase transaction or not

transaction1.getEntry() ⇒ Entry

Get the factom-js Entry object representing the signed FAT transaction. Can be submitted directly to Factom

Kind: instance method of Transaction1
Returns: Entry - - Get the Factom-JS Factom entry representation of the transaction, including extids & other signatures
See: https://github.com/PaulBernier/factomjs/blob/master/src/entry.js
Example

const {FactomCli, Entry, Chain} = require('factom');
     const cli = new FactomCli(); // Default factomd connection to localhost:8088 and walletd connection to localhost:8089

     const tokenChainId = '013de826902b7d075f00101649ca4fa7b49b5157cba736b2ca90f67e2ad6e8ec';

     const tx = new TransactionBuilder(tokenChainId)
     .input("Fs1q7FHcW4Ti9tngdGAbA3CxMjhyXtNyB1BSdc8uR46jVUVCWtbJ", [150])
     .output("FA3aECpw3gEZ7CMQvRNxEtKBGKAos3922oqYLcHQ9NqXHudC6YBM", [150])
     .build();

     //"cast" the entry object to prevent compatibility issues
     const entry = Entry.builder(tx.getEntry()).build();

     await cli.add(entry, "Es32PjobTxPTd73dohEFRegMFRLv3X5WZ4FXEwNN8kE2pMDfeMym"); //commit the transaction entry to the token chain

transaction1.getChainId() ⇒ string

Get the token chain ID for this transaction

Kind: instance method of Transaction1
Returns: string - - The chain ID string. Undefined if the transaction is constructed from an object or unsigned

transaction1.getEntryhash() ⇒ string

Get the Factom entryhash of the transaction.

Kind: instance method of Transaction1
Returns: string - - The entryhash of the transaction. Only defined if the Transaction was constructed from an object

transaction1.getTimestamp() ⇒ number

Get the unix timestamp of when the Transaction was signed (locally built transactions) or committed to Factom (from RPC response JSON)

Kind: instance method of Transaction1
Returns: number - - The integer unix timestamp

transaction1.getPending() ⇒ boolean

Get the pending status of the transaction at the time of request.

Kind: instance method of Transaction1
Returns: boolean - - The pending status of the entry in the daemon

transaction1.getMarshalDataSig(inputIndex) ⇒ Buffer

Get the assembled ("marshalled") data that needs to be signed for the transaction for the given input address index

Kind: instance method of Transaction1
Returns: Buffer - - Get the marshalled data that needs to be hashed then signed

Param Type Description
inputIndex number The input index to marshal to prep for hashing then signing

transaction1.validateSignatures() ⇒ boolean

Validate all the signatures in the transaction against the input addresses

Kind: instance method of Transaction1
Returns: boolean - returns true if signatures are valid, throws error otherwise.