Exemplo n.º 1
0
 internal BlockchainOperation(
     BlockchainOperationId id,
     IWeb3 web3,
     ConfirmationLevel minimalConfirmationLevel = default)
 {
     _minimalConfirmationLevel = minimalConfirmationLevel;
     _web3 = web3;
     Id    = id;
 }
Exemplo n.º 2
0
        protected async Task <BlockchainOperation> SendTransactionAsync <TParameters>(
            Address from,
            TransactionDefinition <TParameters> transactionDefinition,
            ConfirmationLevel minimalConfirmationLevel)
            where TParameters : TransactionDefinition <TParameters>, new()
        {
            var transactionInput = await Web3.Eth
                                   .GetContractTransactionHandler <TParameters>()
                                   .CreateTransactionInputEstimatingGasAsync
                                   (
                ContractAddress,
                (TParameters)transactionDefinition
                                   );

            transactionInput.From     = from;
            transactionInput.GasPrice = new HexBigInteger(await EstimateGasPriceStrategy.ExecuteAsync());

            string transactionHash;

            if (Web3.TransactionManager.Account != null)
            {
                var signedTransaction = await Web3.TransactionManager
                                        .SignTransactionAsync(transactionInput);

                transactionHash = await Web3.Eth.Transactions
                                  .SendRawTransaction
                                  .SendRequestAsync(signedTransaction);
            }
            else
            {
                transactionHash = await Web3.Eth.Transactions
                                  .SendTransaction
                                  .SendRequestAsync(transactionInput);
            }

            var blockchainOperationId = BlockchainOperationId.Parse(transactionHash);

            return(new BlockchainOperation(blockchainOperationId, Web3, minimalConfirmationLevel));
        }
Exemplo n.º 3
0
 public IBlockchainOperation GetOperation(
     BlockchainOperationId operationId,
     ConfirmationLevel minimalConfirmationLevel = default)
 {
     return(new BlockchainOperation(operationId, _web3, minimalConfirmationLevel));
 }