public static async Task <ICitizenAttestationRepository> ConstructCitizenAttestationRepositoryWithNewContract(
            string url, string contractOwnerPrivateKey)
        {
            Account account = new Account(contractOwnerPrivateKey);
            Web3    web3    = new Web3(account, url);

            var deployment = new CitizenAttestationsDeployment();
            var receipt    = await CitizenAttestationsService.DeployContractAndWaitForReceiptAsync(web3, deployment);

            CitizenAttestationsService citizenAttestationsService = new CitizenAttestationsService(web3, receipt.ContractAddress);

            return(new CitizenAttestationRepository(citizenAttestationsService, receipt.ContractAddress));
        }
Ejemplo n.º 2
0
        static async Task Demo()
        {
            var url                  = "http://localhost:7545";
            var privateKey           = "7c567d23f12d9e68d4a9783f90b417272c803e8eb4dc5d8387bca3904868734d";
            var citizenPublicAddress = "0x1100B250349B71F2629249bB6414790AE2bEe5F7";
            var account              = new Account(privateKey);
            var web3                 = new Web3(account, url);

            var deployment = new CitizenAttestationsDeployment();
            var receipt    = await CitizenAttestationsService.DeployContractAndWaitForReceiptAsync(web3, deployment);

            var service = new CitizenAttestationsService(web3, receipt.ContractAddress);

            Console.WriteLine($"Contract Deployment Tx Status: {receipt.Status.Value}");
            Console.WriteLine($"Contract Address: {service.ContractHandler.ContractAddress}");
            Console.WriteLine("");

            // signing message
            string message   = "COVID19";
            var    signer    = new MessageSigner();
            var    signature = signer.HashAndSign(message, privateKey);

            Console.WriteLine($"Message: {message}");
            Console.WriteLine($"Signature: {signature}");
            Console.WriteLine("");

            // Write signed mesage
            string attestationId     = Guid.NewGuid().ToString();
            var    attestationIssuer = "0x77C5e60b0b7b7d6bD9bb06ED89d77723C06eEcaa";

            //var addReceipt = await service.AddAttestationSignatureRequestAndWaitForReceiptAsync(attestationId, attestationIssuer, signature);

            //Console.WriteLine($"Contract Deployment Tx Status: {addReceipt.Status.Value}");
            Console.WriteLine("");
            Console.ReadKey();
        }
        public static async Task <CitizenAttestationsService> DeployContractAndGetServiceAsync(Nethereum.Web3.Web3 web3, CitizenAttestationsDeployment citizenAttestationsDeployment, CancellationTokenSource cancellationTokenSource = null)
        {
            var receipt = await DeployContractAndWaitForReceiptAsync(web3, citizenAttestationsDeployment, cancellationTokenSource);

            return(new CitizenAttestationsService(web3, receipt.ContractAddress));
        }
 public static Task <string> DeployContractAsync(Nethereum.Web3.Web3 web3, CitizenAttestationsDeployment citizenAttestationsDeployment)
 {
     return(web3.Eth.GetContractDeploymentHandler <CitizenAttestationsDeployment>().SendRequestAsync(citizenAttestationsDeployment));
 }
 public static Task <TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.Web3 web3, CitizenAttestationsDeployment citizenAttestationsDeployment, CancellationTokenSource cancellationTokenSource = null)
 {
     return(web3.Eth.GetContractDeploymentHandler <CitizenAttestationsDeployment>().SendRequestAndWaitForReceiptAsync(citizenAttestationsDeployment, cancellationTokenSource));
 }