Skip to content

New Transaction commands#9

Merged
safestak-keith merged 37 commits intomainfrom
feature/new-tx-commands
Jul 5, 2022
Merged

New Transaction commands#9
safestak-keith merged 37 commits intomainfrom
feature/new-tx-commands

Conversation

@safestak-keith
Copy link
Copy Markdown
Collaborator

@safestak-keith safestak-keith commented Jun 28, 2022

New Transaction Commands

Build Simple Payment Transaction

Creates (+ optionally signs & submits) a transaction for a payment of ADA from an address to another address.

$ cscli transaction simple-payment build --network testnet --from addr_test1vq5zuhh9685fup86syuzmu3e6eengzv8t46mfqxg086cvqqc5zr4t --to addr_test1vpuuxlat45yxvtsk44y4pmwk854z4v9k879yfe99q3g3aagqqzar3 --ada 420 --message "thx for lunch"
84a50081825820dcfe996519321071430c812525393f431d75208428852491e9c0c6788dad5f9201018282581d6079c37fabad08662e16ad4950edd63d2a2ab0b63f8a44e4a504511ef51a1908b10082581d60282e5ee5d1e89e04fa81382df239d6733409875d75b480c879f586001a5cf39dd9021a00029ee5031a03afdc580758200088270ea98923127ef4c2e05b665b81b5a6c9fca1582eed1171ba17648f7b3da0f582a11902a2a1636d73676d74687820666f72206c756e636880
Build and Submit Signed Simple Payment
$ cscli transaction simple-payment build --submit true --signing-key addr_xsk1fzw9r482t0ekua7rcqewg3k8ju5d9run4juuehm2p24jtuzz4dg4wpeulnqhualvtx9lyy7u0h9pdjvmyhxdhzsyy49szs6y8c9zwfp0eqyrqyl290e6dr0q3fvngmsjn4aask9jjr6q34juh25hczw3euust0dw --network testnet --from addr_test1vq5zuhh9685fup86syuzmu3e6eengzv8t46mfqxg086cvqqc5zr4t --to addr_test1vpuuxlat45yxvtsk44y4pmwk854z4v9k879yfe99q3g3aagqqzar3 --ada 420 --message "thx for lunch"
5853cc86af075cc547a5a20658af54841f37a5832532a704c583ed4f010184a5
Build Signed Simple Payment Tx with cardano-cli Output File
$ cscli transaction simple-payment build --out-file tx.txsigned --signing-key addr_xsk1fzw9r482t0ekua7rcqewg3k8ju5d9run4juuehm2p24jtuzz4dg4wpeulnqhualvtx9lyy7u0h9pdjvmyhxdhzsyy49szs6y8c9zwfp0eqyrqyl290e6dr0q3fvngmsjn4aask9jjr6q34juh25hczw3euust0dw --network testnet --from addr_test1vq5zuhh9685fup86syuzmu3e6eengzv8t46mfqxg086cvqqc5zr4t --to addr_test1vpuuxlat45yxvtsk44y4pmwk854z4v9k879yfe99q3g3aagqqzar3 --ada 420 --message "thx for lunch"
84a500818258205853cc86af075cc547a5a20658af54841f37a5832532a704c583ed4f010184a501018282581d6079c37fabad08662e16ad4950edd63d2a2ab0b63f8a44e4a504511ef51a1908b10082581d60282e5ee5d1e89e04fa81382df239d6733409875d75b480c879f586001a43e80724021a0002c24d031a03afe00c0758200088270ea98923127ef4c2e05b665b81b5a6c9fca1582eed1171ba17648f7b3da10081825820de9503426759fa18624657f5bcc932f38220ec9eceb262907caf2d198b6e0faa584025f49ad0cb27c0a297ebd2237134be2803b19d11c6e52416d3d7beba130bbc2bd95eb9b7e9e7410d7efcd5c2abd338dd62100d86b26308636335b533873bb508f582a11902a2a1636d73676d74687820666f72206c756e636880
$ cat tx.txsigned
{
  "type": "Tx AlonzoEra",
  "description": "",
  "cborHex": "84a500818258205853cc86af075cc547a5a20658af54841f37a5832532a704c583ed4f010184a501018282581d6079c37fabad08662e16ad4950edd63d2a2ab0b63f8a44e4a504511ef51a1908b10082581d60282e5ee5d1e89e04fa81382df239d6733409875d75b480c879f586001a43e80724021a0002c24d031a03afe00c0758200088270ea98923127ef4c2e05b665b81b5a6c9fca1582eed1171ba17648f7b3da10081825820de9503426759fa18624657f5bcc932f38220ec9eceb262907caf2d198b6e0faa584025f49ad0cb27c0a297ebd2237134be2803b19d11c6e52416d3d7beba130bbc2bd95eb9b7e9e7410d7efcd5c2abd338dd62100d86b26308636335b533873bb508f582a11902a2a1636d73676d74687820666f72206c756e636880"
}

Sign Transaction

Signs (aka append VKey Witnesses) for a transaction from one or more signing keys.

