0

Is there a way to send bitcoins programmatically without the bitcoin client using PHP?

0

You will need to connect to a bitcoin node in one way or another to broardcast to the newtork. There are a number of php and bitcoin open source repos that will do this, have a look here https://github.com/search?q=bitcoind+php&ref=cmdform

Another option if you do not want to run the bitcoin client locally is to connect to an api to broadcast your transaction.

An example I found for php connecting to blockchain.info is as follows

<?php

$guid="GUID_HERE";
$firstpassword="PASSWORD_HERE";
$secondpassword="PASSWORD_HERE";
$amounta = "10000000";
$amountb = "400000";
$addressa = "1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq";
$addressb = "1ExD2je6UNxL5oSu6iPUhn9Ta7UrN8bjBy";
$recipients = urlencode('{
              "'.$addressa.'": '.$amounta.',
              "'.$addressb.'": '.$amountb.'
           }');

$json_url = "http://blockchain.info/merchant/$guid/sendmany?password=$firstpassword&second_password=$secondpassword&recipients=$recipients";

$json_data = file_get_contents($json_url);

$json_feed = json_decode($json_data);

$message = $json_feed->message;
$txid = $json_feed->tx_hash;

?>

Hope this helps

UPDATE: To run requests to the blockchain.info API you need to follow the setup instructions here https://www.blockchain.com/api/blockchain_wallet_api

NOTE To use this API, you will need to run small local service which be responsible for managing your Blockchain Wallet. Your application interacts with this service locally via HTTP API calls. Click here for complete setup instructions on GitHub.

  • I'm getting NULL as response And when trying with the url in browser: blockchain.com/merchant/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx/sendmany?password=xxxxxxx&recipients=1G2muzzGkogHKGCTi5MJeXQVDiArALmjoP+600 I'm getting the error message: "We can't seem to find the page you're looking for" – Freeman 123 Jun 29 '18 at 14:43
  • It seems that you do need to run a service locally to get the blockchain API up and running blockchain.com/api/blockchain_wallet_api Need to setup this github.com/blockchain/service-my-wallet-v3 – Fuzzybear Jun 29 '18 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.