Model A signed or unsigned FAT-0 Transaction
Kind: global class
Access: protected
- Transaction0
- new Transaction(builder)
- .getInputs() ⇒
object
- .getOutputs() ⇒
object
- .getMetadata() ⇒
*
- .isCoinbase() ⇒
boolean
- .getEntry() ⇒
Entry
- .getChainId() ⇒
string
- .getEntryhash() ⇒
string
- .getTimestamp() ⇒
number
- .getPending() ⇒
boolean
- .getMarshalDataSig(inputIndex) ⇒
Buffer
- .validateSignatures() ⇒
boolean
Param | Type | Description |
---|---|---|
builder | TransactionBuilder | object |
Either a TransactionBuilder object or a FAT-0 transaction object content |
Example
//From transaction builder
let tx = new TransactionBuilder(tokenChainId)
.input("Fs1q7FHcW4Ti9tngdGAbA3CxMjhyXtNyB1BSdc8uR46jVUVCWtbJ", 150)
.output("FA3aECpw3gEZ7CMQvRNxEtKBGKAos3922oqYLcHQ9NqXHudC6YBM", 150)
.build();
tx.getInputs(); // => {"FA1PkAEbmo1XNangSnxmKqi1PN5sVDbQ6zsnXCsMUejT66WaDgkm":150}
tx.getChainId(); // => "013de826902b7d075f00101649ca4fa7b49b5157cba736b2ca90f67e2ad6e8ec"
//or from API response
const response =
{
entryhash: '68f3ca3a8c9f7a0cb32dc9717347cb179b63096e051a60ce8be9c292d29795af',
timestamp: 1550696040,
data:
{
inputs: {FA1zT4aFpEvcnPqPCigB3fvGu4Q4mTXY22iiuV69DqE1pNhdF2MC: 10},
outputs: {FA3aECpw3gEZ7CMQvRNxEtKBGKAos3922oqYLcHQ9NqXHudC6YBM: 10}
}
};
tx = new Transaction(response);
tx.getEntryHash(); // => "68f3ca3a8c9f7a0cb32dc9717347cb179b63096e051a60ce8be9c292d29795af"
Get the inputs object for the transaction (Map of Address => Token IDs)
Kind: instance method of Transaction0
Returns: object
- - The transaction's inputs
Get the outputs object for the transaction (Map of Address => Token IDs)
Kind: instance method of Transaction0
Returns: object
- - The transaction's outputs
Get the metadata if present for the transaction if present
Kind: instance method of Transaction0
Returns: *
- - The transaction's metadata (if present, undefined if not)
Check whether this transaction is a coinbase (token minting) transaction
Kind: instance method of Transaction0
Returns: boolean
- - Whether the transaction is a coinbase transaction or not
Get the factom-js Entry object representing the signed FAT transaction. Can be submitted directly to Factom
Kind: instance method of Transaction0
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
Get the token chain ID for this transaction
Kind: instance method of Transaction0
Returns: string
- - The chain ID string. Undefined if the transaction is constructed from an object or unsigned
Get the Factom entryhash of the transaction.
Kind: instance method of Transaction0
Returns: string
- - The entryhash of the transaction. Only defined if the Transaction was constructed from an object
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 Transaction0
Returns: number
- - The integer unix timestamp
Get the pending status of the transaction at the time of request.
Kind: instance method of Transaction0
Returns: boolean
- - The pending status of the entry in the daemon
Get the assembled ("marshalled") data that needs to be signed for the transaction for the given input address index
Kind: instance method of Transaction0
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 |
Validate all the signatures in the transaction against the input addresses
Kind: instance method of Transaction0
Returns: boolean
- returns true if signatures are valid, throws error otherwise.