Skip to main content

This library provides functions for encoding and decoding keyless addresses, used by the TRAIT blockchain: application agent addresses, transactional addresses, and named addresses.

Project description

Keyless Addresses Python Library

This Python library provides functionality for encoding and decoding keyless addresses.

A keyless address is a type of address that doesn't rely on cryptographic key pairs for identification. Instead, it is derived from a combination of identifiers and checksums, making it suitable for various use cases such as tracking and verification.

Installation

You can install the library using pip:

pip install traitkeyless

Usage

Encode and Decode AppAgent Addresses

import traitkeyless

app_agent_id = 123

# Encode an AppAgent address
encoded_address = traitkeyless.encode_app_agent_address(app_agent_id)
assert encoded_address == "ttowKp8AmRn9nxt8Gcout4stYQem7TZNkhpnVmtpS5KG39m2Y"

# Decode the AppAgent address
decoded_app_agent_id = traitkeyless.decode_app_agent_address(encoded_address)
assert decoded_app_agent_id == 123

Encode and Decode Transactional Addresses

import traitkeyless

app_agent_id = 123
transactional_address_id = 456

# Encode a Transactional address
encoded_address = traitkeyless.encode_transactional_address(app_agent_id, transactional_address_id)
assert encoded_address == "ttowKp8AmjjQh4HoMJwdKPyEQS5HSXQHwBUrLbn2LJFopLG85"

# Decode the Transactional address
decoded_data = traitkeyless.decode_transactional_address(encoded_address)
assert decoded_data == (123, 456)

Encode and Decode Named Addresses

import traitkeyless

app_agent_id = 123
address_name = "example123"

# Encode a Named address
encoded_address = traitkeyless.encode_named_address(app_agent_id, address_name)
assert encoded_address == "ttowKp8Amrt2FQ2eNdsbMsWDhEDiavXcVdeJBhQE7ttL1np4c"

# Decode the Named address
decoded_data = traitkeyless.decode_named_address(encoded_address)
assert decoded_data == (123, "example123")

Decode any address

import traitkeyless

app_agent_id = 123

# Encode a Named address
encoded_address = traitkeyless.encode_app_agent_address(app_agent_id)
assert encoded_address == "ttowKp8AmRn9nxt8Gcout4stYQem7TZNkhpnVmtpS5KG39m2Y"

# Decode the Named address
decoded_data = traitkeyless.decode_address(encoded_address)
expected_data = traitkeyless.BlockchainAddressInfo(
    address=encoded_address,
    account_id="0x7b000000013c8b3aeb6b293833058fc7db52fc03f6ce344bca98bd7825ff7477",
    address_type=traitkeyless.AddressType.AppAgent,
    app_agent_id=123,
    ta_id=None,
    address_name=None,
)
assert decoded_data == expected_data

Development

To generate python stub files:

stubgen traitkeyless/keyless.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traitkeyless-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traitkeyless-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file traitkeyless-0.1.0.tar.gz.

File metadata

  • Download URL: traitkeyless-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for traitkeyless-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f4d26710629a4d1ffed0b9191bb4875d45396b675719042f7f4d4b5049c90b8e
MD5 80035f77022d45ca7b2302fa22487c01
BLAKE2b-256 ec0efc708469d51f5f847f93980ff652d58717fe7e0c948def2228fd31cb36f3

See more details on using hashes here.

File details

Details for the file traitkeyless-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: traitkeyless-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for traitkeyless-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50506281ac2bd8b7cff3d96ab95e297c914e3da6e412ef5ad88ef9699b48ce63
MD5 62105364c1d5670481f9abf5d9de0295
BLAKE2b-256 03904bcf557614fd57a295098e9f88cfa4ae2b6523c0182c30a893dc43fea68d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page