Skip to content

Latest commit

 

History

History
69 lines (54 loc) · 2.62 KB

COIN_ID.md

File metadata and controls

69 lines (54 loc) · 2.62 KB

coin id

Coin ID/CoinName (TXO ID/transaction output ID) - The ID of a coin in Chia is generated by hashing the primary input ID, puzzle hash, and amount concatenated in that order.

Example

  • coin_id: 0xd47c35dff3bd1f7473146b064b473a2888eff23bd4bfac19a9ea009a742e5e2b
  • parent_coin_info: 0x12c0709babe92736387cd4ab8b4082af3aab33422fcc9cd1092ba6f6f6b01b66,
  • puzzle_hash: 0xb92a9d42c0f3e3612e98e1ae7b030ed425e076eda6238c7df3c481bf13de3bfd
  • amount: 299 (0x012b)

Chia-Dev-Tools

# 0x12c0709babe92736387cd4ab8b4082af3aab33422fcc9cd1092ba6f6f6b01b66
# 0xb92a9d42c0f3e3612e98e1ae7b030ed425e076eda6238c7df3c481bf13de3bfd
# 0x012b (299)
❯ cdv hash 0x12c0709babe92736387cd4ab8b4082af3aab33422fcc9cd1092ba6f6f6b01b66b92a9d42c0f3e3612e98e1ae7b030ed425e076eda6238c7df3c481bf13de3bfd012b
d47c35dff3bd1f7473146b064b473a2888eff23bd4bfac19a9ea009a742e5e2b

Chialisp

(sha256 parent_id puzzlehash amount)
❯ brun '(sha256 (q . 0x12c0709babe92736387cd4ab8b4082af3aab33422fcc9cd1092ba6f6f6b01b66) (q . 0xb92a9d42c0f3e3612e98e1ae7b030ed425e076eda6238c7df3c481bf13de3bfd) (q . 299))'

0xd47c35dff3bd1f7473146b064b473a2888eff23bd4bfac19a9ea009a742e5e2b

❯ run '(sha256 "0x12c0709babe92736387cd4ab8b4082af3aab33422fcc9cd1092ba6f6f6b01b66" "0xb92a9d42c0f3e3612e98e1ae7b030ed425e076eda6238c7df3c481bf13de3bfd" 299)'

0xd47c35dff3bd1f7473146b064b473a2888eff23bd4bfac19a9ea009a742e5e2b

Python

from chia.types.blockchain_format.sized_bytes import bytes32
from chia.util.hash import std_hash
from clvm.casts import int_to_bytes

std_hash(
    bytes32.fromhex("12c0709babe92736387cd4ab8b4082af3aab33422fcc9cd1092ba6f6f6b01b66") +
    bytes32.fromhex("b92a9d42c0f3e3612e98e1ae7b030ed425e076eda6238c7df3c481bf13de3bfd") +
    int_to_bytes(299)
)
❯ python3 -i

Python 3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from chia.types.blockchain_format.sized_bytes import bytes32
>>> from chia.util.hash import std_hash
>>> from clvm.casts import int_to_bytes
>>> std_hash(
...     bytes32.fromhex("12c0709babe92736387cd4ab8b4082af3aab33422fcc9cd1092ba6f6f6b01b66") +
...     bytes32.fromhex("b92a9d42c0f3e3612e98e1ae7b030ed425e076eda6238c7df3c481bf13de3bfd") +
...     int_to_bytes(299)
... )
<bytes32: d47c35dff3bd1f7473146b064b473a2888eff23bd4bfac19a9ea009a742e5e2b>