Accessing address in smart filter

+1 vote
Hi, I am looking to create a smart filer that does something like

 

function filterstreamitem()
{
  var item=getfilterstreamitem();
 
  for (var i=0;i<item.keys.length; i++) {
    var key=item.keys[i];
   
    if (key == 'Complete' &&  address1  != addressOfGenesisBlockMiner)
      return 'Unable to publish this content';
  }
}

In order to create a restriction on the keys that people post with (in this case only the genesis block miner can add the key 'complete'). Is it possible to, within a stream, access the address of someone trying to post something to a stream? Also is it possible to access the address of the genesis block miner with a function, or should I just hard code it? Thanks for your help
asked Jul 8 by anonymous
edited Jul 8

1 Answer

0 votes

First, you can access the address of person publishing the item from the publishers field in the output of getfilterstreamitem() exactly how you are using the keys field now. Usually an item will have only one publisher, but it is possible for it to be published together by multiple parties. Some sample code that will help:

https://github.com/MultiChain/smart-filter-examples/blob/master/stream-filters/restrict-key-count.js

As for obtaining the miner of the genesis block, try using:

var genesisminer=getlastblockinfo(getlastblockinfo().height).miner;

answered Jul 9 by MultiChain
I'd also suggest you look into permissions. Maybe use a custom permission for this entity (high3?) and run it through that.
...