How To: Submit a Metadata Transaction on the Cardano Blockchain

Submitting a transaction containing metadata in JSON format to the Cardano Blockchain is a fairly easy and straight-forward process. Basically, we will follow the steps found here ( https://docs.cardano.org/projects/cardano-node/en/latest/stake-pool-operations/simple_transaction.html ) with the slight modification of including a --metadata-json-file argument to include our JSON file as part of the transaction.

Create the JSON file on your server

The first step to casting your vote (or submitting your ballot proposal or voter registration) is to save the structured JSON file to your server like shown below:

$ cat my.vote.json
{
    "1": {
        "ObjectType": "VoteBallot",
        "NetworkId": "TheRealAdamDean",
        "ProposalId": "80064c28-1b03-4f1c-abf0-ca8c5a98d5b9",
        "VoterId": "ae2f8433-947b-40a8-8b16-cec54572e408",
        "Choices": [
            {
                "CandidateId": "aaa9503a-6fc5-46ea-9aa0-b4c90f361a4c",
                "VoteWeight": 1,
                "VoteRank": 2
            },
            {
                "CandidateId": "8d649c12-936e-46be-b65a-c17f30f59574",
                "VoteWeight": 1,
                "VoteRank": 1
            },
            {
                "CandidateId": "81ce7f8e-94c3-4835-91fc-2146d51fa1fc",
                "VoteWeight": 1,
                "VoteRank": 3
            },
            {
                "CandidateId": "407540aa-58b5-40ca-b484-f40040eb2990",
                "VoteWeight": 0,
                "VoteRank": 0
            }
        ]
    }
}

A couple of minor changes while making the transaction...

Section 3.3 Draft the Transaction

This step will be changed slightly to reflect the fact that we are submitting our JSON file as part of the transaction metadata. See below for changes. Note unless the vote proposal you are participating in requires you to send a "vote fee" to a specified address, you can simply submit the transaction by using your UTXO as the --tx-in and only your address plus the remainder as the --tx-out.

cardano-cli shelley transaction build-raw \
--tx-in 4e3a6e7fdcb0d0efa17bf79c13aed2b4cb9baf37fb1aa2e39553d5bd720c5c99#4 \
--tx-out $(cat payment.addr)+0 \
--metadata-json-file my.vote.json \
--ttl 0 \
--fee 0 \
--out-file tx.draft

Section 3.7 Build the Transaction

The only change here, identical to the change in Section 3.3 is to include the --metadata-json-file argument while building the transaction.

cardano-cli shelley transaction build-raw \
--tx-in 4e3a6e7fdcb0d0efa17bf79c13aed2b4cb9baf37fb1aa2e39553d5bd720c5c99#4 \
--tx-out $(cat payment.addr)+19832035 \
--metadata-json-file my.vote.json
--ttl 369400 \
--fee 167965 \
--out-file tx.raw

Then submit your transaction!

Those are the only steps that need to be modified from an otherwise "basic" and standard transaction submission. Simply follow the rest of the steps to sign and submit your transaction and your proposal, voter registration, or vote ballot will be submitted officially to the blockchain.