Como decodificar a transação bruta?
3 respostas
- votos
-
- 2020-05-28
taquitopode analisarbytesforjados usando ométodo
parse()
nopacote@taquito/local-forging
.TypeDocs são aqui . Vocêpode ver ostestes de unidade aqui .
Implementaçãopara decodificar umatransação assinada:
const { localForger } = require('@taquito/local-forging'); const sbytes = '008f1d96e2783258ff663f03dacfe946c026a5d194c73d1987b3da73fadea7d46c008cb5baedee4dc3ec261dfcf57a9600bb0a8e26c0f00bdd85a0018452ac02e0a712000153957451d3cc83a71e26b65ea2391a1b16713d2d009595facf847a72b4c3fe231c0e4185e68e9b2875aa3c639382c86bcf0af23699f47fe66a6550ade936a5b59d5919ad20703885750314e0c368b277de39e7d10a'; async function decode() { const unsignedPart = sbytes.substring(0, sbytes.length - 128); // Removing last 128 characters as that is the signature const decoded = await localForger.parse(unsignedPart); console.log(decoded); } decode();
Taquito can parse forged bytes using the
parse()
method in the@taquito/local-forging
package.TypeDocs are here. You can see the unit tests here.
Implementation to decode a signed transaction:
const { localForger } = require('@taquito/local-forging'); const sbytes = '008f1d96e2783258ff663f03dacfe946c026a5d194c73d1987b3da73fadea7d46c008cb5baedee4dc3ec261dfcf57a9600bb0a8e26c0f00bdd85a0018452ac02e0a712000153957451d3cc83a71e26b65ea2391a1b16713d2d009595facf847a72b4c3fe231c0e4185e68e9b2875aa3c639382c86bcf0af23699f47fe66a6550ade936a5b59d5919ad20703885750314e0c368b277de39e7d10a'; async function decode() { const unsignedPart = sbytes.substring(0, sbytes.length - 128); // Removing last 128 characters as that is the signature const decoded = await localForger.parse(unsignedPart); console.log(decoded); } decode();
-
- 2020-05-28
Vocêpode usar o
tezos-codec
bináriopara decodificaristo:tezos-codec decode 006-PsCARTHA.operation from 008f1d96e2783258ff663f03dacfe946c026a5d194c73d1987b3da73fadea7d46c008cb5baedee4dc3ec261dfcf57a9600bb0a8e26c0f00bdd85a0018452ac02e0a712000153957451d3cc83a71e26b65ea2391a1b16713d2d009595facf847a72b4c3fe231c0e4185e68e9b2875aa3c639382c86bcf0af23699f47fe66a6550ade936a5b59d5919ad20703885750314e0c368b277de39e7d10a
queproduz
{ "branch": "BKiXcfN1ZTXnNNbTWSRArSWzVFc6om7radWq5mTqGX6rY4P2Uhe", "contents": [ { "kind": "transaction", "source": "tz1YU2zoyCkXPKEA4jknSpCpMs7yUndVNe3S", "fee": "1520", "counter": "2622173", "gas_limit": "10500", "storage_limit": "300", "amount": "300000", "destination": "tz2FwBnXhuXvPAUcr1aF3uX84Z6JELxrdYxD" } ], "signature": "sighZMqWz5G8drK1VTsmTnQBFEQ9kxQQxL88NFh8UaqDEJ3R3mzgR3g81azadZ9saPwsWga3kEPsyfbzrXm6ueuDvx3pQ5Q9" }
Vocêpode obtermais detalhes sobre
tezos-codec
em seumanual (tezos-codec man -v 3
)You can use the
tezos-codec
binary to decode this:tezos-codec decode 006-PsCARTHA.operation from 008f1d96e2783258ff663f03dacfe946c026a5d194c73d1987b3da73fadea7d46c008cb5baedee4dc3ec261dfcf57a9600bb0a8e26c0f00bdd85a0018452ac02e0a712000153957451d3cc83a71e26b65ea2391a1b16713d2d009595facf847a72b4c3fe231c0e4185e68e9b2875aa3c639382c86bcf0af23699f47fe66a6550ade936a5b59d5919ad20703885750314e0c368b277de39e7d10a
which yields
{ "branch": "BKiXcfN1ZTXnNNbTWSRArSWzVFc6om7radWq5mTqGX6rY4P2Uhe", "contents": [ { "kind": "transaction", "source": "tz1YU2zoyCkXPKEA4jknSpCpMs7yUndVNe3S", "fee": "1520", "counter": "2622173", "gas_limit": "10500", "storage_limit": "300", "amount": "300000", "destination": "tz2FwBnXhuXvPAUcr1aF3uX84Z6JELxrdYxD" } ], "signature": "sighZMqWz5G8drK1VTsmTnQBFEQ9kxQQxL88NFh8UaqDEJ3R3mzgR3g81azadZ9saPwsWga3kEPsyfbzrXm6ueuDvx3pQ5Q9" }
You can get more details about
tezos-codec
in its manual (tezos-codec man -v 3
)-
Tomassss você salva-vidas.Algumaideia se houver umabiblioteca NPM como Tezos-Codec?TOMASSSS you life saver. Any idea if there's an NPM library like tezos-codec?
- 0
- 2020-05-28
- coder123
-
Nãotenho certeza do que é o seu status,mas vocêpodetentar https://www.npmjs.com/package/@nomadic-labs/tezos-codecI'm not sure what is its status, but you can try https://www.npmjs.com/package/@nomadic-labs/tezos-codec
- 0
- 2020-05-28
- Tomáš Zemanovič
-
- 2020-06-02
Vocêpode usar oendpoint RPC:
/Correntes/Main/Blocks/Head/Ajudantes/Parse/Operações
parafazerisso.Exemplo:
Await Axios.post ( `$ {Nodeurl}/Correntes/Main/Blocks/Head/Ajudantes/Analisar/Operações`, parseoperationbytesdata, { cabeçalhos: { 'Tipo de conteúdo': 'Aplicativo/JSON' } } )
You can use the RPC endpoint:
/chains/main/blocks/head/helpers/parse/operations
to do that.Example:
await axios.post( `${nodeURL}/chains/main/blocks/head/helpers/parse/operations`, parseOperationBytesData, { headers: { 'Content-Type': 'application/json' } } )
Euestou usando @taquitopara construire assinar umatransação. Mas antes deeuenviar,quero decodificarpara verificarmeuendereço de destino,quantidadeetc,como vocênormalmentefariapor outrosblockchains.
Não sei comofazê-lo,maseu assinei uma solicitação usandominha chave de assinatura ED25519. A assinaturafoibem sucedidae os SBYtes que recebiem trocafoi
008f1d96e2783258ff663f03dacfe946c026a5d194c73d1987b3da73fadea7d46c008cb5baedee4dc3ec261dfcf57a9600bb0a8e26c0f00bdd85a0018452ac02e0a712000153957451d3cc83a71e26b65ea2391a1b16713d2d009595facf847a72b4c3fe231c0e4185e68e9b2875aa3c639382c86bcf0af23699f47fe66a6550ade936a5b59d5919ad20703885750314e0c368b277de39e7d10a
Eujá li através de alguns artigos,masnão conseguiencontrar umamaneiraexata defazerissoe o queeutentei nãoproduziaexatamente o queeu queria,o que significa queeunão sei como decodificar atransação,oumeus SBYtes sãoerrado. Alguémpodeexplicarem comoeu decodificaessatransaçãobruta usando umabiblioteca JavaScript/Typycriptpara obter coisas como
fromddress
toaddress
Montante
Etc. E seminhatransação assinadaestiver correta. Isso éparatestnet.