Esempio n. 1
0
        public async Task <AddNewTemplateServiceResponse> Handle(AddNewTemplateServiceRequest aAddNewTemplateServiceRequest, CancellationToken aCancellationToken)
        {
            Function <AddNewTemplateFunctionInput> aAddNewTemplateFunction = NftCreatorInstance.Instance.GetFunction <AddNewTemplateFunctionInput>();

            Nethereum.Contracts.ContractHandlers.IContractTransactionHandler <AddNewTemplateFunctionInput> addNewTemplateFunctionHandler = NethWeb3.Instance.Eth.GetContractTransactionHandler <AddNewTemplateFunctionInput>();

            var aAddNewTemplateFunctionMessage = new AddNewTemplateFunctionInput
            {
                NewTemplateName           = aAddNewTemplateServiceRequest.NewTemplateName,
                NewTemplateSymbol         = aAddNewTemplateServiceRequest.NewTemplateSymbol,
                NewTemplateAttachedTokens = aAddNewTemplateServiceRequest.NewTemplateAttachedTokens,
                NewTemplateMintLimit      = aAddNewTemplateServiceRequest.NewTemplateMintLimit
            };

            // Gas Estimates, needs to be tested

            Nethereum.Hex.HexTypes.HexBigInteger gasEstimate = await addNewTemplateFunctionHandler.EstimateGasAsync(NftCreatorAddresses.NewNftCreatorRopstenAddress, aAddNewTemplateFunctionMessage);

            aAddNewTemplateFunctionMessage.Gas = gasEstimate.Value;

            Nethereum.RPC.Eth.DTOs.TransactionReceipt mintingTransactionReceipt = await addNewTemplateFunctionHandler.SendRequestAndWaitForReceiptAsync(NftCreatorAddresses.NewNftCreatorRopstenAddress, aAddNewTemplateFunctionMessage);

            return(new AddNewTemplateServiceResponse
            {
                NewTemplateTransactionReceipt = mintingTransactionReceipt
            });
        }
Esempio n. 2
0
        public async Task <MintNftOfTypeServiceResponse> Handle(MintNftOfTypeServiceRequest aMintNftOfTypeServiceRequest, CancellationToken aCancellationToken)
        {
            Function <MintNftOfTypeFunctionInput> aMintNftOfTypeFunction = NftCreatorInstance.Instance.GetFunction <MintNftOfTypeFunctionInput>();

            Nethereum.Contracts.ContractHandlers.IContractTransactionHandler <MintNftOfTypeFunctionInput> mintingHandler = NethWeb3.Instance.Eth.GetContractTransactionHandler <MintNftOfTypeFunctionInput>();
            // serialization needed

            var aMintNftOfTypeFunctionMessage = new MintNftOfTypeFunctionInput
            {
                NftId = aMintNftOfTypeServiceRequest.MintNftId,
                ImmutableDataString = aMintNftOfTypeServiceRequest.ImmutableDataString,
                MutableDataString   = aMintNftOfTypeServiceRequest.MutableDataString == null ? "" : aMintNftOfTypeServiceRequest.MutableDataString
            };

            Nethereum.Hex.HexTypes.HexBigInteger gasEstimate = await mintingHandler.EstimateGasAsync(NftCreatorAddresses.NewNftCreatorRopstenAddress, aMintNftOfTypeFunctionMessage);

            aMintNftOfTypeFunctionMessage.Gas = gasEstimate.Value;

            Nethereum.RPC.Eth.DTOs.TransactionReceipt mintingTransactionReceipt = await mintingHandler.SendRequestAndWaitForReceiptAsync(NftCreatorAddresses.NewNftCreatorRopstenAddress, aMintNftOfTypeFunctionMessage);

            System.Collections.Generic.List <EventLog <MintNftOutputEventDto> > MintNftOutput = mintingTransactionReceipt.DecodeAllEvents <MintNftOutputEventDto>();

            int id = (int)MintNftOutput[0].Event.Id;

            return(new MintNftOfTypeServiceResponse
            {
                TransactionHash = mintingTransactionReceipt.TransactionHash,
                TokenId = id,
                GasUsed = new HexBigInteger(mintingTransactionReceipt.GasUsed.Value)
            });
        }