How to feed a transaction with metadata as an input to next transaction?

+1 vote

Scenario: I want to design a supply chain model where in each Transaction I/p should be feed from previous Transaction.

I am able to successfully execute the first transaction taking an unspent I/p transaction & generating an o/p transaction having inline data -

streamchain: listwallettransactions 1
{"method":"listwallettransactions","params":[1],"id":1,"chain_name":"streamchain"}

[
    {
        "balance" : {
            "amount" : 0,
            "assets" : [
            ]
        },
        "myaddresses" : [
            "1EvCWA6RhJohvhMAtTkssx3FFhJs1N5AB56Hh3",
            "1QevGxyWXDCcP6z4VXLy8oyULnZKRfb4tSRvqv"
        ],
        "addresses" : [
        ],
        "permissions" : [
        ],
        "items" : [
        ],
        "data" : [
            {
                "text" : "Requested"
            }
        ],
        "confirmations" : 11,
        "blockhash" : "00cc8adb2f271239a2797b1014bae560300fdf42faacc8eea288c2a94ba3dd22",
        "blockindex" : 1,
        "blocktime" : 1534831625,
        "txid" : "0572612f079f29e6d2a0e286e080a5a27fb2a8df7ca995913c00c741eac4f301",
        "valid" : true,
        "time" : 1534831606,
        "timereceived" : 1534831606
    }
]

Now, I want to feed this transaction i.e 0572612f079f29e6d2a0e286e080a5a27fb2a8df7ca995913c00c741eac4f301 as an input for next transaction. 

So. I am creating another transaction taking this as input & I want to transfer the asset to another address.

createrawtransaction '[{"txid":"0572612f079f29e6d2a0e286e080a5a27fb2a8df7ca995913c00c741eac4f301","vout":1}]' '{"1UdP6xqz3SuK5MfeT1DPaPG2iwZwP5Dvzq2UMG":{"assetproduct":1}}'

appendrawdata 010000000101f3c4ea41c7003c9195a97cdfa8b27fa2a580e086e2a0d2e6299f072f6172050100000000ffffffff0100000000000000003776a914cc697bdd8617017860ecfe7aa888d13413cfd1ae88ac1c73706b714956b57af4ef691e74b3b63cbd232d7c01000000000000007500000000  '{"text":"Available"}'

streamchain: signrawtransaction 010000000101f3c4ea41c7003c9195a97cdfa8b27fa2a580e086e2a0d2e6299f072f6172050100000000ffffffff0200000000000000003776a914cc697bdd8617017860ecfe7aa888d13413cfd1ae88ac1c73706b714956b57af4ef691e74b3b63cbd232d7c0100000000000000750000000000000000120573706b6601756a09417661696c61626c6500000000
{"method":"signrawtransaction","params":["010000000101f3c4ea41c7003c9195a97cdfa8b27fa2a580e086e2a0d2e6299f072f6172050100000000ffffffff0200000000000000003776a914cc697bdd8617017860ecfe7aa888d13413cfd1ae88ac1c73706b714956b57af4ef691e74b3b63cbd232d7c0100000000000000750000000000000000120573706b6601756a09417661696c61626c6500000000"],"id":1,"chain_name":"streamchain"}

{
    "hex" : "010000000101f3c4ea41c7003c9195a97cdfa8b27fa2a580e086e2a0d2e6299f072f617205010000006a473044022001d88619cc1b1a3f3f3fce368bec017f30751b79f144ae771b62c1ea2de95dd102206d67c7a9976e14e619c4f3f4f9b121d78bedc05f0017c0eaf8dc96dd8a5210fa012103b2ccb7c2c367f77a5f0d97011ee29480523788979b1a3cb6ccdb61b7d2e22b61ffffffff0200000000000000003776a914cc697bdd8617017860ecfe7aa888d13413cfd1ae88ac1c73706b714956b57af4ef691e74b3b63cbd232d7c0100000000000000750000000000000000120573706b6601756a09417661696c61626c6500000000",
    "complete" : true
}

While doing the sendrawtransaction I am getting this error -

streamchain: sendrawtransaction 010000000101f3c4ea41c7003c9195a97cdfa8b27fa2a580e086e2a0d2e6299f072f617205010000006a473044022001d88619cc1b1a3f3f3fce368bec017f30751b79f144ae771b62c1ea2de95dd102206d67c7a9976e14e619c4f3f4f9b121d78bedc05f0017c0eaf8dc96dd8a5210fa012103b2ccb7c2c367f77a5f0d97011ee29480523788979b1a3cb6ccdb61b7d2e22b61ffffffff0200000000000000003776a914cc697bdd8617017860ecfe7aa888d13413cfd1ae88ac1c73706b714956b57af4ef691e74b3b63cbd232d7c0100000000000000750000000000000000120573706b6601756a09417661696c61626c6500000000
{"method":"sendrawtransaction","params":["010000000101f3c4ea41c7003c9195a97cdfa8b27fa2a580e086e2a0d2e6299f072f617205010000006a473044022001d88619cc1b1a3f3f3fce368bec017f30751b79f144ae771b62c1ea2de95dd102206d67c7a9976e14e619c4f3f4f9b121d78bedc05f0017c0eaf8dc96dd8a5210fa012103b2ccb7c2c367f77a5f0d97011ee29480523788979b1a3cb6ccdb61b7d2e22b61ffffffff0200000000000000003776a914cc697bdd8617017860ecfe7aa888d13413cfd1ae88ac1c73706b714956b57af4ef691e74b3b63cbd232d7c0100000000000000750000000000000000120573706b6601756a09417661696c61626c6500000000"],"id":1,"chain_name":"streamchain"}

error code: -26
error message:
64: Asset transfer script rejected - mismatch in input/output quantities

Please help me out.

asked Aug 21 by adgupta

1 Answer

0 votes

It sounds like you don't have a change output that balances the total quantities across inputs and outputs. If you want to use createrawtransaction you need to add a change output using the appendrawchange command.

answered Aug 21 by MultiChain
...