Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h4>connex.thor.filter - event(VTHO transfer)</h4>
<pre id="status">connecting to node.....</pre>
<label>criteria: </label>
<select id="criteria">
  <!-- Base on transferEventABI indexed == true   -->
  <option value="_from">_from</option>
  <option value="_to">_to</option>
</select>
<label>address:</label>
<input id="address" placeholder="input address" value="0xd3ae78222beadb038203be21ed5ce7c9b1bff602"></input>
<br><br>
<label>order: </label>
<select id="order">
  <option value="desc">desc</option>
  <option value="asc">asc</option>
</select>
<br><br>
<label>fitlerRange: </label>
<select id="rangeUnit">
  <option value="block">block</option>
  <option value="time">time</option>
</select>
<label>from</label>
<input id="from"></input>
<label>to</label>
<input id="to"></input>
<h5>Note: Enter block number or timestamp in second</h5>
<button onclick="filter()">filter</button>
<pre id="filterResult"></pre>
              
            
!

CSS

              
                
              
            
!

JS

              
                const connex = new Connex({
  node: "https://testnet.veblocks.net/",
  network: "test"
});
//VTHO transfer
const transferEventABI = {
  anonymous: false,
  inputs: [
    { indexed: true, name: "_from", type: "address" },
    { indexed: true, name: "_to", type: "address" },
    { indexed: false, name: "_value", type: "uint256" }
  ],
  name: "Transfer",
  type: "event"
};
const transferEvent = connex.thor
  .account("0x0000000000000000000000000000456E65726779")
  .event(transferEventABI);
const filterResult = document.getElementById("filterResult");
const filterOffset = 0; // Start cursor in the result
const filterLimit = 1; // Constrain the number of result returned
const ticker = connex.thor.ticker();

void (async () => {
  for (;;) {
    await ticker.next();
    document.getElementById("status").innerText =
      "Current block# " + connex.thor.status.head.number;
  }
})();

function filter() {
  const criteriaType = document.getElementById("criteria").value;
  const orderType = document.getElementById("order").value;
  const rangeUnit = document.getElementById("rangeUnit").value;
  const address = document.getElementById("address").value;
  const filterFrom = document.getElementById("from").value;
  const filterTo = document.getElementById("to").value;
  filterResult.innerText = "";

  // Create a filter from eventABI
  const criteria = { [criteriaType]: address };
  const filter = transferEvent.filter([criteria]);
  // Set filter order
  filter.order(orderType);
  // Set filter range
  if (filterFrom && filterTo != "") {
    filter.range({
      unit: rangeUnit,
      from: parseInt(filterFrom, 10),
      to: parseInt(filterTo, 10)
    });
  }
  // Set the range
  // Apply the filter, get the first one
  filter.apply(filterOffset, filterLimit).then((logs) => {
    filterResult.innerText = JSON.stringify(logs, null, 4);
  });
}

              
            
!
999px

Console