Get coinbase transaction
$get coinbase transaction is a function used to retrieve the transaction hash once a transaction is posted on Coinbase.
This function will need a transfer id as an argument, which can be obtained from the transaction info object returned by the coinbase send tokens command.
Parameters
Transfer ID: The transfer ID that is provided by Coinbase when a transaction is made. This ID is used to track the status of the transaction.
Return Value
This function returns a yaml object with data from the transaction.
Since Coinbase doesn't post transactions to the blockchain right away, the data returned by this function will change over time. The transaction hash will be added to the object at the path "details.crypto_transaction_hash" once the transaction posts to the blockchain. The function will need to be run multiple times to see these updates.
Example
ui console view config coinbase("your api key", "your api secret", "your passphrase") send crypto from coinbase(0.0001,"BTC","bc1q40lacrcwkl037yejtqaf097njle8u8eashamr4",#txinfo) log object("Transaction Info: {#txinfo}") wait for crypto hash($object entity(#txinfo,"id")) define wait for crypto hash(#tx id) { set(#tx data,$get coinbase transaction(#tx id),"Global") loop while($crypto hash doesnt exist()) { wait(10) set(#tx data,$get coinbase transaction(#tx id),"Global") } log("Transaction Hash: {$object entity(#tx data,"details.crypto_transaction_hash")}") } define $crypto hash doesnt exist { if($comparison($object entity(#tx data,"details.crypto_transaction_hash"),"= Equals","")) { then { return("true") } else { return("false") } } }
In this script, replace "your api key", "your api secret", and "your passphrase" with your actual API key, API secret, and passphrase.
The script will send 0.0001 of Bitcoin (BTC) to the address "bc1q40lacrcwkl037yejtqaf097njle8u8eashamr4". The transaction information will be stored in a variable named #txinfo. This variable is logged to the console.
We then run a custom command, wait for crypto hash, that will check $get coinbase transaction every 10 seconds to see if "details.crypto_transaction_hash" exists. Note that this check has been abstracted into the function $crypto hash doesnt exist.
Notice also the use of $object entity to find specific pieces of information from our transaction data.
Once the hash is found, it is logged to the console.
Please remember that your API key, API secret, passphrase, and addresses are sensitive information. If you need to show someone your script, ensure to remove these details first.
After running the command, you will see the transaction hash in the console. The exact hash will be different for each transaction.