Github transaction filter example: Approve Asset Transfer, I'm not able to understand this code?

+1 vote

Code link:


Filter code blocked this transaction with the reason: (time taken 0.001472 seconds)
Address 1KB85GgVgHyters6tMMeQ7DYS9fkY192yq8ey1V did not include sufficient USD spending approvals in this transaction false undefined

I'm trying to understand GitHub transaction filter example- approve asset transfer.

If I have understood it correctly, that code is processing an only pre-approved transaction. pre-approved transactions are those whom approvals are given by the address with low-1 permissions. And that approvals are provided by the command:

sendfrom <approver-address> <approvee-address> {"data":{"json":{"type":"approval","maxraw":<rawqty>,"expiry":<expiry>}}}

So I gave approvals using the above command and I set max raw quantity and expiry as last block time. And then I tried to run this code. But still, I'm getting the above error. To identify that my approval is set properly, I'm checking variable like


for (var inputnum=0; inputnum<; inputnum++) {

var spentoutput=getfiltertxinput(inputnum);

if (

          outputisapproval(spentoutput) &&


          ([0].json.expiry >= getlastblockinfo().time)

) {[0].json.maxraw; /* we can use this approval */



if (requiredraw>0)

return "Address "+address+" did not include sufficient USD spending approvals in this transaction "+hasapproval+" ";





why is returned as undefined even when I have given approvals:


sendfrom 1KB85GgVgHyters6tMMeQ7DYS9fkY192yq8ey1V    192ruBtNjWSXUQi2xpWmka5M14rUbNNxzxTbcb '{"data":{"json":{"type":"approval","maxraw":10000000,"expiry":1584258634}}}'                                                                        

Please resolve my doubt asap.

asked Mar 15, 2020 by user123

1 Answer

0 votes
You need to actually consume the approval in one of the inputs of the transaction you are sending. See the four items listed under "To use an approval" in the comments at the top of the code:

If you are doing this, please reproduce the steps you are performing, and we can see where it might be going wrong.
answered Mar 16, 2020 by MultiChain
Can you please give me an example of those 4 steps?? I know the commands are given but if any demo example you can give consisting of those 4 steps would be really helpful for me. Please I request you.

In that code link it is said that first, we need to send approval, so please provide me the example where you first send approval using "sendfrom" command and then those 4 steps.
Sender address you can take :1KB85GgVgHE8fw6tMMeQ7DYS9fkY192yk8uy1V
Receiver address you can take :1MB85GgVgHE8fw6tMMeQ7DYS9fkY192yk8uy1V