Created
March 17, 2015 21:11
-
-
Save ryandotsmith/3c4e44b738e9b625a784 to your computer and use it in GitHub Desktop.
Sending a transaction in the browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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