Convert string to principal

Description

Parse string addresses into principal types using c32 decoding in Clarity

Use Cases

  • Parsing user input addresses in contracts

  • Converting stored string addresses to principals

  • Validating address formats before use

  • Building dynamic contract calls with string inputs

Key Concepts

  • c32 alphabet - 0123456789ABCDEFGHJKMNPQRSTVWXYZ (no I, L, O, U)

  • Checksum - Last 4 bytes verify address integrity

  • Version byte - First character indicates address type

  • Contract addresses - Include .contract-name suffix

Was this helpful?