Decode amino-encoded txs

Decode amino-encoded txs

This is a guide to the various methods for decoding an amino-encoded (protobuf) transaction.

With JavaScript

To decode it from Javascript you can use @terra-money/terra.js

import { Tx } from '@terra-money/terra.js';

function decode(encodedTx){
    return Tx.unpackAny({ value: Buffer.from(encodedTx, 'base64') })

With Python

To decode it in python you can use

You must have installed v2.0.1 or higher

from terra_sdk.client.lcd import LCDClient

def decode(encoded_tx):
    terra = LCDClient("", "columbus-5")
    decoded = terra.tx.decode(encoded_tx)
    return decoded

Using the LCD

This method is the slowest as it makes an http request to the LCD, but it doesn’t require any library and therefore it be used in any language.

    "tx": "ENCODED TX HERE"


You can also decode it from any linux terminal using base64 and protoc.

echo "ENCODED TX HERE" | base64 -D | protoc --decode_raw