请问如何批量转账呢?

如何批量转账呢? 如何构造多个输出地址呢?

目前还没有现成的批量转账功能。
如果现在要用的话,需要写代码。
可以参考 ruby sdk现有构造交易的代码

尝试写了下代码 提示
CKB::RPCError {:code=>-3, :message=>"InvalidTx(ScriptFailure(ValidationFailure(-2)))"}

code


    def send_capacities(_addrs, capacities, data = "0x")
      raise "addrs.size != capacities.size" if _addrs.size != capacities.size

      _sum = capacities.sum()
      i = gather_inputs(_sum, MIN_CELL_CAPACITY)
      input_capacities = i.capacities

      outputs = []

      _addrs.each_with_index do | addr, inx|

       outputs << Types::Output.new(
          capacity: capacities[inx],
          data: data,
          lock: Types::Script.generate_lock(
            key.address.parse(addr),
            api.system_script_code_hash
          )
        )
      end

      if input_capacities > _sum
        outputs << Types::Output.new(
          capacity: input_capacities - _sum,
          lock: lock
        )
      end

      tx = Types::Transaction.new(
        version: 0,
        deps: [api.system_script_out_point],
        inputs: i.inputs,
        outputs: outputs
      )

      tx_hash = api.compute_transaction_hash(tx)
      tx.sign(key, tx_hash)

      send_transaction(tx)
    end

json 数据

{
    "id":1,
    "jsonrpc":"2.0",
    "method":"send_transaction",
    "params":[
        {
            "version":"0",
            "deps":[
                {
                    "block_hash":null,
                    "cell":{
                        "tx_hash":"0xbffab7ee0a050e2cb882de066d3dbf3afdd8932d6a26eda44f06e4b23f0f4b5a",
                        "index":"1"
                    }
                }
            ],
            "inputs":[
                {
                    "args":[

                    ],
                    "previous_output":{
                        "block_hash":null,
                        "cell":{
                            "tx_hash":"0xa2c17f60b66eb6d0c340221ca809004b838be6f7bc19ee61fb76d3d775e7dac3",
                            "index":"0"
                        }
                    },
                    "since":"0"
                }
            ],
            "outputs":[
                {
                    "capacity":"10000000000",
                    "lock":{
                        "code_hash":"0x9e3b3557f11b2b3532ce352bfe8017e9fd11d154c4c7f9b7aaaa1e621b539a08",
                        "args":[
                            "0x6098288d6f14bca4cd7654629f505cc41fb00744"
                        ]
                    },
                    "type":null,
                    "data":"0x"
                },
                {
                    "capacity":"7000000000",
                    "lock":{
                        "code_hash":"0x9e3b3557f11b2b3532ce352bfe8017e9fd11d154c4c7f9b7aaaa1e621b539a08",
                        "args":[
                            "0xfd8548f61f46f826aeafac91c18a0c72364df3ad"
                        ]
                    },
                    "type":null,
                    "data":"0x"
                },
                {
                    "capacity":"2098059221658",
                    "lock":{
                        "code_hash":"0x9e3b3557f11b2b3532ce352bfe8017e9fd11d154c4c7f9b7aaaa1e621b539a08",
                        "args":[
                            "0x22f5a6747402a038675fdc6421359006cca4966a"
                        ]
                    },
                    "type":null,
                    "data":"0x"
                }
            ],
            "witnesses":[

            ]
        }
    ]
}

https://explorer.nervos.org/transaction/0xe8ee650721e42a226b5b302754e168d76c1789580d6b3c83bc06885e7ffda195

ok, 发送成功

# lib/ckb/wallet.rb
    def send_capacities(_addrs, capacities, data = "0x")
      raise "addrs.size != capacities.size" if _addrs.size != capacities.size

      outputs = []

      _addrs.each_with_index do | addr, inx|

       outputs << Types::Output.new(
          capacity: capacities[inx],
          data: data,
          lock: Types::Script.generate_lock(
            key.address.parse(addr),
            api.system_script_code_hash
          )
        )
      end

      _sum = capacities.sum()

      charge_output = Types::Output.new(
        capacity: 0,
        lock: lock
      )

      calculate_min_capacity = outputs[0].calculate_min_capacity

      i = gather_inputs(_sum, calculate_min_capacity,
       charge_output.calculate_min_capacity)

      input_capacities = i.capacities

      charge_output.capacity = input_capacities - _sum
      outputs << charge_output if charge_output.capacity.to_i > 0

      tx = Types::Transaction.new(
        version: 0,
        deps: [api.system_script_out_point],
        inputs: i.inputs,
        outputs: outputs
      )

      tx_hash = api.compute_transaction_hash(tx)
      sign_tx = tx.sign(key, tx_hash)

      send_transaction(sign_tx)
    end
zhi="ckt1q9gry5zg32g20ar9dntrygg4r7ayx8xtaa3wa2cwzmvmx6"
wallet.send_capacities(Array.new(500, zhi),  Array.new(500, 60*10**8))