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 terra.py
You must have installed terra.py v2.0.1 or higher
from terra_sdk.client.lcd import LCDClient
def decode(encoded_tx):
terra = LCDClient("https://lcd.terra.dev", "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.
POST https://lcd.terra.dev/txs/decode
{
"tx": "ENCODED TX HERE"
}
From BASH
You can also decode it from any linux terminal using base64
and protoc
.
echo "ENCODED TX HERE" | base64 -D | protoc --decode_raw