Selecteer een pagina

The blockchain technology caught my attention a few months back when learning more about Gulden, which is a good alternative to Bitcoin. In my opinion the blockchain technology will be the next big thing in tech for the next few decades. It’s been around for almost 8 years now, and to my opinion hasn’t got enough traction it deserves. Therefore I decided I wanted to do more with this technology and learn more about it. But where to start? How to start? There’s so much to learn about the blockchain that it simply cannot be summarized in a simple blogpost like this. But this blogpost is a summary of what I’ve learned with the Gulden blockchain over the past few weeks.


If you are completely blank with what you can do with blockchain technology I recommend you to see this short Youtube video:

Watch that video and you get to know the basics of Blockchain. Watch it again…. and again ….  and again.

My Gulden development journey

My personal Gulden development journey started completely blank. I knew -NOTHING- about blockchain development. Yes I’d consider myself a developer (although I really don’t develop that much) but I know how to develop in different languages. This post is all about connecting the dots. Some dots are really clear to see, and some dots are vague, and I had to make them clear for myself how stuff worked.

Now that I’ve got my development machine up-and-running I help you to have an easy blog post where all the dots you need are connected.

The objective is to write a PHP function which connects to the Gulden Blockchain and returns some interesting data. My main goal with this blog post is to let you see how I’ve managed this.

Dot 0: Prerequisites before starting your development

This blog post is written from a developer point-of-view. I realize that some parts in this blog post are “easy” for some, and completely new for others. I expect at least that you know how to install a Ubuntu machine and that you know what shell commands are and how you can use them. For editing files I use “nano”; you obviously can also use vim. I got to know nano which does the job for me. Further you need to understand at least the basics about how a web server works and how to access php-pages on a web server. If you are that far, this guide will help you through the rest.

Dot 1: Adding a node to the Gulden Network

First I wanted to have my own Gulden node up-and-running. Nodes are important for the network. A node is basically a copy of the Gulden blockchain which connects to other nodes so that you add more speed, stability, and security for the network. Since I’ve had a spare VPS I decided to create the Gulden node on that particular VPS. I installed Ubuntu 16.04 on the VPS and followed the description on the Gulden developer site on how to add a full-node to the network. That particular post can be found here:

After checking that my node was up-and-running the way it should I wanted to do more with it and that it would be great to actually develop on that machine.

Take note: This VPS isn’t security hardened in any way.
Yes I use ufw (uncomplicated Firewall) on the Ubuntu machine but you should really harden your security more than that to make sure you’re not getting hacked.

Dot 2: “Talking” to the blockchain.

In the previous step you set up your Gulden node. GREAT! If the command

returned a value higher than 1 than you can assume that you’ve got an operational node running and that you can go further with this step.

Now you should realize that getconnectioncount isn’t the only function you can execute to return a value. Far from it. There are numerous of functions you can execute like:

  • Getinfo
  • Getblockcount
  • Getdifficulty
  • etc. etc. (<- Not an actual function ;-))

Actually there’s a complete list of functions you can execute. The list can be found here: Gulden RPC Commands

So I learned that when you’ve got a node running you can talk to the blockchain via the Gulden-CLI program. Now THAT’S interesting! My thoughts were:

If you can reach the Gulden-CLI more accessible (not through SSH, but otherwise) it should be the ultimate blockchain development option.

So I started investigating talking to the Gulden network via PHP. Luckily there were more than enough posts on the internet how to do this for the bitcoin network, but I haven’t found any for the Gulden network. To be able to talk to the Gulden network via PHP I knew I had to install a web server and PHP on my machine.

Dot 3: Installing Apache/PHP

Installing Apache & PHP on Ubuntu isn’t really hard at all. I followed the tutorial which I found on DigitalOcean. Of that tutorial I skipped some parts. The parts I didn’t skip were:

  • Step 1: Install Apache and Allow in Firewall
  • Step 3: Install PHP

Make sure you have at least the PHP-module curl installed as well!

After installing Apache and PHP; adding Apache to ufw (uncomplicated Firewall) I typed the ip-address of my server and saw the Apache2 Ubuntu Default Page. I also created a phpinfo-file to make sure PHP was installed correctly. After I set everything up I was good to go to the next dot. If you’ve managed this far: Lucky you 🙂 Please make sure before going further you also have Apache and PHP running and that you have a valid Gulden Node.

