Discuss Scratch
- Discussion Forums
- » Developing Scratch Extensions
- » Trying to make Dogecoin extension, need help
- coolgem923
-
100+ posts
Trying to make Dogecoin extension, need help
Hey everyone,
I'm trying to make an extension that would check the confirmed balance of a Dogecoin address using the chain.so blockchain api, but so far I have little luck.
I'm trying to combine the ScratchX Weather API example here with the get balance API example here.
So when I import the extension into ScratchX, I get the
What am I doing wrong?
I'm trying to make an extension that would check the confirmed balance of a Dogecoin address using the chain.so blockchain api, but so far I have little luck.
I'm trying to combine the ScratchX Weather API example here with the get balance API example here.
So when I import the extension into ScratchX, I get the
(balance [address])block I add, but it never returns any output.
What am I doing wrong?
(function(ext) {
// Cleanup function when the extension is unloaded
ext._shutdown = function() {};
// Status reporting code
// Use this to report missing hardware, plugin or unsupported browser
ext._getStatus = function() {
return {status: 2, msg: 'Ready'};
};
ext.getbalance = function(location, callback) {
// Make an AJAX call to the Chain.so API
$.ajax({
url: 'https://chain.so/api/v2/get_address_balance/DOGE/' & location & '/0',
dataType: 'jsonp',
success: function( balance_data ) {
// Got the data - parse it and return the confirmed balance
status = balance_data['status'];
balance = balance_data['data']['confirmed_balance'];
callback(status);
}
});
};
// Block and block menu descriptions
var descriptor = {
blocks: [
['R', 'balance %s', 'getbalance', 'address'],
]
};
// Register the extension
ScratchExtensions.register('Dogecoin', descriptor, ext);
})({});
Last edited by coolgem923 (May 16, 2016 18:46:13)
- NickyNouse
-
1000+ posts
Trying to make Dogecoin extension, need help
I'm not too familiar with the extension API yet but it looks like you should be doing callback(balance)
- Discussion Forums
- » Developing Scratch Extensions
-
» Trying to make Dogecoin extension, need help