Closed yukairex closed 5 years ago
Hello,
The tx is base64 encoded, you can decode them and get the amino encoded transactions, like
info is: e301f0625dee0a68ce6dc0430a147e368542f164aab69bb31c4367600b46fb014914122e374533363835343246313634414142363942423331433433363736303042343646423031343931342d31383534381a0b5048422d3244465f424e4220022801309bac0538808093e8b515400112710a26eb5ae98721020ef973443f3a22c45cafe5b50381bc1e0f97be1234851b05fffc60091590fa5b124071682309a069c50bf65322d8e986785a57f1d7919e7fcb660e6bc055184e2225480b8daccf27abf690cdd15fbe6ed83fac2f89930abf3bd7a7384f9f346945df18ad6020f390012003
As explained in https://docs.binance.org/api-reference/transactions.html#amino-types
the first 4 bytes is used to represent length of message, the next 8 bytes are to represent the types of transaction. in this case is f0625dee
. It's a auth/StdTx
. Then you can decode the messages within a transaction.
https://github.com/binance-chain/javascript-sdk/blob/master/__tests__/decoder.test.js
Then you use the type info to decode the transaction with decoder.unMarshalBinaryLengthPrefixed(bytes, result)
@huangsuyu Hello, I'm having the same questions as yukairex, but I didn't understand how to work with the transaction once I know that it's type is "auth/StdTx". I tried making a Class for StdTx like this:
class Msg {
constructor(opts) {
opts = opts || {}
this.string = opts.address || ''
this.buf = opts.buf || Buffer.alloc(0)
this.price = opts.price || 0
this.bool = opts.timeinforce || false
this.quantity = opts.quantity || 0
this.msgType = 'StdTx'
}
}
const result = new Msg()
const transaction = JSON.stringify(
BnbApiClient.amino.unMarshalBinaryLengthPrefixed(Buffer.from(block.block.data.txs[0], 'base64'),
result)
)
console.log(transaction)
That console.log in the end outputs:
{
"string":"*,��\n#\n\u00143��P7�`����A��c�+���\u0012\u000b\n\u0007GTO-FC1\u0010\u0001\u0012#\n\u0014�vk�&>�\u0016�\rq�DTv���<�\u0012\u000b\n\u0007GTO-FC1\u0010\u0001",
"buf":{
"type": "Buffer",
"data":[]
},
"price":0,
"bool":false,
"quantity":0,
"msgType":"StdTx",
"msg":""
}
How do I know what parameters can I take from an StdTx type, and how do I get the decoded address from that string attribute?
Thanks
@joadr Hi, I have this weird outputs too, is there any solution now?
@wangboguo check this out: https://old-community.binance.org/t/bnb-api-integration/3020
@joadr Hey, care to share your solution? :)
any solution . i am still struggling to decode this hash of transaction.
Can you guys share the test cases here? I'm having the same question and find out a little trick to work with NewOrderMsg
transactions, but I still cannot successfully decode a normal StdTx
transaction.
My testing data:
let orderRaw = Buffer.from("db01f0625dee0a65ce6dc0430a14b6561dcc104130059a7c08f48c64610c1f6f9064122b423635363144434331303431333030353941374330384634384336343631304331463646393036342d31311a0b4254432d3543345f424e42200228013080c2d72f3880989abc044001126e0a26eb5ae9872103baf53d1424f8ea83d03a82f6d157b5401c4ea57ffb8317872e15a19fc9b7ad7b1240e79a6606d28cf07b9cc6f566b524a5282b13beccc3162376c79f392620c95a447b19f64e761e22a7a3bc311a780e7d9fdd521e2f7edec25308c5bac6aa1c0a311801200a","hex")
let OrderType = {
msg: [{
sender: Buffer.from([]),
id: "",
symbol: "",
ordertype: 0,
side: 0,
price: 0,
quantity: 0,
timeinforce: 0,
msgType: "NewOrderMsg"
}],
signatures: [{
pub_key: Buffer.from([]),
signature: Buffer.from([]),
account_number: 0,
sequence: 0
}],
memo: "",
msgType: "StdTx"
}
let encodedOrder = decoder.unMarshalBinaryLengthPrefixed(orderRaw, OrderType)
console.log(JSON.stringify(encodedOrder))
I won't work with the decoder:
encountered fieldNum: 2, but we have already seen fnum: 8
130 |
131 | if(fieldNum <= lastFieldNum) {
> 132 | throw new Error(`encountered fieldNum: ${fieldNum}, but we have already seen fnum: ${lastFieldNum}`)
| ^
133 | }
134 |
135 | lastFieldNum = fieldNum
It looks like the msgType
keys caused the problem, so I have to edit the the decodeObjectBinary
function in file src/decoder/index.js as follow to temporarily resolve this.
if (key === "msgType") return
// src/decoder/index.js
keys.forEach((key, index) => {
if (key === "msgType") return
if (is.array(type[key])) {
const { offset, val } = decodeArrayBinary(bytes, type[key][0])
objectOffset += offset
type[key] = val
bytes = bytes.slice(offset)
} else {...}
I'm not sure this is the correct way to fix it, at least it works for now. I'm still trying to make the standard transfer work. I'll update here once I figured it out.
"msgType": "someType"
on your own in the type definitions.@achevmd @blockmonk I have found some more that may be a solution to your problems
I realized a big problem in the current decoder is its ability to decode arrays correctly, more specifically, it is the function decodeArrayBinary
to blame.
The current decodeArrayBinary uses a while loop to iterate through an array. Sometimes the iteration just goes on beyond expected and convert more bytes into a specific object. In my case, the MsgSend
example (down below) generate 2 coin
object, while the input was only one.
** The testing data came from the original fixtures
folder, I changed it a little bit and use it in my updated test as follow.
import TRANSFER from "./fixtures/transfer.js"
let stdTx = TRANSFER.stdTx
let encodedTx = encoder.marshalBinary(stdTx)
expect(encodedTx).toBe(TRANSFER.stdTxBytes)
let stdType = {
msg:[
{
"inputs":[
{
"address":Buffer.from([]),
"coins":[
{
"denom":"d",
"amount":0
}
]
}
],
"outputs":[
{
"address":Buffer.from([]),
"coins":[
{
"denom":"",
"amount":0
}
]
}
],
"msgType":"MsgSend"
}],
"signatures":[{
"pub_key":Buffer.from([]),
"signature":Buffer.from([]),
"account_number":0,
"sequence":0
}
],
"memo":"",
"source":0,
"data":"",
"msgType":"StdTx"
}
let {val: decodedTx} = decoder.unMarshalBinaryLengthPrefixed(Buffer.from(encodedTx,"hex"), stdType)
So if you stick to the original decoder, it won't work. Hence, I took a look at another animo js repository: https://github.com/cybercongress/js-amino/blob/master/src/binaryDecoder.js and find out they're actually implementing array decoding with Length Specified. So instead of a while loop, they use a for loop, and put the length of array in type object as the target length of decoding data.
const decodeBinaryArray = (bz, arrayType, instance, opts, isBare = true, idx = 0) => {
let totalLength = 0;
let items = []
if (!isBare) { // Read byte-length prefixed byteslice.
let prefixSlice = Decoder.decodeUVarint(bz)
bz = bz.slice(prefixSlice.byteLength)
if (bz.length < prefixSlice.data) throw new RangeError("Wrong length prefix for Binary Array")
totalLength += prefixSlice.byteLength;
}
let itemType = arrayType == Types.ArrayInterface ? Types.Interface : Types.Struct
for (let i = 0; i < instance.length; ++i) {
let decodedFieldtype = Decoder.decodeFieldNumberAndType(bz)
bz = bz.slice(decodedFieldtype.byteLength) //remove byte field
let decodedData = decodeBinary(bz, instance[i], itemType, opts, false)
bz = bz.slice(decodedData.byteLength);
items.push(decodedData.data)
totalLength += decodedFieldtype.byteLength;
totalLength += decodedData.byteLength;
}
return {
data: items,
byteLength: totalLength //+ instance.length
}
}
So I follow their this code to modify the decodeArrayBinary function and temporarily add an extra param len to easily pass in what I want.
const decodeArrayBinary = (bytes, type, len) => {
const arr = []
let arrayOffset = 0
let { fieldNum: fieldNumber } = decodeFieldNumberAndTyp3(bytes)
for(let i=0; i<len; i++){
const { fieldNum, offset: fieldNumLen } = decodeFieldNumberAndTyp3(bytes)
if(fieldNum !== fieldNumber || fieldNum < 0) break
//remove 1 byte of encoded field number and type
bytes = bytes.slice(fieldNumLen)
//is default value, skip and continue read bytes
if(bytes.length > 0 && bytes[0] === 0x00) continue
const { offset, val } = decodeBinary(bytes, type, true)
arr.push({...val})
bytes = bytes.slice(offset)
//add 1 byte of type
arrayOffset += offset + fieldNumLen
fieldNumber = fieldNum
}
// console.log(arr)
return { val: arr, offset: arrayOffset }
}
And It works now!
To use this implementation, you have to specify "msgType"
on your own in the type definition.
You have to pass in a more precise type object, for example, if your inputs
contain two objects, you have to specify your type as:
"inputs":[
{
"address":Buffer.from([]),
"coins":[
{
"denom":"d",
"amount":0
}
]
},
{
"address":Buffer.from([]),
"coins":[
{
"denom":"d",
"amount":0
}
]
}
I also modify the decodeFieldNumberAndTyp3 so it will return offset
as well, save me from hardcoding slice(1)
in my decoder.
I'm not sure if this is correct, let me know if I'm misunderstanding any of this.
i am unable to decode txns data in /block?height= [RPC] can someone help me with amino-encoded data for sendTx
help me decode amino-encoded tx data for nodejs
Can someone tell whats wrong with this code ?
let txn = "xgHwYl3uCkwqLIf6CiIKFJGTdSD0BFj1tBTSZ5YbRsGXid1wEgoKA0JOQhDA0eEjEiIKFEYLfJ9Eg666OgnnNNBoO+8TYkdaEgoKA0JOQhDA0eEjEnAKJuta6YchA1bgpYA4mm/SzJHNUlxtWk2AVK9w3xdITlhnj59XSgtNEkBiVAL8/DmusweaMjwhhC4FKIedREnOsvbSxJjLXp0Ti2MI8K03X0tuFxpBlQSoHoW4CkIs+sJnPsSuT0HzAVVLGDMg6u8EIAI=";
let txnDt = Buffer.from(txn, "base64");
class Token {
constructor(opts) {
opts = opts || {}
this.denom = opts.denom || ""
this.amount = opts.amount || 0
}
}
class Input {
constructor(opts) {
opts = opts || {}
this.address = opts.address || Buffer.alloc(0)
this.coins = opts.coins || [new Token()]
}
}
class Output {
constructor(opts) {
opts = opts || {}
this.address = opts.address || Buffer.alloc(0)
this.coins = opts.coins || [new Token()]
}
}
class MsgSend {
constructor(opts) {
opts = opts || {}
this.inputs = opts.inputs || new Input()
this.outputs = opts.outputs || new Output()
this.msgType = "MsgSend"
}
}
class StdSignature {
constructor(opts) {
opts = opts || {}
this.pub_key = opts.pub_key || Buffer.from([])
this.signature = opts.signature || Buffer.from([])
this.account_number = opts.account_number || 0
this.sequence = opts.sequence || 0
}
}
class stdTx {
constructor(opts) {
opts = opts || {}
this.msgs = opts.msgs || [new MsgSend()]
this.signatures = opts.signatures || new StdSignature()
this.memo = opts.memo || ""
this.source = opts.source || 0
this.data = opts.data || Buffer.alloc(0)
this.msgType = "stdTx"
}
}
const result = new stdTx()
const json_transaction = JSON.stringify(
BnbApiClient.amino.unMarshalBinaryBare(txnDt, result)
)
@mattabc9756 I successfully decode your message with the updated decode function I provided above.
The result look like this:
{
"msgs":[
{
"inputs":{
"address":{
"type":"Buffer",
"data":[145, 147,117,32,244,4,88,245,180,20,210,103,150,27,70,193,151,137,221,112]
},
"coins":[
{
"denom":"BNB",
"amount":75000000
}
]
},
"outputs":{
"address":{
"type":"Buffer",
"data":[70,11,124,159,68,131,174,186,58,9,231,52,208,104,59,239,19,98,71,90]
},
"coins":[
{
"denom":"BNB",
"amount":75000000
}
]
},
"msgType":"MsgSend"
}
],
"signatures":{
"pub_key":{
"type":"Buffer",
"data":[235,90,233,135,33,3,86,224,165,128,56,154,111,210,204,145,205,82,92,109,90,77,128,84,175,112,223,23,72,78,88,103,143,159,87,74,11,77]
},
"signature":{
"type":"Buffer",
"data":[98,84,2,252,252,57,174,179,7,154,50,60,33,132,46,5,40,135,157,68,73,206,178,246,210,196,152,203,94,157,19,139,99,8,240,173,55,95,75,110,23,26,65,149,4,168,30,133,184,10,66,44,250,194,103,62,196,174,79,65,243,1,85,75]
},
"account_number":51,
"sequence":79850
},
"memo":"",
"source":2,
"data":{
"type":"Buffer",
"data":[
]
},
"msgType":"stdTx"
}
You can take a look at my new decoder file at https://github.com/antoncoding/javascript-sdk/ Or you can try another library I recently built to decode BNB transactions for now: https://github.com/antoncoding/raw-transaction-hex-decoder I updated your code in the test cases here. So it should be working fine.
@mattabc9756 I successfully decode your message with the updated decode function I provided above.
The result look like this:
{ "msgs":[ { "inputs":{ "address":{ "type":"Buffer", "data":[145, 147,117,32,244,4,88,245,180,20,210,103,150,27,70,193,151,137,221,112] }, "coins":[ { "denom":"BNB", "amount":75000000 } ] }, "outputs":{ "address":{ "type":"Buffer", "data":[70,11,124,159,68,131,174,186,58,9,231,52,208,104,59,239,19,98,71,90] }, "coins":[ { "denom":"BNB", "amount":75000000 } ] }, "msgType":"MsgSend" } ], "signatures":{ "pub_key":{ "type":"Buffer", "data":[235,90,233,135,33,3,86,224,165,128,56,154,111,210,204,145,205,82,92,109,90,77,128,84,175,112,223,23,72,78,88,103,143,159,87,74,11,77] }, "signature":{ "type":"Buffer", "data":[98,84,2,252,252,57,174,179,7,154,50,60,33,132,46,5,40,135,157,68,73,206,178,246,210,196,152,203,94,157,19,139,99,8,240,173,55,95,75,110,23,26,65,149,4,168,30,133,184,10,66,44,250,194,103,62,196,174,79,65,243,1,85,75] }, "account_number":51, "sequence":79850 }, "memo":"", "source":2, "data":{ "type":"Buffer", "data":[ ] }, "msgType":"stdTx" }
You can take a look at my new decoder file at https://github.com/antoncoding/javascript-sdk/ Or you can try another library I recently built to decode BNB transactions for now: https://github.com/antoncoding/raw-transaction-hex-decoder I updated your code in the test cases here. So it should be working fine.
Thank you for all the help you've been giving here. It looks like the address in inputs/outputs aren't correct. Do you have a solution for this?
I have forked minimized the antoncoding
package above to get a decoder only for Binance chain.
const decoder = require('bnb-tx-decoder');
const tx = "..."; // Your transaction base64
// No need to provide the transaction type. It is automatically discovered
const decodedTx = decoder.decodeBnbRawTx(tx);
// decoded Tx has the JSON object
Hey @antoncoding @naiemk, this is awesome work. Do you think we could look at merging the new decoder into the sdk via pull request?
https://github.com/binance-chain/javascript-sdk/issues/168#issuecomment-521614970
Tried
getTradingPairs(0,100)
,listAllTokens(0,100)
, they return array with just 1 element, same >with parameters(1,1)
,(0,1)
,(0,10)
,(1,2)
. Output is changing depending onoffset
I suspect its
decodeArrayBinary
, which has new paramlen
on that fork, which is set totype.length
inunMarshalBinaryBare
https://github.com/binance-chain/javascript-sdk/pull/198. Check this pr. fixed
I have forked minimized the
antoncoding
package above to get a decoder only for Binance chain.const decoder = require('bnb-tx-decoder'); const tx = "..."; // Your transaction base64 // No need to provide the transaction type. It is automatically discovered const decodedTx = decoder.decodeBnbRawTx(tx); // decoded Tx has the JSON object
I tried doing this with the transaction returned in tx: [] of https://seed-pre-s3.binance.org/block?height=42502806 API: `const decoder = require('bnb-tx-decoder');
const decodedTx = decoder.decodeBnbRawTx('7AHwYl3uCnQqLIf6CiQKFIn4Vss50lwb3arsdKOBV3yo4viGEgwKA0JOQhCAoL6BlQESIwoUPyuxIZV8eGZeiqld8RuZzLtz56gSCwoDQk5CEICQ38BKEiMKFMEjmlKgvc/lzW80ymK3/4GD9UJFEgsKA0JOQhCAkN/AShJwCibrWumHIQOKveXhJ+HEdW28VUamHPKWy7ymMmjMY82k0ppEyUFK+hJAI5U2XBGM2hh1Lv96o6sEhCwwlx+s9Eu7+CFbzrFzAwIpKg9Rzw7kslmisgSk4Unr/XB5acnqOTNOaf1LWOPiHxgOIOH0Ag=='); console.log(decodedTx);`
But it just returned:
ACTUAL MSG TYPE
{ msg: [],
signatures: [],
memo: '',
source: 0,
data: '',
msgType: 'StdTx' }
I don't understand how to get the full-blown version like this: `{
"msgs":[
{
"inputs":{
"address":{
"type":"Buffer", "data":[145, 147,117,32,244,4,88,245,180,20,210,103,150,27,70,193,151,137,221,112] }, "coins":[
{
"denom":"BNB", "amount":75000000 } ] }, "outputs":{
"address":{
"type":"Buffer", "data":[70,11,124,159,68,131,174,186,58,9,231,52,208,104,59,239,19,98,71,90] }, "coins":[
{
"denom":"BNB", "amount":75000000 } ] }, "msgType":"MsgSend" } ], "signatures":{
"pub_key":{
"type":"Buffer", "data":[235,90,233,135,33,3,86,224,165,128,56,154,111,210,204,145,205,82,92,109,90,77,128,84,175,112,223,23,72,78,88,103,143,159,87,74,11,77] }, "signature":{
"type":"Buffer", "data":[98,84,2,252,252,57,174,179,7,154,50,60,33,132,46,5,40,135,157,68,73,206,178,246,210,196,152,203,94,157,19,139,99,8,240,173,55,95,75,110,23,26,65,149,4,168,30,133,184,10,66,44,250,194,103,62,196,174,79,65,243,1,85,75] }, "account_number":51, "sequence":79850 }, "memo":"", "source":2, "data":{
"type":"Buffer", "data":[ ] }, "msgType":"stdTx" }
Also, many were discussing about putting in base64 transaction, so am I not passing the base64 transaction? If not then how do I convert
7AHwYl3uCnQqLIf6CiQKFIn4Vss50lwb3arsdKOBV3yo4viGEgwKA0JOQhCAoL6BlQESIwoUPyuxIZV8eGZeiqld8RuZzLtz56gSCwoDQk5CEICQ38BKEiMKFMEjmlKgvc/lzW80ymK3/4GD9UJFEgsKA0JOQhCAkN/AShJwCibrWumHIQOKveXhJ+HEdW28VUamHPKWy7ymMmjMY82k0ppEyUFK+hJAI5U2XBGM2hh1Lv96o6sEhCwwlx+s9Eu7+CFbzrFzAwIpKg9Rzw7kslmisgSk4Unr/XB5acnqOTNOaf1LWOPiHxgOIOH0Ag==
to base64, I tried using Buffer.from(string, 'base64') but it didn't work. Please help me on this I have been stuck and getting a hard time in decoding this huge transaction hex.
I have forked minimized the
antoncoding
package above to get a decoder only for Binance chain.const decoder = require('bnb-tx-decoder'); const tx = "..."; // Your transaction base64 // No need to provide the transaction type. It is automatically discovered const decodedTx = decoder.decodeBnbRawTx(tx); // decoded Tx has the JSON object
I tried doing this with the transaction returned in tx: [] of https://seed-pre-s3.binance.org/block?height=42502806 API: `const decoder = require('bnb-tx-decoder');
const decodedTx = decoder.decodeBnbRawTx('7AHwYl3uCnQqLIf6CiQKFIn4Vss50lwb3arsdKOBV3yo4viGEgwKA0JOQhCAoL6BlQESIwoUPyuxIZV8eGZeiqld8RuZzLtz56gSCwoDQk5CEICQ38BKEiMKFMEjmlKgvc/lzW80ymK3/4GD9UJFEgsKA0JOQhCAkN/AShJwCibrWumHIQOKveXhJ+HEdW28VUamHPKWy7ymMmjMY82k0ppEyUFK+hJAI5U2XBGM2hh1Lv96o6sEhCwwlx+s9Eu7+CFbzrFzAwIpKg9Rzw7kslmisgSk4Unr/XB5acnqOTNOaf1LWOPiHxgOIOH0Ag=='); console.log(decodedTx);`
But it just returned:
ACTUAL MSG TYPE { msg: [], signatures: [], memo: '', source: 0, data: '', msgType: 'StdTx' }
I don't understand how to get the full-blown version like this: `{ "msgs":[ { "inputs":{ "address":{ "type":"Buffer", "data":[145, 147,117,32,244,4,88,245,180,20,210,103,150,27,70,193,151,137,221,112] }, "coins":[ { "denom":"BNB", "amount":75000000 } ] }, "outputs":{ "address":{ "type":"Buffer", "data":[70,11,124,159,68,131,174,186,58,9,231,52,208,104,59,239,19,98,71,90] }, "coins":[ { "denom":"BNB", "amount":75000000 } ] }, "msgType":"MsgSend" } ], "signatures":{ "pub_key":{ "type":"Buffer", "data":[235,90,233,135,33,3,86,224,165,128,56,154,111,210,204,145,205,82,92,109,90,77,128,84,175,112,223,23,72,78,88,103,143,159,87,74,11,77] }, "signature":{ "type":"Buffer", "data":[98,84,2,252,252,57,174,179,7,154,50,60,33,132,46,5,40,135,157,68,73,206,178,246,210,196,152,203,94,157,19,139,99,8,240,173,55,95,75,110,23,26,65,149,4,168,30,133,184,10,66,44,250,194,103,62,196,174,79,65,243,1,85,75] }, "account_number":51, "sequence":79850 }, "memo":"", "source":2, "data":{ "type":"Buffer", "data":[ ] }, "msgType":"stdTx" }
Also, many were discussing about putting in base64 transaction, so am I not passing the base64 transaction? If not then how do I convert
7AHwYl3uCnQqLIf6CiQKFIn4Vss50lwb3arsdKOBV3yo4viGEgwKA0JOQhCAoL6BlQESIwoUPyuxIZV8eGZeiqld8RuZzLtz56gSCwoDQk5CEICQ38BKEiMKFMEjmlKgvc/lzW80ymK3/4GD9UJFEgsKA0JOQhCAkN/AShJwCibrWumHIQOKveXhJ+HEdW28VUamHPKWy7ymMmjMY82k0ppEyUFK+hJAI5U2XBGM2hh1Lv96o6sEhCwwlx+s9Eu7+CFbzrFzAwIpKg9Rzw7kslmisgSk4Unr/XB5acnqOTNOaf1LWOPiHxgOIOH0Ag==
to base64, I tried using Buffer.from(string, 'base64') but it didn't work. Please help me on this I have been stuck and getting a hard time in decoding this huge transaction hex.
Did you use this fork? https://github.com/ferrumnet/bnb-tx-decoder
What happens when you replace the TX base64 in this test? https://github.com/ferrumnet/bnb-tx-decoder/blob/master/__tests__/decoder_bnb.js#L13
FYI, that is hex encoding used in the test case you linked to, not base64.
From: Naiem Yeganeh notifications@github.com Sent: Saturday, October 5, 2019 5:34 am To: binance-chain/javascript-sdk Cc: Luke Plaster; Comment Subject: Re: [binance-chain/javascript-sdk] bnb transaction decode (#138)
I have forked minimized the antoncoding package above to get a decoder only for Binance chain.
const decoder = require('bnb-tx-decoder');
const tx = "..."; // Your transaction base64
// No need to provide the transaction type. It is automatically discovered const decodedTx = decoder.decodeBnbRawTx(tx);
// decoded Tx has the JSON object
I tried doing this with the transaction returned in tx: [] of https://seed-pre-s3.binance.org/block?height=42502806 API: `const decoder = require('bnb-tx-decoder');
const decodedTx = decoder.decodeBnbRawTx('7AHwYl3uCnQqLIf6CiQKFIn4Vss50lwb3arsdKOBV3yo4viGEgwKA0JOQhCAoL6BlQESIwoUPyuxIZV8eGZeiqld8RuZzLtz56gSCwoDQk5CEICQ38BKEiMKFMEjmlKgvc/lzW80ymK3/4GD9UJFEgsKA0JOQhCAkN/AShJwCibrWumHIQOKveXhJ+HEdW28VUamHPKWy7ymMmjMY82k0ppEyUFK+hJAI5U2XBGM2hh1Lv96o6sEhCwwlx+s9Eu7+CFbzrFzAwIpKg9Rzw7kslmisgSk4Unr/XB5acnqOTNOaf1LWOPiHxgOIOH0Ag=='); console.log(decodedTx);`
But it just returned:
ACTUAL MSG TYPE { msg: [], signatures: [], memo: '', source: 0, data: '', msgType: 'StdTx' }
I don't understand how to get the full-blown version like this: `{ "msgs":[ { "inputs":{ "address":{ "type":"Buffer", "data":[145, 147,117,32,244,4,88,245,180,20,210,103,150,27,70,193,151,137,221,112] }, "coins":[ { "denom":"BNB", "amount":75000000 } ] }, "outputs":{ "address":{ "type":"Buffer", "data":[70,11,124,159,68,131,174,186,58,9,231,52,208,104,59,239,19,98,71,90] }, "coins":[ { "denom":"BNB", "amount":75000000 } ] }, "msgType":"MsgSend" } ], "signatures":{ "pub_key":{ "type":"Buffer", "data":[235,90,233,135,33,3,86,224,165,128,56,154,111,210,204,145,205,82,92,109,90,77,128,84,175,112,223,23,72,78,88,103,143,159,87,74,11,77] }, "signature":{ "type":"Buffer", "data":[98,84,2,252,252,57,174,179,7,154,50,60,33,132,46,5,40,135,157,68,73,206,178,246,210,196,152,203,94,157,19,139,99,8,240,173,55,95,75,110,23,26,65,149,4,168,30,133,184,10,66,44,250,194,103,62,196,174,79,65,243,1,85,75] }, "account_number":51, "sequence":79850 }, "memo":"", "source":2, "data":{ "type":"Buffer", "data":[ ] }, "msgType":"stdTx" }
Also, many were discussing about putting in base64 transaction, so am I not passing the base64 transaction? If not then how do I convert
7AHwYl3uCnQqLIf6CiQKFIn4Vss50lwb3arsdKOBV3yo4viGEgwKA0JOQhCAoL6BlQESIwoUPyuxIZV8eGZeiqld8RuZzLtz56gSCwoDQk5CEICQ38BKEiMKFMEjmlKgvc/lzW80ymK3/4GD9UJFEgsKA0JOQhCAkN/AShJwCibrWumHIQOKveXhJ+HEdW28VUamHPKWy7ymMmjMY82k0ppEyUFK+hJAI5U2XBGM2hh1Lv96o6sEhCwwlx+s9Eu7+CFbzrFzAwIpKg9Rzw7kslmisgSk4Unr/XB5acnqOTNOaf1LWOPiHxgOIOH0Ag==
to base64, I tried using Buffer.from(string, 'base64') but it didn't work. Please help me on this I have been stuck and getting a hard time in decoding this huge transaction hex.
Did you use this fork? https://github.com/ferrumnet/bnb-tx-decoder
What happens when you replace the TX base64 in this test? https://github.com/ferrumnet/bnb-tx-decoder/blob/master/__tests__/decoder_bnb.js#L13
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/binance-chain/javascript-sdk/issues/138?email_source=notifications&email_token=AAJST5TD3MBXHWYI7VCDLETQM6ZGJA5CNFSM4HP4SR7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAM6HAQ#issuecomment-538567554, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAJST5TRFURZ6NT2NAGJRF3QM6ZGJANCNFSM4HP4SR7A.
hello,
I tried to use RPC to read each transaction in single block. I used command like
https://seed1.longevito.io/block?height=8737140
What I found in the result is that txs are sort of encoded in some way. for example:
"data": { "txs": [ "4wHwYl3uCmjObcBDChR+NoVC8WSqtpuzHENnYAtG+wFJFBIuN0UzNjg1NDJGMTY0QUFCNjlCQjMxQzQzNjc2MDBCNDZGQjAxNDkxNC0xODU0OBoLUEhCLTJERl9CTkIgAigBMJusBTiAgJPotRVAARJxCibrWumHIQIO+XNEPzoixFyv5bUDgbweD5e+EjSFGwX//GAJFZD6WxJAcWgjCaBpxQv2UyLY6YZ4Wlfx15Gef8tmDmvAVRhOIiVIC42szyer9pDN0V++btg/rC+Jkwq/O9enOE+fNGlF3xitYCDzkAEgAw==", "4wHwYl3uCmjObcBDChTEji7BGx0OHFcQP/JQDSQtYg02XRIuQzQ4RTJFQzExQjFEMEUxQzU3MTAzRkYyNTAwRDI0MkQ2MjBEMzY1RC0xODA3NBoLUEhCLTJERl9CTkIgAigBMLO8BTiA0JCL3xJAARJxCibrWumHIQNUw+T33B4h3E01t9QXuQbcU5YmhaiKdo3us7VAiCNMmBJAxn7WNtJKq5C97m96oFS5NVzuTNsk8Gfuk+e7g7l8prBDEYqrlwq4wUb8WswzpPaiV44mmfCpNnP35y21FBmKPxirYCCZjQEgAw==", "0wHwYl3uCk4qLIf6CiMKFJGTdSD0BFj1tBTSZ5YbRsGXid1wEgsKA0JOQhDgj/WsAxIjChSOpw19LqihS6KzPRjV371vrgpuqBILCgNCTkIQ4I/1rAMScAom61rphyEDVuClgDiab9LMkc1SXG1aTYBUr3DfF0hOWGePn1dKC00SQKstbRg7fwGp4DZbIgJx1NDinXG//SgjbAzXiWmXp5nbGZ5hxUnFReCTqeGyw9AbnHRRT7VW47k+zxF8PDn2cEIYMyD39AEaCTEwNTUyNDAwMCAC" ]
How can I decode this tx info?
Thanks