9
votes
Accepted
Base58 encoding/decoding of addresses in Micheline
Optimized addresses are 22 bytes, which follows the following format:
The first byte is a tag, either 00 for implicit (tz) or 01 for originated (KT)
If the first byte is 00 and we are working with ...
7
votes
Accepted
How to convert bytes to an address
Those 22 bytes are:
2 bytes - encoded prefix (tz1, tz2, tz3, KT1);
20 bytes - depending on the address type:
for tz-addresses it's public key hash;
for KT-addresses it's hash of the origination ...
7
votes
Accepted
How to decode raw transaction?
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:
...
7
votes
How to decode raw transaction?
You can use the tezos-codec binary to decode this:
tezos-codec decode 006-PsCARTHA.operation from ...
6
votes
Format of public key, signature and key_hash literals
1) About the ed25519 public key, and how it is in bytes:
From [1]:
Ed25519 keys start life as a 32-byte (256-bit) uniformly random binary seed (e.g. the output of SHA256 on some random input). The ...
6
votes
Accepted
Format of public key, signature and key_hash literals
There are some Python code to do that in this blog and a comment posted by Alain:
http://www.ocamlpro.com/2018/11/21/an-introduction-to-tezos-rpcs-signing-operations/
5
votes
Accepted
How do I base58 encode the chain ID using Python?
Your magicbyte seems to be wrong. If you take the decimal byte values from the original, convert them to hex, then pad it with a leading zero, you get
>>> struct.unpack('>L', b'\x00\x57\...
4
votes
How do I base58 encode the chain ID using Python?
It looks like you are only actually grabbing 2 bytes of data (4 hex chars). I verified this by decoding the result you got, and it only returning two bytes of data for the given magic byte.
Try ...
4
votes
Contract's address format specification
When your originate a contract, you send an "operation" to the network. This operation is then serialized into byte format and a hash is derived - this is the operation hash for the given operation.
...
4
votes
Accepted
Documentation for Serializing Contract Call Data/Parameters
There is https://tezos.gitlab.io/whitedoc/micheline.html#binary-serialization which mostly tells to run tezos-codec describe alpha.script.expr binary schema for a complete description of the binary ...
3
votes
Accepted
Why does `sp.pack('some string')` prepend `0x05010000002e` before the actual bytes?
0x05 means "this is a packed Michelson value". 0x01 means "this is a string". The remaining 4 bytes represent the length of the string.
A complete description of the binary format ...
3
votes
How to convert bytes to an address
Something to note from the accepted answer is that the KT1 addresses do not have a "public key hash". The hash used there is the blake2b 20 byte digest hash of the operation group hash and ...
3
votes
Base58 encoding/decoding of addresses in Micheline
I believe you should be able to make use of Stephen Andrews eztz library to access various tools from a js environment
I would speculate the function is this one where you use the KT prefix
...
2
votes
How do I base58 encode the chain ID using Python?
First of all, many thanks! You've helped me with solving the block signature mystery :)
You can use pytezos.encoding package:
from pytezos.encoding import base58_encode
def get_chain_id(self):
...
2
votes
Format of public key, signature and key_hash literals
In Michelson, those types accept two different formats of data (as you mention) - optimized and readable. The readable versions are the base58-check encoded strings (edpk*, tz1*, edsig*, KT1* etc).
...
2
votes
How to decode raw transaction?
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`,
...
1
vote
Accepted
How do you convert a string sent to an entrypoint into its byte representation?
I struggled on this for a while but finally reached a solution.
It's a bit hacky, but you just have to remove the 6 bytes that sp.pack prepends onto the bytes you actually want with sp.slice before ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
encoding × 12protocol × 3
smart-contracts × 2
smartpy × 2
javascript × 2
block × 2
bytes × 2
transactions × 1
michelson × 1
wallets × 1
taquito × 1
address × 1
signature × 1
python × 1
base58 × 1
string × 1
offline × 1
internal-transactions × 1