[Hyperledger Iroha] Query with Python library

Article content

How to execute a query using the Hyperledger Iroha Python library.

Try it

Try executing "Get Account Transactions" to get a list of transactions sent by the specified account.

Implementation

Iroha's host name and private key are set in iroha_config.

The points are the following three. -Use "iroha.query" to create a query. (Update system uses "iroha.command") -Use "sign_query" for signature. (Update system uses "sign_transaction") -Use "send_query" to send a query. (Update system uses "send_tx")

Execution result

I was able to get the information of the transaction sent by the specified account. I set page_size to 10, but I didn't put much data on the blockchain, so I was able to get only 3 data.

query_hash: "a45f8b59aa211688836bb6567c10baf10e24dfdc9db6c62d3fc8a779200ee136"
transactions_page_response {
  transactions {
    payload {
      reduced_payload {
        commands {
          create_asset {
            asset_name: "samplecoin"
            domain_id: "test"
            precision: 10
          }
        }
        commands {
          add_asset_quantity {
            asset_id: "samplecoin#test"
            amount: "100000000"
          }
        }
        creator_account_id: "admin@test"
        created_time: 1594000825126
        quorum: 1
      }
    }
    signatures {
      public_key: "313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910"
      signature: "042b25c8096ca4bfcaca54d05c3d862498f38ddc612b0255138cc74044005d0475467176ef84672fd79b93714e8263e22aa867e7f8e22cf7eba06bb0e63e0b02"
    }
  }
  transactions {
    payload {
      reduced_payload {
        commands {
          transfer_asset {
            src_account_id: "admin@test"
            dest_account_id: "test@test"
            asset_id: "samplecoin#test"
            description: "test"
            amount: "10000"
          }
        }
        creator_account_id: "admin@test"
        created_time: 1594002435597
        quorum: 1
      }
    }
    signatures {
      public_key: "313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910"
      signature: "f147a7e1c1604a3172efa91e4604fd4bfff728fe0d8d4c644e7d3a0d65ee4f3d2436ad9a26bc9777b0de514f120ed6b4d83a5410cbc097a281a5a588702d4d06"
    }
  }
  transactions {
    payload {
      reduced_payload {
        commands {
          create_account {
            account_name: "iroha"
            domain_id: "test"
            public_key: "efdc215eab6dd2c4435d370da73e4b88350e1fed9d39afed503fcbee985fce1f"
          }
        }
        creator_account_id: "admin@test"
        created_time: 1594016319157
        quorum: 1
      }
    }
    signatures {
      public_key: "313a07e6384776ed95447710d15e59148473ccfc052a681317a72a69f2a49910"
      signature: "429bf3ae70b60d31ab3fc3c15fa11cb8155b6a824f831652c1c46068feaeb866846b8048e0959cbcbeed532423f050e77d2fe192ea90d0827a6f1489bf67ec0a"
    }
  }
  all_transactions_size: 3
}

Related article

[Hyperledger Iroha] Notes on how to use Python SDK -[Hyperledger Iroha] Create an account using Python library

Impressions

I tried using the Iroha library. Other queries will work if you change the name of the query to be executed or change the parameters.

As long as you look at the Iroha query, you can easily get "who" and "what", but It seems that there is no query that tells "for which asset", "who", and "what".

Recommended Posts

[Hyperledger Iroha] Query with Python library
[Hyperledger Iroha] Create an account using Python library
Use cryptography library cryptography with Docker Python image
Try HTML scraping with a Python library
Publish your own Python library with Homebrew
Python 3.6 email library
FizzBuzz with Python3
Scraping with Python
Python ast library
Statistics with python
Scraping with Python
Python with Go
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
Tested with Python
★ Memo ★ Python Iroha
python starts with ()
with syntax (Python)
Python Library notes
Bingo with python
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
Cast with python
[Hyperledger Iroha] When I execute a query from the Python library, [bad timestamp: sent from future] is returned.
[Personal memo] julia --Using Python library with julia using PyCall
Library comparison summary to generate PDF with Python
Create polka dot wallpaper with Python Image Library
Registering with PyPI from modern Python library self-made
Serial communication with Python
Zip, unzip with python
Django 1.11 started with Python3.6
Primality test with Python
Socket communication with Python
Data analysis with python 2
Try scraping with Python.
Learning Python with ChemTHEATER 03
Sequential search with Python
"Object-oriented" learning with python
Run Python with VBA
Handling yaml with python
Solve AtCoder 167 with python
Serial communication with python
[Python] Use JSON with Python
Learning Python with ChemTHEATER 05-1
Run prepDE.py with python3
1.1 Getting Started with Python
Collecting tweets with Python
python algorithmic trading library
Binarization with OpenCV / Python
Kernel Method with Python
Non-blocking with Python + uWSGI
Let's call your own C ++ library with Python (Preferences)
Posting tweets with python
Drive WebDriver with python
Use mecab with Python3
[Python] Redirect with CGIHTTPServer
Voice analysis with python
Think yaml with python