I'm running a website on ASP.NET C# and it's connected to a MSSQL Database . What I want to do is when people send BTC to an address (I don't really care if the care is the same or keep generating new one each time) , so once they send BTC .. I want to execute a MSSQL Query into my database to give them some sort of points etc ... ? Who think he can help on this task pls
3 ways, in order of ease:
You will have to write a service, worker processor etc to poll the address looking for new transactions.
1. Use Blockchain.info. They have a nugget package and good enough for small transactions, but you're trusting them to report correct:
public ActionResult Wallet()
{
ViewBag.Address = System.Configuration.ConfigurationManager.AppSettings["WalletAddress"];
Info.Blockchain.API.BlockExplorer.BlockExplorer ex = new Info.Blockchain.API.BlockExplorer.BlockExplorer();
var address = ex.GetAddress(System.Configuration.ConfigurationManager.AppSettings["WalletAddress"]);
Decimal amount = Convert.ToDecimal(address.FinalBalance / 100000000.0M);
String balance = String.Format("{0:0.######}", amount);
ViewBag.Balance = balance;
return View();
}
2. Same approach, but poll your own bitcoind instance. There are a few .net wrappers for bitcoind.
- Have a server running bitcoind in server mode
- Set the credentials and configs and firewalls up
- Use JSON RPC calls (web client will do) to query an address that bitcoind hosts
3. Roll your own blockchain passer and keep updating it. There are a few .net ones out there, but too much over kill for a few tx a day.
Hope this helps.