Transactions
List transactions for a profile
The TransactionAggregate
acts like a self-paginating set of data by keeping track of the history. Every time you call the transactions
, sentTransactions
or receivedTransactions
method the last responses will be stored based on the wallet ID and the next time you call those methods again it will retrieve the next page. If you want to reset the history you can call profile.transactionAggregate().flush()
and start calling the methods again to retrieve fresh data.
1const firstPage = await profile.transactionAggregate().transactions();2const secondPage = await profile.transactionAggregate().transactions();3const thirdPage = await profile.transactionAggregate().transactions();
List transactions for a wallet
1const response = await wallet.transactions({ limit: 15 });2 3if (response.hasMore()) {4 // This will automatically advanced to the next page of every wallet with a limit of 15.5 const nextPage = await wallet.transactions({ limit: 15 });6}
Sign and broadcast a transaction through a wallet
1// 1. Sign and store the ID 2const transactionId = await wallet.transaction().signTransfer({ 3 sign: { 4 mnemonic: "this is a top secret passphrase", 5 }, 6 data: { 7 amount: "1", 8 to: "D61mfSggzbvQgTUe6JhYKH2doHaqJ3Dyib", 9 },10});11 12// 2. Broadcast with the ID from signing13await wallet.transaction().broadcast(transactionId);14 15// 3. Periodically check if the transaction has been confirmed16await wallet.transaction().transaction(transactionId).hasBeenConfirmed();
Sign and broadcast a transaction with multi-signature with 2 participants
Warning
You should always ensure to call wallet.syncIdentity()
before trying to sign transactions.
1// This is the initial transaction without any signatures. 2const transactionId = await wallet.transaction().signTransfer({ 3 nonce: "1", 4 from: "DRsenyd36jRmuMqqrFJy6wNbUwYvoEt51y", 5 sign: { 6 multiSignature: wallet.multiSignature(), 7 }, 8 data: { 9 amount: "1",10 to: "DRsenyd36jRmuMqqrFJy6wNbUwYvoEt51y",11 memo: "Sent from SDK",12 },13});14 15// Broadcast the transaction without any signatures.16await wallet.transaction().broadcast(transactionId);17 18// Add the first signature and re-broadcast the transaction.19await wallet.transaction().addSignature(transactionId, "FIRST_PASSPHRASE");20 21// Add the second signature and re-broadcast the transaction.22await wallet.transaction().addSignature(transactionId, "SECOND_PASSPHRASE");23 24// Sync all of the transactions from the Multi-Signature Server and check the state of each.25await wallet.transaction().sync();26 27// Broadcast the multi signature.28await wallet.transaction().broadcast(transactionId);
Sign and broadcast a multi-signature registration with 3 participants
Warning
You should always ensure to call wallet.syncIdentity()
before trying to sign transactions.
1// This is the initial transaction without any signatures. 2const transactionId = await wallet.transaction().signMultiSignature({ 3 nonce: "2", 4 from: "AH3Ca9QE9u9jKKTdUaLjAQqcqK4ZmSkVqp, 5 sign: { 6 multiSignature: { 7 publicKeys:[ 8 "0205d9bbe71c343ac9a6a83a4344fd404c3534fc7349827097d0835d160bc2b896", 9 "03df0a1eb42d99b5de395cead145ba1ec2ea837be308c7ce3a4e8018b7efc7fdb8",10 "03860d76b1df09659ac282cea3da5bd84fc45729f348a4a8e5f802186be72dc17f"11 ],12 min: 3,13 }14 },15 data: {16 publicKeys:[17 "0205d9bbe71c343ac9a6a83a4344fd404c3534fc7349827097d0835d160bc2b896",18 "03df0a1eb42d99b5de395cead145ba1ec2ea837be308c7ce3a4e8018b7efc7fdb8",19 "03860d76b1df09659ac282cea3da5bd84fc45729f348a4a8e5f802186be72dc17f"20 ],21 min: 3,22 senderPublicKey: "0205d9bbe71c343ac9a6a83a4344fd404c3534fc7349827097d0835d160bc2b896",23 },24});25 26await activeWallet.transaction().broadcast(transactionId);27 28// Add the first signature and re-broadcast the transaction.29await activeWallet.transaction().addSignature(transactionId, "FIRST_PASSPHRASE");30 31// Sync all of the transactions from the Multi-Signature Server and check the state of each.32await activeWallet.transaction().sync();33 34// Add the second signature and re-broadcast the transaction.35await activeWallet.transaction().addSignature(transactionId, "SECOND_PASSPHRASE");36 37// Sync all of the transactions from the Multi-Signature Server and check the state of each.38await activeWallet.transaction().sync();39 40// Add the third signature and re-broadcast the transaction.41await activeWallet.transaction().addSignature(transactionId, "THIRD_PASSPHRASE");42 43// Sync all of the transactions from the Multi-Signature Server and check the state of each.44await activeWallet.transaction().sync();45 46// Add the final signature by signing the whole transaction with the signatures of all participants.47await activeWallet.transaction().addSignature(transactionId, "FIRST_PASSPHRASE");48 49// Sync all of the transactions from the Multi-Signature Server and check the state of each.50await activeWallet.transaction().sync();51 52// Broadcast the multi signature.53await activeWallet.transaction().broadcast(transactionId);
Check what signatures a Multi-Signature Transaction or Registration is awaiting
Warning
If both of the below examples are true the transaction is ready to be broadcast.
1// Needs the signature of the currently active wallet.2wallet.transaction().isAwaitingOurSignature(transactionId);3 4// Needs the signatures of other wallets.5wallet.transaction().isAwaitingOtherSignatures(transactionId);
Last updated 2 years ago
Edit Page