<p>you should pass parameters as an array.</p>

<p>try like that: </p>

<pre><code>$bitcoin-&gt;createrawtransaction(
    array(
        array(
            "txid"=&gt;"aed23bb3ec7e93d69450d7e5ea49d52fcfbef9d380108f2be8fe14ef705fcea5",
            "vout"=&gt;2
        ),
        array(
            "txid"=&gt;"b28c740c66726ab2f0397be29f2d25f091b8ab353b98b9ebf9e6ccfd080cdf49",
            "vout"=&gt;3
        ),
    ),
    array(
        "1GTDT3hYk4x4wzaa9k38pRsHy9SPJ7qPzT"=&gt;0.006,
        "1ApD64wpNUM6GBeSmKYhsyaNwFot3FMC5y"=&gt;0.004,
    )
);
</code></pre>

CC BY-SA 3.0
2018-01-03T12:08:36.390Z
2018-01-03T12:08:36.390Z
Tailer
<p>I can't get createrawtransaction to work in PHP using jsonRPC.</p>

<p>I found this thread <a href="https://bitcointalk.org/index.php?topic=133769.0" rel="nofollow">https://bitcointalk.org/index.php?topic=133769.0</a> from a few months ago describing the process. It won't work however, no matter how many different ways I try it...</p>

<pre><code>$arg1 = array( array( "txid"=&gt;$lasttx, "vout"=&gt;$n));
$arg2 = array( $address=&gt;$coins);


array(1) {
  [0]=&gt;
  array(2) {
    ["txid"]=&gt;
    string(64) "valid_tx_id_goes_here"
    ["vout"]=&gt;
    int(1)
  }
}
array(1) {
  ["valid_address_goes_here"]=&gt;
  float(0.01)
}


$this-&gt;bitcoind-&gt;createrawtransaction($arg, $arg2);
</code></pre>

<p>EDIT: All of the other commands work, like <code>getblock</code> and etc. So I'm connected to the RPC server clearly. The errors aren't helpful either -- it says unable to connect when I output the error for createrawtransaction, but all of the other commands go through the RPC fine and are able to connect. I wish I knew how to even begin debugging this.</p>

<transactions><development><php>
jsonRPC calling createrawtransaction in PHP
bvpx
# jsonRPC calling createrawtransaction in PHP

(Asked by: username_0 on 2013-10-01)

I can't get createrawtransaction to work in PHP using jsonRPC.
I found this thread https://bitcointalk.org/index.php?topic=133769.0 from a few months ago describing the process. It won't work however, no matter how many different ways I try it...
$arg1 = array( array( "txid"=>$lasttx, "vout"=>$n));
$arg2 = array( $address=>$coins);


array(1) {
  [0]=>
  array(2) {
    ["txid"]=>
    string(64) "valid_tx_id_goes_here"
    ["vout"]=>
    int(1)
  }
}
array(1) {
  ["valid_address_goes_here"]=>
  float(0.01)
}


$this->bitcoind->createrawtransaction($arg, $arg2);

EDIT: All of the other commands work, like getblock and etc. So I'm connected to the RPC server clearly. The errors aren't helpful either -- it says unable to connect when I output the error for createrawtransaction, but all of the other commands go through the RPC fine and are able to connect. I wish I knew how to even begin debugging this.

**Tags:** transactions, development, php


---

## 1 answers

### Answer by username_1 on 2018-01-03. Score: 2

you should pass parameters as an array.
try like that: 
$bitcoin->createrawtransaction(
    array(
        array(
            "txid"=>"aed23bb3ec7e93d69450d7e5ea49d52fcfbef9d380108f2be8fe14ef705fcea5",
            "vout"=>2
        ),
        array(
            "txid"=>"b28c740c66726ab2f0397be29f2d25f091b8ab353b98b9ebf9e6ccfd080cdf49",
            "vout"=>3
        ),
    ),
    array(
        "1GTDT3hYk4x4wzaa9k38pRsHy9SPJ7qPzT"=>0.006,
        "1ApD64wpNUM6GBeSmKYhsyaNwFot3FMC5y"=>0.004,
    )
);


---

