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

TRAIT Keyless Address Encoding and Decoding Library

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

A keyless address is a type of blockchain address that does not depend on a pair of cryptographic keys for identification. Instead, it is derived from a combination of identifiers and checksums and is controlled by an AppAgent. This makes the keyless addresses convenient for use in off-chain applications.

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 == "ttowKp8AmQuGfbBGikG2pbdYNnErhHRaLrdktJeZEfJVeVnTp"

# 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 == "ttowKp8AmjjQh4GoN7xMiQWwVyyrU1Pu7GRf5HxFmV5t43TXG"

# 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 = "hot-wallet"

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

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

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 == "ttowKp8AmQuGfbBGikG2pbdYNnErhHRaLrdktJeZEfJVeVnTp"

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

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.4.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.4-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traitkeyless-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 5d7a4819522224a47502f0905c0cea16d12e86a2387b5cd9713d3ed73c28de36
MD5 ea1c002bb120d5c97760cc737be9eb80
BLAKE2b-256 4c10cee1cbef141f18670e4654dd0543d65c7698340e0855e3fc05209aed4315

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traitkeyless-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0728caad478044fc4af3572772a90390a28ece2a96648ece879bd07628040ee7
MD5 b2ed552d52cf1893ebd686e4b2cf3f78
BLAKE2b-256 5c7da074efa9d21457c09e9b7eadb8a9ed48ec3646461a0390398c5ee59213bb

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