HomeРазвлеченияRelated VideosMore From: m1xolyd1an

Bitcoin JSON-RPC Tutorial 5 - Your First Calls

77 ratings | 9530 views
Bitcoin JSON-RPC tutorial. Making your first bitcoin JSON-RPC calls in PHP. My Book: https://www.amazon.com/Building-Bitcoin-Websites-Beginners-Development/dp/153494544X BTC: 1NPrfWgJfkANmd1jt88A141PjhiarT8d9U
Html code for embedding videos on your blog
Text Comments (42)
Aslam Hafizuddin (5 months ago)
when trying to send POST request I got empty result I check the port user and password nothing wrong why can't I connect from easybitcoin ? using CLI have no issues. any idea ?
m1xolyd1an (5 months ago)
*php.ini
m1xolyd1an (5 months ago)
Make sure curl is enabled in your pho.ini and restart apache
Vikas Vekariya (7 months ago)
How to generate rpc username and password
m1xolyd1an (7 months ago)
In your bitcoin.conf file rpcuser=username rpcpassword=secretpassword
armando barra (8 months ago)
thks for the info man!, great video.
Marcelo Soares (8 months ago)
I'm getting HTTP_UNAUTHORIZED trying to run on my local machine. Do have any idea?
Akshay Dev H (8 months ago)
check your RPC username and password
Muhammad Faizan ul haq (10 months ago)
can't we connect to node on vps using php on local desktop ?
# (1 year ago)
it does not work... curl from the web server to wallet server works fine, but this easy bitcoin doesn't work, error 500
Jorge Diaz (11 months ago)
uncomment this line of code in PHP.ini ;extension=php_curl.dl'
Jorge Diaz (11 months ago)
Thank you! This worked!
m1xolyd1an (1 year ago)
I believe digiocean now requires a manual install of phpcurl and be sure curl is enabled in your php.ini
Anthony Lipari (1 year ago)
if i have 20,000 generated receive addresses, how do I monitor them ALL for new transactions? would i need to setup a cron to run every minute which checks them ALL for any new transactions? or is there a better way? like can the server just post to ME when a new transaction is received rather than me checking every minute?
m1xolyd1an (1 year ago)
Anthony Lipari you just put it in your bitcoin.conf file, see video 7 of this series, it goes over walletnotify
Anthony Lipari (1 year ago)
m1xolyd1an awesome thanks! And should this only be run once ever? If the server reboots I should run that command again? Or will it be saved until I run it again?
m1xolyd1an (1 year ago)
+Anthony Lipari Dont use a cron use walletnotify, it monitors all your receiving addresses. It will fire the command you give it twice. Once it hits your mempool, and again after confirmation.
Mykhailo Fiialka (1 year ago)
Is your book in electronic version?
Mario Eduardo Zanetta (1 year ago)
People not lose your time with this sistem. Really is a big lie!. All this configurations not working lose time and money and patient.
# (1 year ago)
me angry same problem very bad, me caveman not understand problem, me fucking pissed
sharad k (1 year ago)
great video. is there way i could get notification of received funds and transafer them to another wallet on the fly ? thanks
# (1 year ago)
yes
Luis Duran Sandoval (1 year ago)
video how to send money
Kaan KILIÇ (1 year ago)
That's what I am looking for. There were not numerous contents about the PHP based native BTC operations. Thanks for it.
Techno Space (1 year ago)
I have tried to run this , but i am still stucked with that " Uncaught exception 'RuntimeException' with message 'Unable to connect to http..........." Error. Any one who can help me contact me on techsupport.asia : skype id
ntsili (2 years ago)
IMPORTANT - THIS COULD HELP YOU IF YOU HAVE ISSUES!! I did everything right but I had an error 500 in explorer (white page in Mozilla) when I was trying to run the script: <?php require("easybitcoin.php"); $bitcoin = new Bitcoin("username", "somepassword"); $info = $bitcoin->getinfo();print_r($info); ?> The script is 100% correct, so I searched in the error.log here: /var/log/apache2/error.log and I found that : "PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /var/www/html/easybitcoin.php:105\nStack trace:\n#0 ..... " I made a search in the net and I found the answer for the problem here: http://stackoverflow.com/questions/34842596/call-to-undefined-function-curl-init-even-it-is-enabled-in-php7 "I've had similar problem with curl after upgrade to XX (16.04). After reinstalling curl with: sudo apt-get install php-curlAnd server restart sudo service apache2 restart everything went back to normal :) " I did it and, MAGIC, the problem is fixed!!! Guys, I saw a LOT of people in the forums having this issue; I think I had a great luck !! I post this here, try it if you have this problem!
Andy Knaebel (1 year ago)
Thanks - I got this same error and this fixed it.
Kamil Kostrzewski (2 years ago)
Will it work with Dashcore? Im doing it like your instruction on localhost, when i saved php its only blank page, no loops.
Ngọc Thạch Hồ (2 years ago)
<?php require_once 'jsonRPCClient.php'; $bitcoin = new jsonRPCClient('http://user:[email protected]:8332/'); echo "<pre>\n"; print_r($bitcoin->getinfo()); echo "</pre>"; ?> my config: server=1 rpcuser=username rpcpassword=pass123 rpcallowip=127.0.0.1 daemon=1 but has error: Warning: fopen(http://[email protected]:8332/): failed to open stream: Connection refused in /var/www/.../jsonRPCClient.php on line 133 Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://user:[email protected]:8332/' in /var/www/coinbase.giaonhanviec.com/jsonRPCClient.php:141 Stack trace: #0 /var/www/.../common.php(15): jsonRPCClient->__call('getinfo', Array) #1 /var/www/.../common.php(15): jsonRPCClient->getinfo() #2 /var/www/.../index.php(3): include('/var/www/coinba...') #3 {main} thrown in /var/www/...m/jsonRPCClient.php on line 141 please help me!!!
m1xolyd1an (2 years ago)
Responded on stackoverflow http://stackoverflow.com/questions/38823308/bitcoind-with-jsonrpcclient-php-not-working/38841058#38841058
Ngọc Thạch Hồ (2 years ago)
i user jsonRPCClient.php in my vps google cloud, and commandline bitcoin-cli getinfo have result, but my code php can't use function bitcoin example: require_once'jsonRPCClient.php'; $Bitcoind->getaccountaddress($wallet_id); $Bytecoind->getaccountaddress($wallet_id); them not running, i try var_dump('xxxx'); after them but not displayed, all code after them not running.  i don't know my vps lacking something, please help me.
m1xolyd1an (2 years ago)
It's different when using jsonRPCClient. require_once("jsonRPCClient.php"); $bitcoin = new jsonRPCClient('http://user:[email protected]:8332/'); $newAddress = $bitcoin->getnewaddress(); print_r($newAddress); Personally I use the easybitcoin library, it works better and is easier to use in my opinion.
Michael Schramm (3 years ago)
Hi this is my conf listen=1 server=1 rpcuser=bachel rpcpassword=Schrammling95 and this my php <?php require_once('easybitcoin.php'); $bitcoin = new Bitcoin('bachel','Schrammling95'); $getinfo = $bitcoin->getinfo(); print_r($getinfo); ?> and still getting the 500 error easybitcoin.php is in the same folder as the php also when i try to get info via the command line it says wrong rpc user
look chmod :p
Alireza Beikverdi (2 years ago)
+m1xolyd1an sure yea i know that. I can make a REST api on top of that. I just wanted to simply use json rpc for efficiency and better performance on my client. Ill tip you some btc. Keep up the good work dude.
m1xolyd1an (2 years ago)
+Alireza Beikverdi or you can create custom php pages for each rpc command and use gets. for example getnewaddress.php could call the get new address function and return the output in json. That way you could hit it from another server and if needed any special fields you do with a GET like gettransacion.php?txid=4jdbj4ndbfb
Alireza Beikverdi (2 years ago)
+m1xolyd1an sure, i noticed that when you mentioned it in the other video. So I always have to build my api on the same server thats running my bitcoind?
m1xolyd1an (2 years ago)
+Alireza Beikverdi it's recommended by the developers that you do not as it is not encrypted. You can take a look at rpcallowip.

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.