Onchain metadata exchange protocol
Project description
Microscope ChainMeta Reader
chainmeta is a Python module that loads, validates, and parses chainmeta from Microscope protocol participants.
What is Microsocope?
Read Chainmeta from Database
Before accessing Microscope's Open Chainmeta database, you need to obtain database credentials. Once you have the connection string, you can export it as an environment variable as follows:
export CHAINMETA_DB_CONN=mysql+pymysql://user:pwd@dbhost/chainmeta
Alternatively, you can set the connection string explicitly in your code using set_connection_string():
>>> import chainmeta as cm
>>> cm.set_connection_string("mysql+pymysql://user:pwd@dbhost/chainmeta")
To read all chainmeta from the database, use search_chainmeta():
>>> result_generator = cm.search_chainmeta()
>>> list(result_generator)
To filter the chainmeta based on specific attributes, you can pass a filter dictionary to search_chainmeta():
>>> filter = {"address": "0xf177aa7b0602f787f6f01c65f4b2e267336fd349", "chain": "ethereum-mainnet"}
>>> result_generator = cm.search_chainmeta(filter=filter)
>>> list(result_generator)
This will return a list of chainmeta that match the specified filter.
Note: The search_chainmeta() function only returns a generator that lazily loads the chainmeta from the database. Therefore, you need to convert it to a list or iterate over it to access the actual data.
Read from Local File
You can read chainmeta from a local file using the load() function provided by chainmeta. It will load all included artifacts, validate the artifacts, and translate them to common schema. Here's an example:
>>> with open("./examples/coinbase_sample.json") as f:
... metadata = cm.load(f, artifact_base_path="./examples")
...
You can access the metadata in common schema via metadata["chainmetadata"]["artifact"] and the raw metadata via metadata["chainmetadata"]["raw_artifact"].
Contribute Chainmeta to Database
If you want to contribute your metadata to the Open Chainmeta database, you can use the upload_chainmeta() function provided by chainmeta. Here's an example:
>>> common_metadata = metadata["chainmetadata"]["artifact"]
>>> cm.upload_chainmeta(common_metadata)
Alternatively, you can use the upload.py script provided by chainmeta to upload chainmeta from a file. Here's an example:
./upload.py ./examples/coinbase_sample.json
This will upload the chainmeta in the ./examples/coinbase_sample.json file to the Open Chainmeta database.
See the usage.py file for more details.
Adding New Categories to Taxonomy
Only categories defined in the taxonomy can be used, and this enforcement is maintained through chainmeta/config/categories.json.
Follow these steps, if you need to add new categories to taxonomy:
-
Make a Pull Request (PR): Create a Pull Request to add the new categories to the categories.json file.
-
Description and Discussion: In your Pull Request, be sure to provide a clear description of why you believe these new categories are needed and how they will be used. This information will help the project maintainers understand the rationale behind your request.
-
Weekly Meeting: All PRs will be discussed in weekly meetings. This means that the project maintainers will review your proposed changes and decide whether to accept or reject them based on the discussion during the meeting.
Remember to follow the contribution guidelines and any specific instructions provided by the maintainers of the project. Additionally, ensure that your proposed categories align with the project's goals and objectives.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chainmeta-0.0.1.tar.gz.
File metadata
- Download URL: chainmeta-0.0.1.tar.gz
- Upload date:
- Size: 31.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caa12ce73e97ae0c340ac1be470ce95d562bfe829cae4afb97cec4fe9fd7330d
|
|
| MD5 |
d2c26b5b153ed349dff3bacd3e72efeb
|
|
| BLAKE2b-256 |
6bd35da359242da1c57a4e0c7816368401ff3123bde9cbbe4c260b9b6e6baf9b
|
File details
Details for the file chainmeta-0.0.1-py3-none-any.whl.
File metadata
- Download URL: chainmeta-0.0.1-py3-none-any.whl
- Upload date:
- Size: 36.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3402754a12204fc064267515dba13f170ee277fff47381255f9e3c35f82ca03
|
|
| MD5 |
5a30f3f3ea417160a0e8f0c8c070cbc7
|
|
| BLAKE2b-256 |
d5b4363105becedaec81cefaa269b1fd892a27b9965a9f309aef0424a5271290
|