How can i apply smart filter to issuemore transaction?

+1 vote
Can anyone explain me is it possible to apply smart filter to issuemore api calls, and if it possible how can i do this in practice? Thank you.
asked Jun 28, 2021 by Levi770
What do you want the smart filter to do?
Only check total issued volume for asset, if not more than specified in the smart filter code, then continue the transaction, if equal or greater then abort.

1 Answer

+1 vote
Best answer

Here's the basic outline for a transaction filter that checks quantities of further asset issuances:

function filtertransaction() {
    var tx = getfiltertransaction();
    for (j = 0; j < tx.vout.length; j++) {
        if (tx.vout[j].assets) {
            for (k = 0; k < tx.vout[j].assets.length; k++) {
                if (tx.vout[j].assets[k].type == "issuemore") {
                    var newqty = tx.vout[j].assets[k].qty;
                    var oldqty = getassetinfo(tx.vout[j].assets[k].name).issueqty;
                    if (oldqty + newqty > 0) return "New qty " + newqty + " old qty " + oldqty;

You'll need to replace the line with if (oldqty + newqty > 0) to reflect whatever rule you want to apply, and whatever error message you want the filter to return if the rule is violated.

answered Jun 29, 2021 by MultiChain
selected Jun 29, 2021 by Levi770
Thank you very much!