Skip to content

Instantly share code, notes, and snippets.

@ryandotsmith
Created Mar 17, 2015
Embed
What would you like to do?
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