$ cscli transaction sign --signing-keys addr_xsk1fzw9r482t0ekua7rcqewg3k8ju5d9run4juuehm2p24jtuzz4dg4wpeulnqhualvtx9lyy7u0h9pdjvmyhxdhzsyy49szs6y8c9zwfp0eqyrqyl290e6dr0q3fvngmsjn4aask9jjr6q34juh25hczw3euust0dw --network testnet --cbor-hex 84a50081825820dcfe996519321071430c812525393f431d75208428852491e9c0c6788dad5f9201018282581d6079c37fabad08662e16ad4950edd63d2a2ab0b63f8a44e4a504511ef51a1908b10082581d60282e5ee5d1e89e04fa81382df239d6733409875d75b480c879f586001a5cf39dd9021a00029ee5031a03afdc580758200088270ea98923127ef4c2e05b665b81b5a6c9fca1582eed1171ba17648f7b3da0f582a11902a2a1636d73676d74687820666f72206c756e636880
84a50081825820dcfe996519321071430c812525393f431d75208428852491e9c0c6788dad5f9201018282581d6079c37fabad08662e16ad4950edd63d2a2ab0b63f8a44e4a504511ef51a1908b10082581d60282e5ee5d1e89e04fa81382df239d6733409875d75b480c879f586001a5cf39dd9021a00029ee5031a03afdc580758200088270ea98923127ef4c2e05b665b81b5a6c9fca1582eed1171ba17648f7b3da10081825820de9503426759fa18624657f5bcc932f38220ec9eceb262907caf2d198b6e0faa5840d856197bc4f4cb62439ea9c2781e9764855685c3809364ef759b1926047d7bb326fecf2ee1144c5d49cf2f53feb432fa1af30e00d8d69c4145e6494fd1979a0cf582a11902a2a1636d73676d74687820666f72206c756e636880

View Transaction

Views a JSON representation of the transaction including the transaction ID.

$ cscli transaction view --network testnet --cbor-hex 84a50081825820dcfe996519321071430c812525393f431d75208428852491e9c0c6788dad5f9201018282581d6079c37fabad08662e16ad4950edd63d2a2ab0b63f8a44e4a504511ef51a1908b10082581d60282e5ee5d1e89e04fa81382df239d6733409875d75b480c879f586001a5cf39dd9021a00029ee5031a03afdc580758200088270ea98923127ef4c2e05b665b81b5a6c9fca1582eed1171ba17648f7b3da0f582a11902a2a1636d73676d74687820666f72206c756e636880
{
  "id": "be9b3070e17f9f0c3e5477b315a35b9c5be0ec355f6c6bfb4beee42270413a25",
  "isValid": true,
  "transactionBody": {
    "inputs": [
      {
        "transactionId": "dcfe996519321071430c812525393f431d75208428852491e9c0c6788dad5f92",
        "transactionIndex": 1
      }
    ],
    "outputs": [
      {
        "address": "addr_test1vpuuxlat45yxvtsk44y4pmwk854z4v9k879yfe99q3g3aagqqzar3",
        "value": {
          "lovelaces": 420000000,
          "nativeAssets": []
        }
      },
      {
        "address": "addr_test1vq5zuhh9685fup86syuzmu3e6eengzv8t46mfqxg086cvqqc5zr4t",
        "value": {
          "lovelaces": 1559469529,
          "nativeAssets": []
        }
      }
    ],
    "mint": [],
    "fee": 171749,
    "ttl": 61856856,
    "auxiliaryDataHash": "0088270ea98923127ef4c2e05b665b81b5a6c9fca1582eed1171ba17648f7b3d",
    "transactionStartInterval": null
  },
  "transactionWitnessSet": null,
  "auxiliaryData": {
    "metadata": {
      "674": {
        "msg": "thx for lunch"
      }
    }
  }
}

…r building simple-payment transaction. Fixed metadata deserialisation when it doesn't exist
…regateValue -> Balance, fixed null TranscationWitnessSet deserialisation for view transaction
// Fee Calculation
var fee = tx.CalculateFee(protocolParams.MinFeeA, protocolParams.MinFeeB);
txBodyBuilder.SetFee(fee);
var fee = tx.CalculateAndSetFee(protocolParams.MinFeeA, protocolParams.MinFeeB);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nothingalike FYI removal of a few lines thanks to the latest update to CardanoSharp.Wallet. Also note the removal of TransactionBodyBuilder.Create.SetFee(0) above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love to see it!

Derive Key and Address for Internal RoleType aka Change
…s to the output text. i set the initial fee to the min b fee like we discussed. I was getting an error for too low fee until adding it
@nothingalike
Copy link
Copy Markdown
Member

Testing build, sign, and submit worked as intended.

Heres my condensed version which just uses more of the options of build command to submit directly/immediately
https://testnet.cardanoscan.io/transaction/f7eae9813d05aa8d523ea8c93d029874a03b673d059f0592a798aaf18642b484

.\Cscli.ConsoleTool.exe transaction simple-payment build --network testnet --from addr_test1qq4qw3s2p5q0ttfucewkttnz795ujue9jd7ruxrpsa05f47cq54ahxv48q2ja88q22f3t9s3gd3napuy9ausj7wdantsvjsd9s --to addr_test1qpx5dv9yx898he0pjkssxhqa5z59dvxdnvvflqng8v3jlwvlzt2g72xze7ker3rcr4htyhqvyk9sw4uh4nhs5g47m2eq9f26rz --ada 40 --message "Hi from cscli!" --signing-key addr_xsk1ep57x8g50e64l3lft7m798whl3764w5rekeagtvuga3k79ns9ed5y6t5nh97qphcywle2htkeakt6ycrcv8em8am8scv28eum4dmfwl7enqx7lja9xlazp2yryk9pmv4g09jqaxzprdnljn6sv2qsdu4fcq9ak33 --submit true

@safestak-keith safestak-keith merged commit 0961a2e into main Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants