                     end
                   end)
 
-
         Map.put(attrs, :assets_transactions, new_map)
     end
 
     update_counter(counter, attrs)
   end
 
-  def add_address_to_table() do
+  def get_attrs_for_type(counter, transaction) do
+    case Map.get(transaction, :type) do
+      "ContractTransaction" ->
+        %{
+          :total_transactions => Map.get(counter, :total_transactions) + 1,
+          :contract_transactions =>
+            Map.get(counter, :contract_transactions) + 1,
+        }
+      "InvocationTransaction" ->
+        %{
+           :total_transactions => Map.get(counter, :total_transactions) + 1,
+           :invocation_transactions =>
+             Map.get(counter, :invocation_transactions) + 1,
+         }
+      "ClaimTransaction" ->
+        %{
+           :total_transactions => Map.get(counter, :total_transactions) + 1,
+           :claim_transactions => Map.get(counter, :claim_transactions) + 1,
+         }
+      "PublishTransaction" ->
+        %{
+           :total_transactions => Map.get(counter, :total_transactions) + 1,
+           :publish_transactions => Map.get(counter, :publish_transactions) + 1,
+         }
+      "RegisterTransaction" ->
+        %{
+           :total_transactions => Map.get(counter, :total_transactions) + 1,
+           :register_transactions =>
+             Map.get(counter, :register_transactions) + 1,
+         }
+      "IssueTransaction" ->
+        %{
+           :total_transactions => Map.get(counter, :total_transactions) + 1,
+           :issue_transactions => Map.get(counter, :issue_transactions) + 1,
+         }
+      "MinerTransaction" ->
+        %{
+           :miner_transactions => Map.get(counter, :miner_transactions) + 1,
+         }
+    end
+  end
+
+  def add_address_to_table do
     %{:total_addresses => addresses} = counter = get_counter()
     update_counter(counter, %{:total_addresses => addresses + 1})
   end

      {:error, %Ecto.Changeset{}}

  """
  def initialize_counter() do
    %{
      :total_blocks => Blocks.count_blocks(),
      :total_transactions=> Transactions.count_transactions(),
      :total_addresses => Addresses.count_addresses(),
      :contract_transactions => Transactions.count_transactions(["ContractTransaction"]),
      :claim_transactions => Transactions.count_transactions(["ClaimTransaction"]),
      :invocation_transactions => Transactions.count_transactions(["InvocationTransaction"]),
      :miner_transactions => Transactions.count_transactions(["MinerTransaction"]),
      :publish_transactions => Transactions.count_transactions(["PublishTransaction"]),
      :issue_transactions => Transactions.count_transactions(["IssueTransaction"]),
      :register_transactions => Transactions.count_transactions(["RegisterTransaction"]),
    }
    |> Map.merge(ChainAssets.get_assets_stats())
    |> Counter.changeset()
    |> Repo.insert!()
  end


  @doc """
  Updates an stats.


  def add_transaction_to_table(transaction) do
    counter = get_counter()
    attrs = get_attrs_for_type(counter, transaction)

    attrs = case Map.get(transaction, :asset_moved) do
      nil ->
