Interact with the Bitcoin blockchain using highly customizable operations to submit transactions.
Create the transaction object
Use BlockchainTransaction to build the transaction object, using previously stored transaction history information:
- Bitcoin is sent in blocks, which must be spent as a whole. It cannot be partially spent. The amount not intended to be sent is considered change and returns to the sender’s wallet. A change address is specially created for this purpose and belongs to the sender.
- You need to know the transaction ID from prior interactions with the blockchain to use it as input.
- The transaction exists locally until it is submitted to the Bitcoin blockchain.
- There is no fee field when building a Bitcoin BlockchainTransaction object. The fee is automatically calculated based on what is not included in the outputs field.
Use BlockchainTransactionData to retrieve the output of the previous transaction existing in the blockchain that is associated with the preceding transaction ID:
This is the amount of bitcoin available to make a transaction.
Visualize the transaction outputs with Dataset:
Total the amounts associated with the outputs of the transaction:
Calculate the transaction fee:
Use CurrencyConvert to convert the transaction fee to satoshis:
Sign the transaction
Use BlockchainTransactionSign to sign the transaction with the private key:
- You must provide the private key that unlocks the outputs referenced in the “Inputs” field of the BlockchainTransaction object.
Submit the transaction
Use BlockchainTransactionSubmit to send the transaction to the blockchain:
- After the transaction is submitted, you must wait for it to be included in a block. The block can then be mined and added to the blockchain.
- If a fee is not left for the miner, it is possible the transaction will not get added to a block.