Blockstack transactions are embedded into Bitcoin blockchain.. is it correct? How can we extract STACKS transactions from bitcoin node?

Hi @jwiley,

Blockstack transactions are embedded into Bitcoin blockchain… is it correct?

Does this mean that we can extract STACKS transactions from bitcoin node also?

If yes, could you please help how?

@stacksadmin

for v1, no. Only name operations (register, renew, etc) are recorded in the BTC chain.
for v2, only POX tx’s are recorded, i.e. https://tbtc.bitaps.com/mxVFsFW5N4mu1HPkxPttorvocvzeZ7KZyk
which is an example tx on the btc testnet from ongoing dev work for v2.

for STX tx’s, you’ll need to query your running v1 node.
Is there something specific you’re trying to do?

Hey Vishal! @jwiley definitely will have a better understanding on this than I do. (thanks Jesse!)

Hi @jwiley … I am trying to extract STX transactions as of a particular block height. Could you help which RPC or API i can use for extracting stx transactions from local stack node v1.

Hi Jesse @jwiley, could you please help how do i get the STX transactions based on a particular block height?

@vishalgupta96 I appreciate the urgency, but please keep in mind this is an open source project and Blockstack/Hiro PBC is just one of the many entities in this ecosystem. PBC employees have their own priorities and constraints – I’m grateful for the time and attention they’re able to give to help out community members here on the Forum and on Discord despite that.

For Stacks V1, you can get STX operations in a specific block using this endpoint: https://core.blockstack.org/#blockchain-operations-get-operations-in-block

As has been mentioned earlier, the transaction model in Stacks V2 is very different, and STX transactions will not be “embedded” into Bitcoin like they are in Stacks V1. You can read more here: https://docs.blockstack.org/stacks-blockchain/transactions

Thank you so much @diwaker & @jwiley . We are also so much grateful for the quick responses you have provided over my queries… Thanks a lot and i really can admit that this is one of the best forums where developers/architects can get their queries resolved as quickly as possible. I reminded multiple times because i was stuck at a point to decide whether i have to decide whether i can pull transactions or not.

Anyways thanks for the responses again.

2 Likes

No problem at all - but like @diwaker mentioned, we are pretty busy with the v2 work that’s ongoing so we try our best to respond in timely manners, but I’ll apologize for letting this stagnate a little.
To answer your questions, to get the tx from a block in blockstack-core, you’d run something like this:
curl -s https://core.blockstack.org/v1/blockchains/bitcoin/operations/546199 | jq
this returns an array , and each item in the array will have a txid, which we’ll use next:
curl -s https://core.blockstack.org/v1/subdomains/d04d708472ea3c147f50e43264efdb1535f71974053126dc4db67b3ac19d41fe | jq

Note that the above examples are available on the https://core.blockstack.org page

To retrieve BTC tx data, you have a few options.
first, let’s use an example from here: https://core.blockstack.org/v1/names/muneeb.id/history?page=0

{
  "373821": [
    {
      "address": "1QJQxDas5JhdiXhEbNS14iNjr8auFT96GP", 
      "block_number": 373821, 
      "consensus_hash": null, 
      "first_registered": 373821, 
      "importer": "76a9143e2b5fdd12db7580fb4d3434b31d4fe9124bd9f088ac", 
      "importer_address": "16firc3qZU97D1pWkyL6ZYwPX5UVnWc82V", 
      "last_creation_op": ";", 
      "last_renewed": 373821, 
      "name": "muneeb.id", 
      "namespace_block_number": 373601, 
      "op": ";", 
      "op_fee": 100000.0, 
      "opcode": "NAME_IMPORT", 
      "preorder_block_number": 373821, 
      "preorder_hash": "e58b193cfe867020ed84cc74edde2487889f28fe", 
      "revoked": false, 
      "sender": "76a914ff95f5612a26a81e919e4b6e63fdd929fd115d6d88ac", 
      "sender_pubkey": "0411d88aa37a0eea476a5b63ca4b1cd392ded830865824c27dacef6bde9f9bc53fa13a0926533ef4d20397207e212c2086cbe13db5470fd29616abd35326d33090", 
      "token_fee": "0", 
      "txid": "f75f58329714fd0455e1283e40cf27b07b933b75f06286874c8328ccedde21f7", 
      "value_hash": "f15528d0831d2beffed5d609d469cf4064bd0b51", 
      "vtxindex": 232
    }
  ], 
  ...

here, the block is 373821, and it’ll give us a txid of f75f58329714fd0455e1283e40cf27b07b933b75f06286874c8328ccedde21f7

We can then use a public explorer like so:


OR, through a series of cli commands, retrieve the same data from any running BTC node:

bitcoin-cli \
  -rpcconnect=bitcoin.blockstack.com \
  -rpcport=8332 \
  -rpcuser=blockstack \
  -rpcpassword=blockstacksystem \
getblockhash "373821"

bitcoin-cli \
  -rpcconnect=bitcoin.blockstack.com \
  -rpcport=8332 \
  -rpcuser=blockstack \
  -rpcpassword=blockstacksystem \
getblock "000000000000000007eaffe21d9bcc0ce42bdb6a0227f44549bbaad607faf387"



bitcoin-cli \
  -rpcconnect=bitcoin.blockstack.com \
  -rpcport=8332 \
  -rpcuser=blockstack \
  -rpcpassword=blockstacksystem \
getrawtransaction "f75f58329714fd0455e1283e40cf27b07b933b75f06286874c8328ccedde21f7"

and finally, you have to decode that raw output:

bitcoin-cli decoderawtransaction 010000000102c4f5a5cf850a863eda743738b4192bfe0ac784d509870dce0ee0bbd4ce6a0e030000008a47304402201b912a40b4b008898954a3524ed37d84fbd339617cc15f5b7dba85b3f71a09c1022071de54dc2620d05ae8548a5ef52785f505c49334d59019cb48f02423840528d901410411d88aa37a0eea476a5b63ca4b1cd392ded830865824c27dacef6bde9f9bc53fa13a0926533ef4d20397207e212c2086cbe13db5470fd29616abd35326d33090ffffffff0410270000000000000e6a0c69643b6d756e6565622e69647c150000000000001976a914ff95f5612a26a81e919e4b6e63fdd929fd115d6d88ac7c150000000000001976a914f15528d0831d2beffed5d609d469cf4064bd0b5188ac20e4870f000000001976a9143e2b5fdd12db7580fb4d3434b31d4fe9124bd9f088ac00000000

which will give you specific details about this particular tx.

this medium post might be helpful as well: https://medium.com/@peterjd42/basic-commands-to-interact-with-the-bitcoin-core-rpc-console-180da2c2dc45

Hello @jwiley, @diwaker : Just wanted to check if we have gone live with Blockstack V2 already?

Any useful links for setting up V2 node, RPC communication links would be helpful.

Yes, Stacks 2.0 went live on 1/14. Please visit https://docs.blockstack.org/ for the information you’re looking for.

Thanks for the reply Diwaker. I will take a look at the documentation.