Skip to content

Instantly share code, notes, and snippets.

@AaronGoldsmith1
Last active November 4, 2016 21:41
Show Gist options
  • Save AaronGoldsmith1/367d8c7d3d60eaf60c499d5db2ed8618 to your computer and use it in GitHub Desktop.
Save AaronGoldsmith1/367d8c7d3d60eaf60c499d5db2ed8618 to your computer and use it in GitHub Desktop.
Project 2 code snippet

This section of code uses the HTTParty gem to query the bitcoin blockchain using the Blockchain.info API.
I had a lot of fun working with this gem, and I'm looking forward to working with other APIs in the future! I would also like to find a way to use the Blockchain.info to calculate the total transcation fees associated with an individual bitcoin addres.

  begin
        @response = HTTParty.get('https://blockchain.info/address/'+@address.loc+'?format=json')
        @BTC = @response.parsed_response['final_balance']/100000000.0
        @total_received = @response.parsed_response['total_received']/100000000.0
        @total_sent = @response.parsed_response['total_sent']/100000000.0
  
        #@total_fees = .each +=
  rescue
        @BTC = "Invalid Address"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment