class Blockchain::CreateIssue < ApplicationService

  attr_reader :params

  def initialize(params)
    @params  = params
  end

  def call
    ActiveRecord::Base.transaction do
      username = @params[:user_id].to_s
      token_name = @params[:project_id].to_s
      amount = @params[:token_num].to_i

      # 调用token锁仓函数
      lock_balance_on_blockchain(username, token_name, amount)
    end
  rescue => e
    puts "转账失败: #{e.message}"
    raise Error, e.message
  end

  private

  def no_use
    puts "this function does not have any usage"
  end
end