Bech32 Strings

To provide some clarity for arguments, some functions in the SDK are documented that they take a type like AccAddress where one may expect a str. It is simply a type alias annotation (equivalent to str) that serves only to remind the developer which format the string is expected to be in.

Terra SDK also provides useful functions for checking and converting addresses and pubkeys.

Addresses

AccAddress

class terra_sdk.core.strings.AccAddress(x)

Terra Bech32 Account Address – type alias of str.

terra_sdk.core.strings.is_acc_address(data)[source]

Checks whether the given string is a properly formatted Terra account address.

Parameters

data (str) – string to check

Returns

whether the string is a proper account address

Return type

bool

terra_sdk.core.strings.to_acc_address(data)[source]

Converts a validator operator address into an account address.

Parameters

data (ValAddress) – validator operator address

Raises

ValueError – if provided string is not Bech32

Returns

account address

Return type

AccAddress

ValAddress

class terra_sdk.core.strings.ValAddress(x)

Terra Bech32 Validator Operator Address – type alias of str.

terra_sdk.core.strings.is_val_address(data)[source]

Checks whether the given string is a properly formatted Terra validator operator address.

Parameters

data (str) – string to check

Returns

whether the string is a proper validator address

Return type

bool

terra_sdk.core.strings.to_val_address(data)[source]

Converts an account address into a validator operator address.

Parameters

data (AccAddress) – account address

Raises

ValueError – if provided string is not Bech32

Returns

validator operator address

Return type

ValAddress

PubKeys

AccPubKey

class terra_sdk.core.strings.AccPubKey(x)

Terra Bech32 Account Address – type alias of str.

terra_sdk.core.strings.is_acc_pubkey(data)[source]

Checks whether the provided string is a properly formatted Terra account pubkey.

Parameters

data (str) – string to check

Returns

whether string is account pubkey

Return type

bool

terra_sdk.core.strings.to_acc_pubkey(data)[source]

Converts a validator pubkey into an account pubkey.

Parameters

data (ValPubKey) – validator pubkey

Raises

ValueError – if provided string is not Bech32

Returns

account pubkey

Return type

AccPubKey

ValPubKey

class terra_sdk.core.strings.ValPubKey(x)

Terra Bech32 Validator PubKey – type alias of str.

terra_sdk.core.strings.is_acc_pubkey(data)[source]

Checks whether the provided string is a properly formatted Terra account pubkey.

Parameters

data (str) – string to check

Returns

whether string is account pubkey

Return type

bool

terra_sdk.core.strings.to_acc_pubkey(data)[source]

Converts a validator pubkey into an account pubkey.

Parameters

data (ValPubKey) – validator pubkey

Raises

ValueError – if provided string is not Bech32

Returns

account pubkey

Return type

AccPubKey

ValConsPubKey

class terra_sdk.core.strings.ValConsPubKey(x)

Terra Bech32 Validator Conensus PubKey – type alias of str.