how to know block id in class which extend from BlockBase
BlockBase is a plugin, and as such has a getPluginId method. As you need this inside the class itself, it's as easy as:

$id = $this-&gt;getPluginId();