Chia 🌱 - DataPlayer, work with DataLayer like a human

Simplify interaction with Chia DataLayer, encrypt and decrypt your data with a password using this tool

3 min read
Chia 🌱 - DataPlayer, work with DataLayer like a human

  • Working with hexadecimal data is not convenient to manage, both for reading and writing
  • That anyone who subscribes to your datastore can see the raw data can be a compromise

DataPlayer is a tool that comes to cover these problems, it allows reading and writing data in DataLayer with human language, functioning as a bridge between the user and Chia DL.

Encoding and encryption with COSE

(CBOR Object Signing and Encryption) It is a data format for concise message representation. It is optimized for energy-efficient devices. COSE messages can be encrypted, MAC used, and signed. The DataPlayer currently only works with MAC0 encryption.

diagrama de funcionamiento de dataplayer
Operation Diagram of dataplayer


You can find the repository with the original code on my Github.


A python3 interpreter and the pipenv library, to create and use the virtual environment.

pip3 install pipenv



Install the environment with

pipenv install

Access the environment with

pipenv shell

You can also directly run datalayer without entering the environment:

pipenv run python dataplayer --help

usage: dataplayer datastore [-h] ...


The config.yaml file is loaded (at the root of the project) by default. Edit it if you are not using DataPlayer on the same machine as the Chia operating node.

Structure config.yaml:

  host: "localhost" #Host of the wallet
  private_wallet_cert_path: "~/.chia/mainnet/config/ssl/wallet/private_wallet.crt" #Private certificate to connect with RPC
  private_wallet_key_path: "~/.chia/mainnet/config/ssl/wallet/private_wallet.key" #Key of the certificate to connect with RP
    wallet: 9256 #TCP Port of wallet RPC
    datalayer: 8562 #TCP Port of datalayer RPC
    chia: 1 #ID of Chia wallet (default)
    datalayer: 2 #ID of datalayer wallet (default)

log_level: "WARNING" #Log level (DEBUG, INFO, WARNING, ERROR) (default WARNING)

File .env

If you plan to use the COSE codec, edit the .env file and correctly set the COSE_KEY environment variable, following the same 32 characteres HMAC-SHA-MD5 key format.

cat .env
If you do not specify an environment variable key, the default key will be use


usage: dataplayer datastore [-h] --id ID [--codec {hex,cose}] --action {update_key,read_key,list_keys} [--key KEY] [--value VALUE]
                            [--cose-ph COSE_PH [COSE_PH ...]] [--cose-uh COSE_UH [COSE_UH ...]]

optional arguments:
  -h, --help            show this help message and exit
  --id ID, -i ID        Datastore ID
  --codec {hex,cose}, -c {hex,cose}
                        Encoding type for reading or updating (default hex)
  --action {update_key,read_key,list_keys}, -a {update_key,read_key,list_keys}
                        Action to execute over datastore (required)
  --key KEY, -k KEY     Key of selection (required for read_key, update_key actions)
  --value VALUE, -v VALUE
                        Value for update_key action (optional)
  --cose-ph COSE_PH [COSE_PH ...], -cph COSE_PH [COSE_PH ...]
                        List of protected headers to store for update_key action and cose codec (optional). Format: FOO=BAR ABC=XYZ
  --cose-uh COSE_UH [COSE_UH ...], -cuh COSE_UH [COSE_UH ...]
                        List of unprotected headers to store for update_key action and cose codec (optional). Format: FOO=BAR ABC=XYZ

examples of use

List keys from a datastore

./dataplayer datastore --id="2530caa7911d0c7c3b93f53927f0fd5bf18b82ac290f4476e26e5b3c32e8526c" -a "list_keys"
  "keys": [
  "success": true

Update keys with default HEX encoding

./dataplayer datastore --id="2530caa7911d0c7c3b93f53927f0fd5bf18b82ac290f4476e26e5b3c32e8526c" -a "update_key" -k "humanized_key" -v "hello world" -c hex
  "success": true,
  "tx_id": "0x1ba3397f6e51a16e03244d4015bfcce6d598053db91c3ace6c036e038a006f5e"

Update keys with COSE encoding and encryption

./dataplayer datastore --id="2530caa7911d0c7c3b93f53927f0fd5bf18b82ac290f4476e26e5b3c32e8526c" -a "update_key" -k "encoded_key" -v "hello worrldd" -c cose -cph a_protected_header=secret_value -cuh an_unprotected_header=public_value
  "success": true,
  "tx_id": "0xaecb1953cdbdb5c2294591c0538c6315c5f2fcfe8fcebf1418680b25271943ad"

Read keys with default HEX encoding

./dataplayer datastore --id="2530caa7911d0c7c3b93f53927f0fd5bf18b82ac290f4476e26e5b3c32e8526c" -a "read_key" -k "humanized_key" -c hex
  "success": true,
  "value": "hello world"

Read keys with COSE encoding and encryption

./dataplayer datastore --id="2530caa7911d0c7c3b93f53927f0fd5bf18b82ac290f4476e26e5b3c32e8526c" -a "read_key" -k "encoded_key" -c cose
  "success": true,
  "value": {
    "payload": "hello worrldd",
    "protected_headers": {
      "a_protected_header": "secret_value"
    "unprotected_headers": {
      "an_unprotected_header": "public_value"