<p>There is an open source implementation of block explorer that supports MySQL databases it is called Bitcoin-abe.  This also works with other cryptocurrencies besides BTC you can find it and the source code at <a href="https://github.com/bitcoin-abe/bitcoin-abe" rel="nofollow">https://github.com/bitcoin-abe/bitcoin-abe</a> it is written in Python so it may or may not fit your requirements, you should also be aware that it may take a couple of days to parse a blockchain and be ready to view in a web browser.  </p>

CC BY-SA 3.0
2014-02-28T04:49:07.373Z
2014-02-28T04:49:07.373Z
Mark S.
<p>I get this output from <strong>gettransaction</strong>:</p>

<pre><code>{
"txid" : "48476129249868825168d72ec6224d8be8ed70a204a7ac4b6523cf3eb8782e83",
"txid" : "48476129249868825168d72ec6224d8be8ed70a204a7ac4b6523cf3eb8782e83",
"version" : 1,
"time" : 1392083602,
"locktime" : 0,
"vin" : [
{
"txid" : "f56aaf54ccd5e6f1a5aa7d79f413c8b528151464ccc05b42c334ba3abcfec3a9",
"vout" : 0,
"scriptSig" : {
"asm" : "30450221008018b4a64cbf305691922152bc3823d6c2eb58ce3935aaad6ca3d9bc7cfeee27022050656428b7d69a50bd9c6ed8cf81213b7d3457c424cf722bb42da4e325ac4bb001 03edba2f5507510abf156b178b82ac93b36c4480010b0cd5242a86b2532655d11c",
"hex" : "4830450221008018b4a64cbf305691922152bc3823d6c2eb58ce3935aaad6ca3d9bc7cfeee27022050656428b7d69a50bd9c6ed8cf81213b7d3457c424cf722bb42da4e325ac4bb0012103edba2f5507510abf156b178b82ac93b36c4480010b0cd5242a86b2532655d11c"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 232306.19497700,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 fd4c23e37c3e35db14b045e1657c821696ffd774 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a914fd4c23e37c3e35db14b045e1657c821696ffd77488ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"MvL5PPHRz9PMHiwToAzXi7aptRrxZ9GLJY"
]
}
},
{
"value" : 3777.33695900,
"n" : 1,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 8c0634d7a07bd4041b4651c7b98ade93ca11e951 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a9148c0634d7a07bd4041b4651c7b98ade93ca11e95188ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"Mk19FdAUVMSp7MM5dWRPnA9Nvj6bjMaFmH"
]
}
}
],
"blockhash" : "000000000448d9bf8021c78b6eeb1182a2cc2281185870111e094e4278ea27b4",
"confirmations" : 45591,
"txntime" : 1392083602,
"time" : 1392083613
}
</code></pre>

<p>How can I decode it into something like this with Perl? I need it to export database to MySQL.</p>

<pre><code>Output:
wallet1 0.123 BTC
wallet2 0.5 BTC
Input:
wallet3 0.4 BTC
wallet4 0.222 BTC
Fees: 0.001 BTC
</code></pre>

<json-rpc><perl>
Decode transaction
user13993
# Decode transaction

(Asked by: username_0 on 2014-02-28)

I get this output from **gettransaction**:

```
{
"txid" : "48476129249868825168d72ec6224d8be8ed70a204a7ac4b6523cf3eb8782e83",
"txid" : "48476129249868825168d72ec6224d8be8ed70a204a7ac4b6523cf3eb8782e83",
"version" : 1,
"time" : 1392083602,
"locktime" : 0,
"vin" : [
{
"txid" : "f56aaf54ccd5e6f1a5aa7d79f413c8b528151464ccc05b42c334ba3abcfec3a9",
"vout" : 0,
"scriptSig" : {
"asm" : "30450221008018b4a64cbf305691922152bc3823d6c2eb58ce3935aaad6ca3d9bc7cfeee27022050656428b7d69a50bd9c6ed8cf81213b7d3457c424cf722bb42da4e325ac4bb001 03edba2f5507510abf156b178b82ac93b36c4480010b0cd5242a86b2532655d11c",
"hex" : "4830450221008018b4a64cbf305691922152bc3823d6c2eb58ce3935aaad6ca3d9bc7cfeee27022050656428b7d69a50bd9c6ed8cf81213b7d3457c424cf722bb42da4e325ac4bb0012103edba2f5507510abf156b178b82ac93b36c4480010b0cd5242a86b2532655d11c"
},
"sequence" : 4294967295
}
],
"vout" : [
{
"value" : 232306.19497700,
"n" : 0,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 fd4c23e37c3e35db14b045e1657c821696ffd774 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a914fd4c23e37c3e35db14b045e1657c821696ffd77488ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"MvL5PPHRz9PMHiwToAzXi7aptRrxZ9GLJY"
]
}
},
{
"value" : 3777.33695900,
"n" : 1,
"scriptPubKey" : {
"asm" : "OP_DUP OP_HASH160 8c0634d7a07bd4041b4651c7b98ade93ca11e951 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "76a9148c0634d7a07bd4041b4651c7b98ade93ca11e95188ac",
"reqSigs" : 1,
"type" : "pubkeyhash",
"addresses" : [
"Mk19FdAUVMSp7MM5dWRPnA9Nvj6bjMaFmH"
]
}
}
],
"blockhash" : "000000000448d9bf8021c78b6eeb1182a2cc2281185870111e094e4278ea27b4",
"confirmations" : 45591,
"txntime" : 1392083602,
"time" : 1392083613
}

```

How can I decode it into something like this with Perl? I need it to export database to MySQL.

```
Output:
wallet1 0.123 BTC
wallet2 0.5 BTC
Input:
wallet3 0.4 BTC
wallet4 0.222 BTC
Fees: 0.001 BTC

```

**Tags:** json-rpc, perl


---

## 1 answers

### Answer by username_1 on 2014-02-28. Score: 1

There is an open source implementation of block explorer that supports MySQL databases it is called Bitcoin-abe. This also works with other cryptocurrencies besides BTC you can find it and the source code at <https://github.com/bitcoin-abe/bitcoin-abe> it is written in Python so it may or may not fit your requirements, you should also be aware that it may take a couple of days to parse a blockchain and be ready to view in a web browser.


---