Dot 4: Connecting to the Gulden Daemon via PHP

My Google search for “bitcoin php” on Google lead me to this useful Wikipage:

Although I thought the information on that page really was helpful, it also seemed quite outdated. The part that lead me to my success was the EasyBitcoin-PHP  project by Andrew LeCody.
I forked the project and created the Gulden version of it which can be found on the EasyGulden-PHP project on Github.

Now came the tricky part of it. Connecting to your node and seeing it on a webpage. First things first.

We need to connect to the Gulden Daemon via JSON-RPC – You can learn more about JSON-RPC here: – I didn’t learn more about JSON-RPC I just wanted to know how to get this to work with PHP and the Gulden Daemon. First I needed to change some settings in the Gulden.conf file (The file you created in Dot 1: Adding a node to the Gulden Network).

Adding these lines to the Gulden.conf file should make it able to connect via PHP to the Gulden Daemon.

Optionally: You could also add txindex=1 to the gulden.conf-file. If you add this to your gulden.conf file you will be able to get transactions data for any transaction in the Gulden Blockchain, but you need to restart the Gulden Deamon in the next step with the -reindex parameter. This takes quite some time!

Now kill the Gulden Daemon

Add port 9232 (the port you used in the gulden.conf) to be allowed in ufw on the ip (localhost) and restart ufw

After that restart the Gulden Daemon. For me this is:

Please note!:  Your directories could be different

Let’s see what we’ve done here:

disablewallet=0 makes sure you also have a wallet and that you can send and receive transactions (please make sure you’ve security hardened your server! This is for development use only!)
server=1 – tells the Gulden Daemon to accept JSON-RPC commands
rpcclienttimeout=30 – how many seconds GuldenD will wait for a http request
rpcport=9232 – Listen for RPC connections on this TCP port
rpcallowip=  – Allow only RPC calls from localhost. This way you make sure that no other RPC calls from any server (or computer) can be made.
txindex=1 – With this setting you will be able to get transactions data for any transaction in the Gulden blockchain.

The Gulden Daemon needs to be killed and restarted with the new settings (Just to be sure the new gulden.conf file has been loaded).

For this part the Gulden configuration is completed. Next step is to get this to work with PHP.

in Terminal (SSH) enter the following commands:

Paste the text from this file into easygulden.php:

Press Ctrl+X and Y to close nano and save the changes. After that enter the command:

paste the following code into the gulden.php file. Make changes where on the following parameters:

$rpc_port should be the same port as the rpcport in the gulden.conf file
$rpc_user should be the same user as the rcpuser in the gulden.conf file
$rpc_pass should be the same password as the rpcpassword in the gulden.conf file

getconnectioncount() is a function we already saw before (in Dot 1) you can change this with any of the other functions available in the list of functions. Looking at the main objective described at the start of this blog post: There we have it. When going to http://[youripaddress]/gulden.php you should see a number and this number is the connectioncount number. From here you can go further with your PHP development on the Gulden blockchain.


I noticed that troubleshooting this is quite a pain in the butt. I tried as good as I can to describe the way to achieve the goal. Nevertheless there could go something wrong.

Please make sure that you:

  1. have a decent connection with the Gulden blockchain (dot 1)
  2. are able to execute a command via the Gulden-cli (dot 2)
  3. have apache, php and the php-module curl installed correctly and that you see the default apache page when entering your ip address in a browser (dot 3)
  4. have all the used ports (and applications) open on ufw (22 for ssh, 9231 for GuldenD, 9232 for Gulden RPC, Apache Full for webserver)
  5. set the variables correct in the gulden.conf file
  6. restarted the Gulden daemon with the new configuration (killall -9 GuldenD)

If you somehow seem stuck you can also join the Gulden Slack – Sign up for the Gulden Slack here: and go to the channel #developer. There are a lot of developers there and it shouldn’t take long before someone helps you with your questions.

Buy me a beer

If you found this article interesting or if it helped you in any way – please keep in mind that it took me quite some time to collect the above data and write it down in a blog post. It would be very much appreciated if you’d buy me a beer when it saved you some time or if you think this post was interesting 😉 Scan the following QR-code with your Gulden-app and please consider a donation.