Skip to content

Instantly share code, notes, and snippets.

@juanfranblanco
Created March 26, 2018 18:03
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 juanfranblanco/c05b96bee4819762806dc80ff0ca10f1 to your computer and use it in GitHub Desktop.
Save juanfranblanco/c05b96bee4819762806dc80ff0ca10f1 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Security.Principal;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using Nethereum.Hex.HexTypes;
using Nethereum.Web3;
using Nethereum.Web3.Accounts;
namespace TestWebService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "TestService" in code, svc and config file together.
// NOTE: In order to launch WCF Test Client for testing this service, please select TestService.svc or TestService.svc.cs at the Solution Explorer and start debugging.
public class TestService : ITestService
{
public void DoWork()
{
var hash = new HashStoreService().StoreHash().Result;
}
}
public class HashStoreService
{
public async Task<string> StoreHash()
{
var web3 = new Web3(new Account("0xb3d7d06a45d2ae2b39f7296af2b03b02ad034b47e3660554ddb440f0610c37b7"),
"https://ropsten.infura.io/pL7x9kxoWf5F4mzkeZ3q");
var abi =
"[{'constant':false,'inputs':[{'name':'inHashString','type':'string'},{'name':'inDescription','type':'string'},{'name':'inSubmitDate','type':'string'}],'name':'storeHash','outputs':[],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':true,'inputs':[],'name':'getStoredDescription','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':true,'inputs':[],'name':'getSubmittedDate','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':true,'inputs':[],'name':'getTransactionDate','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':true,'inputs':[],'name':'getStoredHash','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'}]";
var contract = web3.Eth.GetContract(abi, "0xae4b966957a88afb9fba84359014936520c68e7d");
var function = contract.GetFunction("storeHash");
var transactionHash = await function.SendTransactionAsync("0xf558e0532b817903b980bfd1164101aecb5c5368"
, new HexBigInteger(900000)
, new HexBigInteger(0)
, "Test"
, "Something"
, "1/1/2018");
return transactionHash;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment