lib/ckb/wallet.rb
def create_udt_account_wallet_cell(capacity, token_info)
      if udt_account_wallet(token_info).created?
        raise "Cell is already created!"
      end
      cell = {
        capacity: capacity,
        data: [0].pack("Q<"),
        lock: udt_account_wallet(token_info).address,
        type: token_info.contract_script_json_object
      }
      needed_capacity = Ckb::Utils.calculate_cell_min_capacity(cell)
      if capacity < needed_capacity
        raise "Not enough capacity for account cell, needed: #{needed_capacity}"
      end

      i = gather_inputs(capacity, MIN_UDT_CELL_CAPACITY)
      input_capacities = i.capacities

      outputs = [cell]
      if input_capacities > capacity
        outputs << {
          capacity: input_capacities - capacity,
          data: "",
          lock: self.address
        }
      end
      tx = {
        version: 0,
        deps: [api.mruby_out_point],
        inputs: Ckb::Utils.sign_sighash_all_inputs(i.inputs, outputs, privkey),
        outputs: outputs
      }
      hash = api.send_transaction(tx)
      # This is in fact an OutPoint here
      {
        hash: hash,
        index: 0
      }
    end
# Create a new cell for storing an existing user defined token, you can
# think this as an ethereum account for a user defined token
Create a new cell for storing an existing user defined token, you can
think this as an ethereum account for a user defined token
Create a new cell for storing an existing user defined token you can think this as an ethereum account for a user defined token
def create_udt_account_wallet_cell(capacity, token_info)
      if udt_account_wallet(token_info).created?
        raise "Cell is already created!"
      end
      cell = {
        capacity: capacity,
        data: [0].pack("Q<"),
        lock: udt_account_wallet(token_info).address,
        type: token_info.contract_script_json_object
      }
      needed_capacity = Ckb::Utils.calculate_cell_min_capacity(cell)
      if capacity < needed_capacity
        raise "Not enough capacity for account cell, needed: #{needed_capacity}"
      end
      i = gather_inputs(capacity, MIN_UDT_CELL_CAPACITY)
      input_capacities = i.capacities
      outputs = [cell]
      if input_capacities > capacity
        outputs << {
          capacity: input_capacities - capacity,
          data: "",
          lock: self.address
        }
      end
      tx = {
        version: 0,
        deps: [api.mruby_out_point],
        inputs: Ckb::Utils.sign_sighash_all_inputs(i.inputs, outputs, privkey),
        outputs: outputs
      }
      hash = api.send_transaction(tx)
      {
        hash: hash,
        index: 0
      }
    end
def create_udt_account_wallet_cell ( capacity , token_info ) if udt_account_wallet ( token_info ) . created? raise "Cell is already created!" end cell = { capacity : capacity , data : [ 0 ] . pack ( "Q<" ) , lock : udt_account_wallet ( token_info ) . address , type : token_info . contract_script_json_object } needed_capacity = Ckb :: Utils . calculate_cell_min_capacity ( cell ) if capacity < needed_capacity raise "Not enough capacity for account cell, needed: #{needed_capacity}" end i = gather_inputs ( capacity , MIN_UDT_CELL_CAPACITY ) input_capacities = i . capacities outputs = [ cell ] if input_capacities > capacity outputs << { capacity : input_capacities - capacity , data : "" , lock : self . address } end tx = { version : 0 , deps : [ api . mruby_out_point ] , inputs : Ckb :: Utils . sign_sighash_all_inputs ( i . inputs , outputs , privkey ) , outputs : outputs } hash = api . send_transaction ( tx ) { hash : hash , index : 0 } end
Create a new cell for storing an existing user defined token, you can
think this as an ethereum account for a user defined token
Create a new cell for storing an existing user defined token you can think this as an ethereum account for a user defined token
# This is in fact an OutPoint here
capacity
token_info