<p>First, run <code>bitcoind</code> on your server. Set up <code>bitcoin.conf</code> to have the correct RPC port and a password and etc.</p>

<p>Then, include the jsonRPCClient.php file:</p>

<pre><code>include('jsonRPCClient.php');
</code></pre>

<p>Then, instantiate an object like so:</p>

<pre><code>$bitcoind = new jsonRPCClient("http://$YOUR_RPC_USER:$YOUR_RPC_PASS@$YOUR_RPC_HOST:$YOUR_RPC_PORT/");
</code></pre>

<p>You can now run commands from the RPC using this object.</p>

<pre><code>$bitcoind-&gt;getnetworkhashps();
$bitcoind-&gt;getrawtransaction($txid);
</code></pre>

<p>So if you want a new address:</p>

<pre><code>$newaddr = $bitcoind-&gt;getnewaddress();
</code></pre>

CC BY-SA 3.0
2013-10-21T22:37:48.497Z
2013-10-21T22:46:37.903Z
2013-10-21T22:46:37.903Z
bvpx
<p>bitcoind - d for daemon. It has a native JSON-RPC API built in to it, indeed that's what it provides. You simply use JSON-RPC calls to get information out of bitcoind, or indeed to send information to bitcoind.</p>

<ul>
<li><a href="https://en.bitcoin.it/wiki/API_reference_%28JSON-RPC%29" rel="nofollow">JSON-RPC API Reference</a></li>
<li><a href="https://en.bitcoin.it/wiki/PHP_developer_intro" rel="nofollow">PHP Developer Intro</a></li>
<li><a href="https://github.com/search?q=bitcoin+php" rel="nofollow">Bitcoin + PHP search on GitHub</a></li>
</ul>

CC BY-SA 3.0
2013-10-21T21:50:45.950Z
2013-10-21T21:50:45.950Z
extcoin
<p>I'm trying to write a PHP plugin that will talk to bitcoind to generate a random address to send a bitcoin transaction to. </p>

<p>I'm really confused: how am I supposed to setup bitcoind so that we can query it to generate a random address? </p>

<p>Thanks!  </p>

CC BY-SA 3.0
2013-10-18T11:41:11.683Z
https://en.bitcoin.it/wiki/PHP_developer_intro
Joe White
<bitcoind><php>
How do we talk to bitcoind in a PHP plugin?
Vinamrata
# How do we talk to bitcoind in a PHP plugin?

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

I'm trying to write a PHP plugin that will talk to bitcoind to generate a random address to send a bitcoin transaction to.

I'm really confused: how am I supposed to setup bitcoind so that we can query it to generate a random address?

Thanks!

**Tags:** bitcoind, php

> **Comments:**
> **username_1**: https://en.bitcoin.it/wiki/PHP_developer_intro  

---

## 2 answers

### Answer by username_2 on 2013-10-21. Score: 2

First, run bitcoind on your server. Set up bitcoin.conf to have the correct RPC port and a password and etc.
Then, include the jsonRPCClient.php file:
include('jsonRPCClient.php');

Then, instantiate an object like so:
$bitcoind = new jsonRPCClient("http://$YOUR_RPC_USER:$YOUR_RPC_PASS@$YOUR_RPC_HOST:$YOUR_RPC_PORT/");

You can now run commands from the RPC using this object.
$bitcoind->getnetworkhashps();
$bitcoind->getrawtransaction($txid);

So if you want a new address:
$newaddr = $bitcoind->getnewaddress();


---

### Answer by username_3 on 2013-10-21. Score: 0

bitcoind - d for daemon. It has a native JSON-RPC API built in to it, indeed that's what it provides. You simply use JSON-RPC calls to get information out of bitcoind, or indeed to send information to bitcoind.

* [JSON-RPC API Reference](https://en.bitcoin.it/wiki/API_reference_%28JSON-RPC%29)
* [PHP Developer Intro](https://en.bitcoin.it/wiki/PHP_developer_intro)
* [Bitcoin + PHP search on GitHub](https://github.com/search?q=bitcoin+php)


---

