How to send bitcoins without the bitcoin client in PHP

0

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

Freeman 123

Posted 2018-06-29T10:44:26.890

Reputation: 1

Answers

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.

Fuzzybear

Posted 2018-06-29T10:44:26.890

Reputation: 447

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 2018-06-29T14:43:12.373

It seems that you do need to run a service locally to get the blockchain API up and running https://www.blockchain.com/api/blockchain_wallet_api Need to setup this https://github.com/blockchain/service-my-wallet-v3

Fuzzybear 2018-06-29T14:57:22.557