Skip to content

Instantly share code, notes, and snippets.

@Anderson-Juhasc
Last active April 9, 2022 01:24
Show Gist options
  • Save Anderson-Juhasc/65e9e8256e5c7202a0871398162ec162 to your computer and use it in GitHub Desktop.
Save Anderson-Juhasc/65e9e8256e5c7202a0871398162ec162 to your computer and use it in GitHub Desktop.
CriptoApp
<?php
require __DIR__ . '/vendor/autoload.php';
use \Blocktrail\SDK\BlocktrailSDK;
$client = new BlocktrailSDK("api_key", "secret", "BTC", true /* testnet */);
$wallet = $client->initWallet("wallet_name", "password");
$address = $wallet->getNewAddress();
$btc_amount = 0.15;
?>
<p>
<a href="bitcoin:<?php echo $address; ?>?amount=<?php echo $btc_amount; ?>"><?php echo $address; ?></a>
</p>
<img src="https://api.qrserver.com/v1/create-qr-code/?size=180x180&data=bitcoin:<?php echo $address; ?>?amount=<?php echo $btc_amount; ?>" alt="" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pusher/2.1.6/pusher.min.js"></script>
<script>
Pusher.host = 'slanger1.chain.so'; // our server
Pusher.ws_port = 443; // our server's port
Pusher.wss_port = 443; // ...
// create the pusher client connection
var pusher = new Pusher('e9f5cc20074501ca7395', { encrypted: true, disabledTransports: ['sockjs'], disableStats: true });
// subscribe to the channel for address balance updates (new transactions only)
var ticker = pusher.subscribe('address_btctest_<?php echo $address; ?>');
ticker.bind('balance_update', function(data) {
if (data.type == "address") {
console.log("Transação recebida:", data);
}
});
</script>
@muraad33
Copy link

muraad33 commented Apr 9, 2022

H

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment