Skip to content

Instantly share code, notes, and snippets.

@ilap
Last active December 15, 2019 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ilap/60597d28730b96c852d7ec40625d91c7 to your computer and use it in GitHub Desktop.
Save ilap/60597d28730b96c852d7ec40625d91c7 to your computer and use it in GitHub Desktop.
Byron's Yoroi address migration to Shelley v3 address.
#!/bin/bash
# Get the spending key of your Yoroi address for signing the spending.
# At repl.it/repls/IndolentWarmheartedDehardwarization
# FORK IT FIRST!!!!!!!!!!!
# And replace the
# MNEMONICS="your mnemonics" with yours and then
# from `console.log(address.to_base58());``
# to `console.log(key_prv.to_hex());`
KEY=""
# Apply the Yoroi address of the key in to get the relevant genesis' tx hash
# https://shelleyexplorer.cardano.org/address/<Your yoroi address>
TXHASH=""
# Index of your address in the shelleyexplorer's result.
# Index starts from 0, so my one was 17th so the index is 16.
IDX=16
# Amount in lovelaces
AMOUNT=10000000000
# Your Rest API URL.
URL=""
# Block9 hash
BLOCK0_HASH="8e4d2a343f3dcf9330ad9035b3e8d168e6728904262f2c434a4f8f934ec7b676"
# Destination address
DEST_ADDR=""
i=0
##
NUM_INPUTS=1
NUM_OUTPUTS=1
MULTIPLIER=$(( $NUM_INPUTS + $NUM_OUTPUTS ))
COEFF=100000
CONST=200000
FEE=$(( $CONST + $MULTIPLIER * $COEFF))
OUT_AMOUNT=$(( $AMOUNT - $FEE ))
# The key is an Ed25519Bip32 so we jsut need its first 64 byte to convert it to the Ed25519Extended.
# echo ${KEY} | sed -e 's/^\(.\{128\}\).*/\1/' > bytes${i}
# Nope, Seb mentioned that we need to use legacy-utxo, so Ed25519Bip32 is the go
echo ${KEY} > bytes${i}
jcli key from-bytes --type Ed25519Bip32 bytes${i} addr_key${i}.prv
jcli key to-public --input addr_key${i}.prv addr_key${i}.pub
jcli transaction new --staging tx${i}
jcli transaction add-input "${TXHASH}" "${IDX}" "${AMOUNT}" --staging "tx${i}"
jcli transaction add-output "${DEST_ADDR}" "${OUT_AMOUNT}" --staging "tx${i}"
jcli transaction finalize --staging tx${i}
TX_ID=$(jcli transaction data-for-witness --staging tx${i} )
jcli transaction make-witness ${TX_ID} \
--genesis-block-hash ${BLOCK0_HASH} \
--type "legacy-utxo" \
witness.out addr_key${i}.prv
jcli transaction add-witness witness.out --staging "tx${i}"
jcli transaction seal --staging "tx${i}"
jcli transaction info --fee-constant ${CONST} --fee-coefficient ${COEFF} --staging tx${i}
jcli transaction to-message --staging "tx${i}" > message${i}
echo "Doit buddy!"
echo "jcli rest v0 message post -f message${i} -h http://${URL}/api"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment