Using a Bitcoin transaction to trigger an event

Hi,

I would like to use a spark core to poll for a bitcoin transaction and then flip a digital switch each time a new transaction is detected.

I am using coinbase.com as my online bitcoin wallet. Coinbase offers a merchant service that you can configure to send transaction notifications to a website. So, I have two initial questions:

  1. Can the spark cloud serve as the ‘website’ in this scenario?

  2. Is there sample code available to demonstrate how I would poll the cloud to determine when new transactions appear?

Thanks,

Darryl

Coinbase sends a json file that the spark cloud isn’t going to be able to know what to do with. You’re going to have to have something in between coindbase and the spark cloud that takes the json from coinbase and hits the cloud api with the details. Do you have a webserver somewhere?

Thanks for the quick reply. Unfortunately I do not currently have access to a web server that would be consistently online and available. I’ll need to investigate my options here…

Darryl

Perhaps you can use the TCP Server library on the Spark Core, and forward a port on your router so that Coinbase may interface with it directly? There have been some TCP Server examples on the forum, and docs are here: http://docs.spark.io/#/firmware/communication-tcpserver

I wonder if there are any online services that you could post json to, and it would transform it and post it to the cloud… I remember hearing something similar a while ago…

@dadamspdx I just remember seeing such a service. I haven’t played with it much but you might be able to create your middleware peice that sends your coinbase transaction to the spark core using zapier.com. Create a new zap and use the webhook to create an endpoint for coinbase to send the transaction data to. I’m sure there’s an event that you can trigger to send certain data to the spark cloud api when the coinbase webhook is triggered. No hosting needed!

I’ll play around with it and see if I can come up with something, but that might get you started.

EDIT: I just confirmed you can do this with zapier. I even tested it with coinbase. Setup a webhook trigger that coinbase sends data to and then use another webhook to send the appropriate data to the spark cloud. Pretty nice actually!

1 Like

Sounds like this service could be used for many different situations.

Can you give some info about webhook triggers and sending data to the Spark Cloud? Maybe another thread if Zapier is a good solution for getting data to the Spark through the web.

Yeah, when I get home tonight, I’ll create a walkthrough w/ screenshots and post it in a new thread.

Awesome! Thanks so much!

@Hypnopompia’s suggestion about zapier is a great one, but if you want to get deeper in the code, Heroku is a great service for quickly deploying web apps, and it’s often free, if you’re not doing anything crazy

Thanks all for the feedback! I took a look at Zapier, and it is definitely a cool service for creating simple integrations. One limitation is that the service only runs every 15 minutes so it is not the best solution to facilitate transactions that need to be closer to real-time.

Another approach could be to get the bitcoin transaction data directly from the block chain rather than from Coinbase. Since every bitcoin transaction is pblically logged in the block chain this should be feasible. Using blockexplorer.com I can create an RSS feed to alert me whenever my public wallet address appears in the block chain. (http://blockexplorer.com/rssa/1Ak5sBSviRxmiLoYpbxbhietKbGqaJv7VG.xml)

Is there a documented method for dealing with RSS with the Spark API?

Darryl

I'm looking for this info also. I want to pull weather data from a Weather RSS feed but I have no idea how to do it.

I am parsing RSS feeds but my code is old-fashioned strtok() C code, so it could be hard to understand and use. I think a lot of Arduino folks would use String class, which would be easier.

There was this recently:

which looks very promising!

1 Like

@RWB

2 Likes

@RWB @dadamspdx I should mention that Zapier can handle RSS feeds as your trigger as well. It should be a very similar process to the bitcoin tutorial, except zapier watches an RSS feed for new items instead of waiting for a POST from a web service.

Thanks.

I see that you can import XML data directly into Excel Spreadsheets but the examples I was trying didn’t work and other had issues with it. I know I can pull weather data in the same way I’m pulling Spark Data so Zapier may be the way to go for weather data.