Skip to content

Instantly share code, notes, and snippets.

@ccamel
Last active February 27, 2025 19:39
Show Gist options
  • Save ccamel/44cbc7d8e42f183dcbc78c85ebf404d0 to your computer and use it in GitHub Desktop.
Save ccamel/44cbc7d8e42f183dcbc78c85ebf404d0 to your computer and use it in GitHub Desktop.
A collection of handy one-liners leveraging the Axoned CLI for interacting with the Axone blockchain

Convert an Address from one HRP to another using Axoned's Logic 'ask' command

This one-liner converts an address from one HRP to another using Axoned's logic ask command.

(
  # Define the input address and target HRP
  addr='axone17sc02mcgjzdv5l4jwnzffxw7g60y5ta4zwy04g'
  to_hrp='stars'

  # Convert the address using the Axoned logic 'ask' command
  axoned query logic ask \
    --node "https://api.dentrite.axone.xyz:443/rpc" \
    --program "
      convert_addr(FROM_BECH32, TO_HRP, TO_BECH32) :-
        bech32_address(-(_, FROM_BYTES), FROM_BECH32),
        bech32_address(-(TO_HRP, FROM_BYTES), TO_BECH32).
    " \
    "convert_addr('$addr', '$to_hrp', S)." \
    -ojson | jq -r '.answer.results[0].substitutions[0].expression'
)
stars17sc02mcgjzdv5l4jwnzffxw7g60y5ta445l92y

Prerequisites:

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment