Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save johnshearing/7269a1e3690e1e8fb38d568abf03c2cf to your computer and use it in GitHub Desktop.
Save johnshearing/7269a1e3690e1e8fb38d568abf03c2cf to your computer and use it in GitHub Desktop.
[nix-shell:~/marlowe-cardano]$ marlowe-cli --version
marlowe-cli 0.0.5.0
[nix-shell:~/marlowe-cardano]$ cardano-cli --version
cardano-cli 1.34.1 - linux-x86_64 - ghc-8.10
git rev 0000000000000000000000000000000000000000
[nix-shell:~/marlowe-cardano]$ cardano-wallet version
v2022-01-18 (git revision: 0000000000000000000000000000000000000000)
[nix-shell:~/marlowe-cardano]$ cat mywalletA.seed
vacant end token science hobby salute cancel flame aim marine stuff sweet nation nation donate elbow invite crash cry quarter main faculty ecology frame
[nix-shell:~/marlowe-cardano]$
[nix-shell:~/marlowe-cardano]$ cat mywalletA.seed | cardano-wallet key from-recovery-phrase Shelley | cardano-wallet key child 1852H/1815H/0H/0/0 > my-wallet.prv
[nix-shell:~/marlowe-cardano]$ cardano-cli key convert-cardano-address-key --shelley-payment-key --signing-key-file my-wallet.prv --out-file my-wallet.skey
[nix-shell:~/marlowe-cardano]$ rm my-wallet.prv
[nix-shell:~/marlowe-cardano]$ cardano-cli key verification-key --signing-key-file my-wallet.skey --verification-key-file my-wallet.vkey
[nix-shell:~/marlowe-cardano]$ cardano-cli address build --testnet-magic 1567 --payment-verification-key-file my-wallet.vkey > my-wallet.address
[nix-shell:~/marlowe-cardano]$ ls -l my-wallet.skey my-wallet.vkey
-rw------- 1 johnshearing johnshearing 367 Jul 9 19:14 my-wallet.skey
-rw------- 1 johnshearing johnshearing 244 Jul 9 19:14 my-wallet.vkey
[nix-shell:~/marlowe-cardano]$ cat my-wallet.address
addr_test1vz6fkvz3mj5ddpcleqyv9cxyjm5trrmtmrdudyd5rcvnjec98pk2g
[nix-shell:~/marlowe-cardano]$
[nix-shell:~/marlowe-cardano]$ curl -k -X POST https://faucet.pioneers.testnet.marlowe-finance.io/send-money/$(cat my-wallet.address)
{"success":true,"amount":1000000000,"unit":"lovelace","fee":167789,"minLovelace":999978,"txid":"d00b2a7c9d5f032d0f5caa6ca4a6ee4fe0d8f8844c182ecbac2c237853cf1bd3"}
[nix-shell:~/marlowe-cardano]$
[nix-shell:~/marlowe-cardano]$ export CARDANO_NODE_SOCKET_PATH=/tmp/node.socket
[nix-shell:~/marlowe-cardano]$ export CARDANO_TESTNET_MAGIC=1567
[nix-shell:~/marlowe-cardano]$ CARDANO_NODE_SOCKET_PATH=/tmp/node.socket cardano-cli query tip --testnet-magic 1567
{
"era": "Alonzo",
"syncProgress": "100.00",
"hash": "7a2a1de79b99bb9f235748ffa757b3d31a74645f415f94e42b236d30a97a37b6",
"epoch": 12434,
"slot": 7459033,
"block": 379638
}
[nix-shell:~/marlowe-cardano]$ marlowe-cli util select $(cat my-wallet.address)
TxIn "9d882141b058fb39559a94e1d3701bccefef67597f3aef71b929bd2a689aadb4" (TxIx 0)
TxIn "9d882141b058fb39559a94e1d3701bccefef67597f3aef71b929bd2a689aadb4" (TxIx 1)
TxIn "9d882141b058fb39559a94e1d3701bccefef67597f3aef71b929bd2a689aadb4" (TxIx 2)
TxIn "9d882141b058fb39559a94e1d3701bccefef67597f3aef71b929bd2a689aadb4" (TxIx 3)
TxIn "d00b2a7c9d5f032d0f5caa6ca4a6ee4fe0d8f8844c182ecbac2c237853cf1bd3" (TxIx 0)
[nix-shell:~/marlowe-cardano]$ cardano-cli query utxo --testnet-magic "$CARDANO_TESTNET_MAGIC" --address $(cat my-wallet.address)
TxHash TxIx Amount
--------------------------------------------------------------------------------------
9d882141b058fb39559a94e1d3701bccefef67597f3aef71b929bd2a689aadb4 0 969821035 lovelace + TxOutDatumNone
9d882141b058fb39559a94e1d3701bccefef67597f3aef71b929bd2a689aadb4 1 10000000 lovelace + 1 f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57.434d + TxOutDatumNone
9d882141b058fb39559a94e1d3701bccefef67597f3aef71b929bd2a689aadb4 2 10000000 lovelace + 1 f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57.4642 + TxOutDatumNone
9d882141b058fb39559a94e1d3701bccefef67597f3aef71b929bd2a689aadb4 3 10000000 lovelace + 1 f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57.544d + TxOutDatumNone
d00b2a7c9d5f032d0f5caa6ca4a6ee4fe0d8f8844c182ecbac2c237853cf1bd3 0 1000000000 lovelace + TxOutDatumNone
[nix-shell:~/marlowe-cardano]$
[nix-shell:~/marlowe-cardano]$ INITIAL_LOVELACE=3000000
[nix-shell:~/marlowe-cardano]$ PRICE=256000000
[nix-shell:~/marlowe-cardano]$ SELLER_ROLE="FB"
[nix-shell:~/marlowe-cardano]$ BUYER_ROLE="TM"
[nix-shell:~/marlowe-cardano]$ MEDIATOR_ROLE="CM"
[nix-shell:~/marlowe-cardano]$ marlowe-cli util mint --required-signer my-wallet.skey \
> --change-address $(cat my-wallet.address) \
> --out-file /dev/null \
> --submit 600 \
> "$MEDIATOR_ROLE" "$SELLER_ROLE" "$BUYER_ROLE"
PolicyID "f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57"
[nix-shell:~/marlowe-cardano]$
[nix-shell:~/marlowe-cardano]$ NOW=$(($(date -u +%s)*1000))
[nix-shell:~/marlowe-cardano]$ HOUR=$((60*60*1000))
[nix-shell:~/marlowe-cardano]$ PAYMENT_DEADLINE=$((NOW+10*HOUR))
[nix-shell:~/marlowe-cardano]$ COMPLAINT_DEADLINE=$((NOW+12*HOUR))
[nix-shell:~/marlowe-cardano]$ DISPUTE_DEADLINE=$((NOW+14*HOUR))
[nix-shell:~/marlowe-cardano]$ MEDIATION_DEADLINE=$((NOW+16*HOUR))
[nix-shell:~/marlowe-cardano]$ ROLES_CURRENCY=f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57
[nix-shell:~/marlowe-cardano]$ MEDIATOR_TOKEN="$ROLES_CURRENCY.$MEDIATOR_ROLE"
[nix-shell:~/marlowe-cardano]$ echo $MEDIATOR_TOKEN
f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57.CM
[nix-shell:~/marlowe-cardano]$ BUYER_TOKEN="$ROLES_CURRENCY.$BUYER_ROLE"
[nix-shell:~/marlowe-cardano]$ SELLER_TOKEN="$ROLES_CURRENCY.$SELLER_ROLE"
[nix-shell:~/marlowe-cardano]$ WALLET_SKEY=my-wallet.skey
[nix-shell:~/marlowe-cardano]$ WALLET_ADDRESS=$(cat my-wallet.address)
[nix-shell:~/marlowe-cardano]$ MEDIATOR_ROLE="$MEDIATOR_ROLE"
[nix-shell:~/marlowe-cardano]$ MEDIATOR_SKEY=mediator.skey
[nix-shell:~/marlowe-cardano]$ MEDIATOR_VKEY=mediator.vkey
[nix-shell:~/marlowe-cardano]$ cardano-cli address key-gen --signing-key-file "$MEDIATOR_SKEY" --verification-key-file "$MEDIATOR_VKEY"
[nix-shell:~/marlowe-cardano]$ MEDIATOR_ADDRESS=$(cardano-cli address build --testnet-magic "$CARDANO_TESTNET_MAGIC" --payment-verification-key-file "$MEDIATOR_VKEY")
[nix-shell:~/marlowe-cardano]$ echo $MEDIATOR_ADDRESS
addr_test1vqyg6m4fnrvn0fawud4n53ay3k04sx44yvwrl9f8xq7fs2g8jaf5r
[nix-shell:~/marlowe-cardano]$ BUYER_ROLE="$BUYER_ROLE"
[nix-shell:~/marlowe-cardano]$ BUYER_SKEY=buyer.skey
[nix-shell:~/marlowe-cardano]$ BUYER_VKEY=buyer.vkey
[nix-shell:~/marlowe-cardano]$ cardano-cli address key-gen --signing-key-file "$BUYER_SKEY" --verification-key-file "$BUYER_VKEY"
[nix-shell:~/marlowe-cardano]$ BUYER_ADDRESS=$(cardano-cli address build --testnet-magic "$CARDANO_TESTNET_MAGIC" --payment-verification-key-file "$BUYER_VKEY")
[nix-shell:~/marlowe-cardano]$ echo $BUYER_ADDRESS
addr_test1vzl07pye5nrw4qnhqtl394lvru8g375z44lrdk7r2jgsnegqcd096
[nix-shell:~/marlowe-cardano]$ SELLER_ROLE="$SELLER_ROLE"
[nix-shell:~/marlowe-cardano]$ SELLER_SKEY=seller.skey
[nix-shell:~/marlowe-cardano]$ echo $SELLER_SKEY
seller.skey
[nix-shell:~/marlowe-cardano]$ SELLER_VKEY=seller.vkey
[nix-shell:~/marlowe-cardano]$ cardano-cli address key-gen --signing-key-file "$SELLER_SKEY" --verification-key-file "$SELLER_VKEY"
[nix-shell:~/marlowe-cardano]$ SELLER_ADDRESS=$(cardano-cli address build --testnet-magic "$CARDANO_TESTNET_MAGIC" --payment-verification-key-file "$SELLER_VKEY")
[nix-shell:~/marlowe-cardano]$ echo $SELLER_ADDRESS
addr_test1vrhkg8cyplfdzkm2a38cler5sazqhc36rgu3hn0gfsenz3cvrdjzs
[nix-shell:~/marlowe-cardano]$ cardano-cli query utxo --testnet-magic "$CARDANO_TESTNET_MAGIC" --address "$WALLET_ADDRESS"
TxHash TxIx Amount
--------------------------------------------------------------------------------------
418f1f033141b5ddc19f1026c40d84d41514f8f60cd871d906b725cf3329fbe4 0 1969617958 lovelace + TxOutDatumNone
418f1f033141b5ddc19f1026c40d84d41514f8f60cd871d906b725cf3329fbe4 1 10000000 lovelace + 2 f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57.434d + TxOutDatumNone
418f1f033141b5ddc19f1026c40d84d41514f8f60cd871d906b725cf3329fbe4 2 10000000 lovelace + 2 f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57.4642 + TxOutDatumNone
418f1f033141b5ddc19f1026c40d84d41514f8f60cd871d906b725cf3329fbe4 3 10000000 lovelace + 2 f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57.544d + TxOutDatumNone
[nix-shell:~/marlowe-cardano]$ TX_IN=418f1f033141b5ddc19f1026c40d84d41514f8f60cd871d906b725cf3329fbe4
[nix-shell:~/marlowe-cardano]$ marlowe-cli transaction simple --required-signer "$WALLET_SKEY" \
> --tx-in "$TX_IN#0" \
> --tx-in "$TX_IN#1" \
> --tx-in "$TX_IN#2" \
> --tx-in "$TX_IN#3" \
> --change-address "$WALLET_ADDRESS" \
> --tx-out "$MEDIATOR_ADDRESS+20000000+1 $ROLES_CURRENCY.$MEDIATOR_ROLE" \
> --tx-out "$BUYER_ADDRESS+300000000+1 $ROLES_CURRENCY.$BUYER_ROLE" \
> --tx-out "$SELLER_ADDRESS+40000000+1 $ROLES_CURRENCY.$SELLER_ROLE" \
> --out-file /dev/null \
> --submit 600
TxBodyErrorNonAdaAssetsUnbalanced (valueFromList [(AdaAssetId,1639426013),(AssetId "f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57" "CM",1),(AssetId "f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57" "FB",1),(AssetId "f5d49aca7cd69d9b8347ce307e6f326e0c088181733ff9a5c1d66e57" "TM",1)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment