Skip to content

Instantly share code, notes, and snippets.

@ryandotsmith
Created March 17, 2015 21:11
Show Gist options
  • Save ryandotsmith/3c4e44b738e9b625a784 to your computer and use it in GitHub Desktop.
Save ryandotsmith/3c4e44b738e9b625a784 to your computer and use it in GitHub Desktop.
Sending a transaction in the browser
<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<p>Balance: <span id="balance"></span></p>
</body>
<script type="text/javascript">
var api_key_id = '[redacted]';
var url = 'https://api.chain.com/v2/bitcoin/transactions/send';
$.ajax({
type: 'POST',
url: url,
headers: {"Authorization": "Basic " + btoa(api_key_id)},
contentType: 'application/json',
processData: false,
data: JSON.stringify({"signed_hex": "[redacted]"}),
success: function(response) {
console.log(response);
},
error: function(err) {
console.log(err);
},
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment