<p>Here's a simple code snippet which allows you to bundle transactions if the recipients have the asset you specified in their account.</p>

<pre>
package nxt.customfilter;

import nxt.account.Account;
import nxt.blockchain.Bundler;
import nxt.blockchain.ChildTransaction;
import nxt.db.DbIterator;
import nxt.ae.Asset;


public class FilterByAsset implements Bundler.Filter {

    @Override
    public boolean ok(Bundler bundler, ChildTransaction childTransaction) {
        String assetID = "Insert Your Asset ID Here";
        try (DbIterator iterateAssets = Account.getAccountAssets(childTransaction.getRecipientId(),0,Integer.MAX_VALUE)) {
            while (iterateAssets.hasNext()) {
                if(iterateAssets.next().toString().contains(assetID)) return true;
            }
        }
        return false;
    }
}

</pre>

<p><strong>customfilter</strong> is a folder I created inside <strong>src/java/nxt</strong></p>

<p>So you would create a file and name it <strong><em>FilterByAsset.java</em></strong> inside <strong>customfilter</strong> and paste the above codes.</p>

<p>finally, add <code>nxt.bundlingFilter=nxt.customfilter.FilterByAsset</code> to conf/nxt.properties and compile.</p>

<p><strong>getAccountAssets</strong> method return all the assets in the recipient account and prints out accound_id, asset_id, quantity, and unconfirmedQuantity.</p>

CC BY-SA 3.0
2018-02-09T18:24:55.747Z
2018-02-09T18:24:55.747Z
Toxnyc
<p>Take a look at the bundler filter shipped with Ardor: src/java/nxt/addons/AccountPropertyBundler.java and PersonalBundler.java</p>

<p>You need to be familiar with internal Ardor interfaces in order to write your own bundler filter.  The bundler filter runs as part of the server and is loaded during server initialization.  </p>

<p>You specify a custom bundler in nxt.properties by setting nxt.bundlingFilter.</p>

CC BY-SA 3.0
2018-01-30T05:00:52.780Z
what do you set nxt.bundlingFilter to in the conf file?
Patoshi パトシ
CC BY-SA 3.0
2018-01-30T17:42:37.340Z
You set nxt.bundlingFilter to the class name of the bundler filter that you want to use.  For example, if I wrote a filter called CustomFilter, then I would set nxt.bundlingFilter to org.scripterron.CustomFilter where org.scripterron is my Java package and CustomFilter is the class.
ScripterRon
CC BY-SA 3.0
2018-01-24T20:01:40.283Z
2018-01-24T20:01:40.283Z
ScripterRon
<p>I'm looking to write a custom Ardor bundler to only bundle transactions that have the following properties:</p>

<ul>
<li>Bundle transactions that are being <em>sent to</em> a specific account only.</li>
<li>Bundle transactions where the sender holds a specific type of asset or monetary system coin.</li>
<li>Bundle transactions only if that user hasn't sent more than 10 transactions in the past hour. </li>
</ul>

<p>I couldn't find any code snippets of how to go about setting these custom Ardor bundlers. </p>

<java><ardor><bundler><child-chain>
Code example for Ardor bundler code snippet to filter transactions of a certain criteria to pay ZERO 0 ignis Fees?
Patoshi パトシ
# Code example for Ardor bundler code snippet to filter transactions of a certain criteria to pay ZERO 0 ignis Fees?

(Asked by: username_0 on 2018-01-24)

I'm looking to write a custom Ardor bundler to only bundle transactions that have the following properties:

* Bundle transactions that are being *sent to* a specific account only.
* Bundle transactions where the sender holds a specific type of asset or monetary system coin.
* Bundle transactions only if that user hasn't sent more than 10 transactions in the past hour.

I couldn't find any code snippets of how to go about setting these custom Ardor bundlers.

**Tags:** java, ardor, bundler, child-chain


---

## 2 answers

### Answer by username_1 on 2018-02-09. Score: 1 | Accepted answer

Here's a simple code snippet which allows you to bundle transactions if the recipients have the asset you specified in their account.

package nxt.customfilter;

import nxt.account.Account;
import nxt.blockchain.Bundler;
import nxt.blockchain.ChildTransaction;
import nxt.db.DbIterator;
import nxt.ae.Asset;


public class FilterByAsset implements Bundler.Filter {

    @Override
    public boolean ok(Bundler bundler, ChildTransaction childTransaction) {
        String assetID = "Insert Your Asset ID Here";
        try (DbIterator iterateAssets = Account.getAccountAssets(childTransaction.getRecipientId(),0,Integer.MAX_VALUE)) {
            while (iterateAssets.hasNext()) {
                if(iterateAssets.next().toString().contains(assetID)) return true;
            }
        }
        return false;
    }
}


customfilter is a folder I created inside src/java/nxt
So you would create a file and name it FilterByAsset.java inside customfilter and paste the above codes.
finally, add nxt.bundlingFilter=nxt.customfilter.FilterByAsset to conf/nxt.properties and compile.
getAccountAssets method return all the assets in the recipient account and prints out accound_id, asset_id, quantity, and unconfirmedQuantity.


---

### Answer by username_2 on 2018-01-24. Score: 1

Take a look at the bundler filter shipped with Ardor: src/java/nxt/addons/AccountPropertyBundler.java and PersonalBundler.java

You need to be familiar with internal Ardor interfaces in order to write your own bundler filter. The bundler filter runs as part of the server and is loaded during server initialization.

You specify a custom bundler in nxt.properties by setting nxt.bundlingFilter.

> **Comments:**
> **username_0**: what do you set nxt.bundlingFilter to in the conf file?  
> **username_2**: You set nxt.bundlingFilter to the class name of the bundler filter that you want to use.  For example, if I wrote a filter called CustomFilter, then I would set nxt.bundlingFilter to org.scripterron.CustomFilter where org.scripterron is my Java package and CustomFilter is the class.  

---

