Skip to content

Instantly share code, notes, and snippets.

@ryandotsmith
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryandotsmith/2cb44e5b0442e321779f to your computer and use it in GitHub Desktop.
Save ryandotsmith/2cb44e5b0442e321779f to your computer and use it in GitHub Desktop.
An example for how to authenticate against Chain using CORS
<!doctype html>
<html>
<head>
<script src="http://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">
$(document).ready(function() {
var addr = window.location.hash.split('#').pop();
var url = 'https://api.chain.com/v1/bitcoin';
url += '/addresses/' + addr;
url += '?key=GUEST-TOKEN';
$.ajax({
url: url,
type: 'GET',
success: function(data) {
$('#balance').text(data.balance);
},
error: function(req, msg, err) {
console.log(err);
}
});
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment