Cardano: Submit Cardano Blockchain Transactions with Embedded Metadata Stored on Filebase
Learn how to submit Cardano blockchain transactions with embedded metadata stored on IPFS.
Cardano is a collection of patent-free, open-source protocols that enable you to store, manage, and transform data and digital identities. Cardano’s developer portal allows users to send and receive native tokens, vote toward community-driven proposals and projects, and interact with smart contracts. Transactions created on the Cardano blockchain can use embedded metadata files, which can be stored on IPFS through Filebase.
Read below to learn how to submit Cardano blockchain transactions with embedded metadata stored on Filebase.
In Cardano, the cardano-node communicates with the back-end server, which creates transactions, then queries the blockchain for the transaction’s metadata information for the front-end.
In this guide, we’ll create a transaction metadata file, store it on Filebase, then submit a transaction to the blockchain that uses our metadata file.
cardano-cli address key-gen \\
--verification-key-file payment.vkey \\
--signing-key-file payment.skey
cardano-cli address build \\
--payment-verification-key-file payment.vkey \\
--out-file payment.addr \\
--testnet-magic 1097911063
View your wallet address in the
payment.addr
file. Take note of this wallet address.{
"1": {
"name": "cardano-test metadata",
"completed": 0
}
}
For this tutorial, we need an IPFS Filebase bucket. For instructions on creating an IPFS bucket, see our documentation here.​
This tutorial uses AWS CLI to upload this file. For more information on AWS CLI, see our configuration guide here.
aws --endpoint https://s3.filebase.com s3 cp metadata.json s3://filebase-bucket
Using AWS CLI, we can get the IPFS CID with the command:
aws --endpoint https://s3.filebase.com s3api head-object --bucket ipfs-bucket-name --key metadata.json
Take note of the Metadata value ‘CID’.
cardano-cli query utxo --testnet-magic 1097911063 --address $(cat payment.addr)
Take note of the TxHash value and TxIndex value outputted by this command.
Use the following command:
cardano-cli transaction build-raw \\
--tx-in {TxHash}#{TxIndex}\\
--tx-out $(cat payment.addr)+0 \\
--metadata-json-file https://ipfs.filebase.io/ipfs/{IPFS_CID} \\
--fee 0 \\
--out-file tx.draft
Replace the following values:
- TxHash: TxHash Value from Step 7
- TxIndex: TxIndex Value from Step 7
- IPFS_CID: Filebase IPFS CID from Step 6
cardano-cli transaction calculate-min-fee \\
--tx-body-file tx.draft \\
--tx-in-count 1 \\
--tx-out-count 1 \\
--witness-count 1 \\
--byron-witness-count 0 \\
--testnet-magic 1097911063 \\
--protocol-params-file protocol.json
Take note of this value.
cardano-cli transaction build-raw \\
--tx-in dfb99f8f103e56a856e04e087255dbaf402f3801acb71a6baf423a1054d3ccd5#0 \\
--tx-out $(cat payment.addr)+1749480133 \\
--metadata-json-file metadata.json \\
--fee [FEE_FROM_STEP_9] \\
--out-file tx.draft
cardano-cli transaction sign \\
--tx-body-file tx.draft \\
--signing-key-file payment.skey \\
--testnet-magic 1097911063 \\
--out-file tx.signed
cardano-cli transaction submit \\
--tx-file tx.signed \\
--testnet-magic 1097911063
If you have any questions, please join our Discord server, or send us an email at [email protected]​
Last modified 9mo ago