Exemplo n.º 1
0
 public CallInput(string data, HexBigInteger gas, string addressFrom)
 {
    
     this.Data = data;
     this.Gas = gas;
     this.From = addressFrom;
 }
        public virtual void ShouldDecode08ac7230489e80000()
        {
            var encode = new HexBigInteger(BigInteger.Parse("10000000000000000000"));
            var x = new HexBigInteger("0x8ac7230489e80000");
            Assert.Equal(encode.Value.ToString(), x.Value.ToString());


        }
 public virtual void EncodingDecodingRandom10000Test()
 {
     var random = new Random();
     
     for (int i = 0; i < 10000; i++)
     {
         var number = random.Next(0, 100000);
         var value = i* number + "000000000000";
         var encode = new HexBigInteger(BigInteger.Parse(value)); 
        Assert.Equal(encode.Value.ToString(), new HexBigInteger(encode.HexValue).Value.ToString());
     }   
 }
Exemplo n.º 4
0
        public async Task <string> RemoveAttributeAsync(byte[] key, HexBigInteger gasPrice = null, HexBigInteger valueAmount = null)
        {
            var    function = GetFunctionRemoveAttribute();
            string data     = function.GetData(key);

            return(await _transactionService.SignAndSendTransaction(data, contract.Address, valueAmount, gasPrice));
        }
Exemplo n.º 5
0
 public TransactionInput(string data, string addressTo, HexBigInteger value) : base(data, addressTo, value)
 {
 }
Exemplo n.º 6
0
        public async Task <BigInteger> GetBalanceInWei(IAccount account)
        {
            HexBigInteger balance = await Web3Instance(account).Eth.GetBalance.SendRequestAsync(account.Address);

            return(balance.Value);
        }
Exemplo n.º 7
0
        public async Task <string> AddCertificateAsync(string attr, string cert, HexBigInteger gasPrice = null, HexBigInteger valueAmount = null)
        {
            var    function = GetFunctionAddCertificate();
            string data     = function.GetData(attr, cert);

            return(await _transactionService.SignAndSendTransaction(data, contract.Address, valueAmount, gasPrice));
        }
Exemplo n.º 8
0
 public void SetValue(HexBigInteger blockNumber)
 {
     ParameterType = BlockParameterType.blockNumber;
     BlockNumber = blockNumber;
 }
Exemplo n.º 9
0
 public Task <string> SendRequestAsync(HexBigInteger type, string contractByteCode, string from,
                                       HexBigInteger gas, HexBigInteger maxFeePerGas, HexBigInteger maxPriorityFeePerGas, HexBigInteger value, HexBigInteger nonce)
 {
     return(TransactionManager.SendTransactionAsync(new TransactionInput(type, contractByteCode, null, from, gas,
                                                                         value, maxFeePerGas, maxPriorityFeePerGas)));
 }
Exemplo n.º 10
0
        public Task <TransactionReceipt> SendRequestAndWaitForReceiptAsync <TConstructorParams>(HexBigInteger type, string contractByteCode, string from,
                                                                                                HexBigInteger gas, HexBigInteger maxFeePerGas, HexBigInteger maxPriorityFeePerGas, HexBigInteger value, HexBigInteger nonce, TConstructorParams inputParams, CancellationTokenSource receiptRequestCancellationToken = null)
        {
            var transaction =
                _deployContractTransactionBuilder.BuildTransaction(type, contractByteCode, from, gas, maxFeePerGas, maxPriorityFeePerGas, value, nonce,
                                                                   inputParams);

            return(TransactionManager.TransactionReceiptService.DeployContractAndWaitForReceiptAsync(transaction,
                                                                                                     receiptRequestCancellationToken));
        }
 public virtual void ShouldDecodeCompactNoTraillingZeros()
 {
     var x = new HexBigInteger("0x400");
     Assert.Equal(1024, x.Value); 
 }
Exemplo n.º 12
0
        public Task <TransactionReceipt> SendRequestAndWaitForReceiptAsync(string abi, string contractByteCode,
                                                                           string from, HexBigInteger gas, HexBigInteger gasPrice,
                                                                           HexBigInteger value, CancellationTokenSource receiptRequestCancellationToken = null,
                                                                           params object[] values)
        {
            var transaction =
                _deployContractTransactionBuilder.BuildTransaction(abi, contractByteCode, from, gas, gasPrice, value,
                                                                   values);

            return(TransactionManager.TransactionReceiptService.DeployContractAndWaitForReceiptAsync(transaction,
                                                                                                     receiptRequestCancellationToken));
        }
Exemplo n.º 13
0
 public Task <TransactionReceipt> SendRequestAndWaitForReceiptAsync(string contractByteCode, string from,
                                                                    HexBigInteger gas, HexBigInteger value, CancellationTokenSource receiptRequestCancellationToken = null)
 {
     _deployContractTransactionBuilder.EnsureByteCodeDoesNotContainPlaceholders(contractByteCode);
     return(TransactionManager.TransactionReceiptService.DeployContractAndWaitForReceiptAsync(
                new TransactionInput(contractByteCode, null, from, gas, value), receiptRequestCancellationToken));
 }
Exemplo n.º 14
0
        public Task <string> SendRequestAsync <TConstructorParams>(HexBigInteger type, string contractByteCode, string from,
                                                                   HexBigInteger gas, HexBigInteger maxFeePerGas, HexBigInteger maxPriorityFeePerGas, HexBigInteger value, HexBigInteger nonce, TConstructorParams inputParams)
        {
            var transaction =
                _deployContractTransactionBuilder.BuildTransaction(type, contractByteCode, from, gas, maxFeePerGas, maxPriorityFeePerGas, value, nonce,
                                                                   inputParams);

            return(TransactionManager.SendTransactionAsync(transaction));
        }
Exemplo n.º 15
0
        public Task <string> SendRequestAsync <TConstructorParams>(string contractByteCode, string from,
                                                                   HexBigInteger gas, HexBigInteger gasPrice, HexBigInteger value, TConstructorParams inputParams)
        {
            var transaction =
                _deployContractTransactionBuilder.BuildTransaction(contractByteCode, from, gas, gasPrice, value,
                                                                   inputParams);

            return(TransactionManager.SendTransactionAsync(transaction));
        }
Exemplo n.º 16
0
 public Task <string> SendRequestAsync(string contractByteCode, string from, HexBigInteger gas,
                                       HexBigInteger value)
 {
     return(TransactionManager.SendTransactionAsync(new TransactionInput(contractByteCode, null, from, gas,
                                                                         value)));
 }
Exemplo n.º 17
0
 public TransactionInput(string data, HexBigInteger gas, string adddressFrom) : base(data, gas, adddressFrom)
 {
 }
Exemplo n.º 18
0
        public Task <HexBigInteger> EstimateGasAsync <TConstructorParams>(string contractByteCode, string from,
                                                                          HexBigInteger gas, HexBigInteger value,
                                                                          TConstructorParams inputParams)
        {
            var callInput =
                _deployContractTransactionBuilder.BuildTransaction(contractByteCode, from, gas, null, value,
                                                                   inputParams);

            return(TransactionManager.EstimateGasAsync(callInput));
        }
 public virtual void ShouldEncode0as0x0()
 {
     var x = new HexBigInteger(new BigInteger(0));
     Assert.Equal("0x0", x.HexValue);
 }
Exemplo n.º 20
0
        public Task <string> SendRequestAsync(string abi, string contractByteCode, string from, HexBigInteger gas,
                                              HexBigInteger gasPrice,
                                              HexBigInteger value,
                                              params object[] values)
        {
            var transaction =
                _deployContractTransactionBuilder.BuildTransaction(abi, contractByteCode, from, gas, gasPrice, value,
                                                                   values);

            return(TransactionManager.SendTransactionAsync(transaction));
        }
Exemplo n.º 21
0
 public BlockParameter(HexBigInteger blockNumber)
 {
     SetValue(blockNumber);
 }
        public void GetBlocksWithTransactionHashes()
        {
            // Setup.
            var sched  = new TestScheduler();
            var poller = sched.CreateColdObservable(
                OnNext(100, Unit.Default),
                OnNext(200, Unit.Default));

            var filterService      = new Mock <IEthApiFilterService>();
            var transactionService = new Mock <IEthApiTransactionsService>();

            var provider = new PendingTransactionStreamProvider(
                poller,
                filterService.Object,
                transactionService.Object);

            var filterId = new HexBigInteger(1337);

            filterService
            .Setup(x => x.NewPendingTransactionFilter.SendRequestAsync(null))
            .Returns(Task.FromResult(filterId));

            filterService
            .Setup(x => x.UninstallFilter.SendRequestAsync(filterId, null))
            .Returns(Task.FromResult(true));

            // Setup incoming pending transactions.
            var expectedTransactions = new[]
            {
                new[]
                {
                    new Transaction
                    {
                        TransactionHash = "0x1"
                    }
                },
                new[]
                {
                    new Transaction
                    {
                        TransactionHash = "0x2"
                    },
                    new Transaction
                    {
                        TransactionHash = "0x3"
                    }
                }
            };

            filterService.SetupSequence(x => x.GetFilterChangesForBlockOrTransaction.SendRequestAsync(filterId, null))
            .Returns(Task.FromResult(new[]
            {
                expectedTransactions[0][0].TransactionHash
            }))
            .Returns(Task.FromResult(new[]
            {
                expectedTransactions[1][0].TransactionHash, expectedTransactions[1][1].TransactionHash
            }));

            transactionService.Setup(x => x.GetTransactionByHash.SendRequestAsync(expectedTransactions[0][0].TransactionHash, null))
            .Returns(Task.FromResult(expectedTransactions[0][0]));
            transactionService.Setup(x => x.GetTransactionByHash.SendRequestAsync(expectedTransactions[1][0].TransactionHash, null))
            .Returns(Task.FromResult(expectedTransactions[1][0]));
            transactionService.Setup(x => x.GetTransactionByHash.SendRequestAsync(expectedTransactions[1][1].TransactionHash, null))
            .Returns(Task.FromResult(expectedTransactions[1][1]));

            // Record incoming data.
            var res = sched.Start(() => provider.GetPendingTransactions());

            res.Messages.AssertEqual(
                OnNext(100 + Subscribed, expectedTransactions[0][0]),
                OnNext(200 + Subscribed, expectedTransactions[1][0]),
                OnNext(200 + Subscribed, expectedTransactions[1][1]));

            filterService.Verify(x => x.NewPendingTransactionFilter.SendRequestAsync(null), Times.Once);
            filterService.Verify(x => x.UninstallFilter.SendRequestAsync(filterId, null), Times.Once);
        }
Exemplo n.º 23
0
 public CallInput(string data, string addressTo, string adddressFrom, HexBigInteger gas, HexBigInteger value) : this(data, addressTo, value)
 {
     this.From = adddressFrom;
     this.Gas = gas;
 }
Exemplo n.º 24
0
        public Task <string> InvalidateNameAsync(string addressFrom, string unhashedName, HexBigInteger gas = null,
                                                 HexBigInteger valueAmount = null)
        {
            var function = GetFunctionInvalidateName();

            return(function.SendTransactionAsync(addressFrom, gas, valueAmount, unhashedName));
        }
Exemplo n.º 25
0
 public CallInput(string data, string adddressFrom, HexBigInteger gas, HexBigInteger value)
     : this(data, null, value)
 {
     From = adddressFrom;
     Gas = gas;
 }
Exemplo n.º 26
0
        public Task <string> StartAuctionsAsync(string addressFrom, byte[][] _hashes, HexBigInteger gas = null,
                                                HexBigInteger valueAmount = null)
        {
            var function = GetFunctionStartAuctions();

            return(function.SendTransactionAsync(addressFrom, gas, valueAmount, _hashes));
        }
Exemplo n.º 27
0
        public async Task <string> CreateCertificateAsync(string _location, string _hash, string _owningAttribute, HexBigInteger gasPrice = null, HexBigInteger valueAmount = null)
        {
            var    function = GetFunctionCreateCertificate();
            string data     = function.GetData(_location, _hash, _owningAttribute);

            return(await _transactionService.SignAndSendTransaction(data, contract.Address, valueAmount, gasPrice));
        }
Exemplo n.º 28
0
        public Task <string> TransferRegistrarsAsync(string addressFrom, byte[] _hash, HexBigInteger gas = null,
                                                     HexBigInteger valueAmount = null)
        {
            var function = GetFunctionTransferRegistrars();

            return(function.SendTransactionAsync(addressFrom, gas, valueAmount, _hash));
        }
Exemplo n.º 29
0
        public async Task <string> ChangeOwnerAsync(string newOwner, HexBigInteger gasPrice = null, HexBigInteger valueAmount = null)
        {
            var    function = GetFunctionChangeOwner();
            string data     = function.GetData(newOwner);

            return(await _transactionService.SignAndSendTransaction(data, contract.Address, valueAmount, gasPrice));
        }
Exemplo n.º 30
0
        public static async Task <string> TransferOfflineAsync(Web3 web3, string contractAddress, string recipient, BigInteger amount, HexBigInteger nonce, BigInteger gas, BigInteger gasPrice, string fromAddress = null)
        {
            IContractTransactionHandler <TransferFunction> transferHandler = web3.Eth.GetContractTransactionHandler <TransferFunction>();

            var transfer = new TransferFunction
            {
                To          = recipient,
                TokenAmount = amount,
                // Nethereum internally calls its Ethereum client by default to set the GasPrice, Nonce and estimate the Gas,
                // so if we want to sign the transaction for the contract completely offline we will need to set those values ourselves.
                Nonce    = nonce.Value,
                Gas      = gas,
                GasPrice = Web3.Convert.ToWei(gasPrice, UnitConversion.EthUnit.Gwei)
            };

            if (fromAddress != null)
            {
                transfer.FromAddress = fromAddress;
            }

            string result = await transferHandler.SignTransactionAsync(contractAddress, transfer).ConfigureAwait(false);

            return(result);
        }
Exemplo n.º 31
0
 /// <summary>
 /// Transfers a specified amount of ether from the input UserWallet to a specified address.
 /// </summary>
 /// <param name="userWalletManager"> The wallet to send the ether from. </param>
 /// <param name="gasLimit"> The gas limit to use for this ether send transaction. </param>
 /// <param name="gasPrice"> The gas price to use for this ether send transaction. </param>
 /// <param name="address"> The address to send the ether to. </param>
 /// <param name="amount"> The amount of ether to send. </param>
 public override void Transfer(UserWalletManager userWalletManager, HexBigInteger gasLimit, HexBigInteger gasPrice, string address, decimal amount)
 {
     userWalletManager.SignTransaction <ConfirmTransactionPopup>(
         request => EthUtils.SendEther(request, gasLimit, gasPrice, userWalletManager.GetWalletAddress(), address, amount),
         gasLimit,
         gasPrice,
         SolidityUtils.ConvertToUInt(amount, 18),
         address,
         "",
         address,
         AssetAddress,
         amount,
         "ETH");
 }
Exemplo n.º 32
0
        public async Task <string> ChangeRequirementAsync(BigInteger _newRequired, HexBigInteger gasPrice = null, HexBigInteger valueAmount = null)
        {
            var    function = GetFunctionChangeRequirement();
            string data     = function.GetData(_newRequired);

            return(await _transactionService.SignAndSendTransaction(data, contract.Address, valueAmount, gasPrice));
        }
Exemplo n.º 33
0
 public TransactionInput(string data, string adddressFrom, HexBigInteger gas,
     HexBigInteger value) : base(data, adddressFrom, gas, value)
 {
 }
Exemplo n.º 34
0
        public async Task <List <EventLog <T> > > GetFilterChanges <T>(HexBigInteger filterId) where T : new()
        {
            var logs = await EthGetFilterChanges.SendRequestAsync(filterId).ConfigureAwait(false);

            return(DecodeAllEvents <T>(logs));
        }
Exemplo n.º 35
0
 public Task<string> SetSubnodeOwnerAsync(string addressFrom, byte[] node, byte[] label, string owner, HexBigInteger gas = null, HexBigInteger valueAmount = null) {
     var function = GetFunctionSetSubnodeOwner();
     return function.SendTransactionAsync(addressFrom, gas, valueAmount, node, label, owner);
 }
Exemplo n.º 36
0
        private void m_updateMinerTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                var miningParameters = GetMiningParameters();
                if (miningParameters == null)
                {
                    OnGetMiningParameterStatusEvent(this, false, null);
                    return;
                }

                var address   = miningParameters.EthAddress;
                var challenge = miningParameters.ChallengeNumberByte32String;
                var target    = miningParameters.MiningTargetByte32String;

                if (m_lastParameters == null || miningParameters.ChallengeNumber.Value != m_lastParameters.ChallengeNumber.Value)
                {
                    Program.Print(string.Format("[INFO] New challenge detected {0}...", challenge));
                    OnNewMessagePrefixEvent(this, challenge + address.Replace("0x", string.Empty));
                }

                if (m_customDifficulity == 0)
                {
                    DifficultyHex = miningParameters.MiningDifficulty.HexValue;

                    if (m_lastParameters == null || miningParameters.MiningTarget.Value != m_lastParameters.MiningTarget.Value)
                    {
                        Program.Print(string.Format("[INFO] New target detected {0}...", target));
                        OnNewTargetEvent(this, target);
                    }

                    if (m_lastParameters == null || miningParameters.MiningDifficulty.Value != m_lastParameters.MiningDifficulty.Value)
                    {
                        Program.Print(string.Format("[INFO] New difficulity detected ({0})...", miningParameters.MiningDifficulty.Value));
                        Difficulty = Convert.ToUInt64(miningParameters.MiningDifficulty.Value.ToString());

                        var calculatedTarget = m_maxTarget.Value / Difficulty;
                        if (calculatedTarget != miningParameters.MiningTarget.Value)
                        {
                            var newTarget = calculatedTarget.ToString();
                            Program.Print(string.Format("[INFO] Update target {0}...", newTarget));
                            OnNewTargetEvent(this, newTarget);
                        }
                    }
                }
                else
                {
                    Difficulty = m_customDifficulity;
                    var calculatedTarget = m_maxTarget.Value / m_customDifficulity;
                    var newTarget        = new HexBigInteger(new BigInteger(m_customDifficulity)).HexValue;

                    OnNewTargetEvent(this, newTarget);
                }

                m_lastParameters = miningParameters;
                OnGetMiningParameterStatusEvent(this, true, miningParameters);
            }
            catch (Exception ex)
            {
                Program.Print(string.Format("[ERROR] {0}", ex.Message));
            }
        }
        public virtual void ShouldEncodeCompactNoTraillingZeros()
        {
            var x = new HexBigInteger(new BigInteger(1024));
            Assert.Equal("0x400", x.HexValue); // not "0x0400"

        }
Exemplo n.º 38
0
        public void SubmitSolution(string digest, string fromAddress, string challenge, string difficulty, string target, string solution, Miner.IMiner sender)
        {
            if (m_runFailover)
            {
                ((INetworkInterface)SecondaryPool).SubmitSolution(digest, fromAddress, challenge, difficulty, target, solution, sender);
                return;
            }

            if (string.IsNullOrWhiteSpace(solution) || solution == "0x")
            {
                return;
            }

            difficulty = new HexBigInteger(difficulty).Value.ToString(); // change from hex to base 10 numerics

            var success = false;
            var submitted = false;
            int retryCount = 0, maxRetries = 10;
            var devFee = (ulong)Math.Round(100 / Math.Abs(DevFee.UserPercent));

            do
            {
                try
                {
                    var poolAddress = fromAddress;
                    lock (this)
                    {
                        if (SubmittedShares == ulong.MaxValue)
                        {
                            SubmittedShares = 0u;
                        }
                        var minerAddress = ((SubmittedShares) % devFee) == 0 ? DevFee.Address : s_MinerAddress;

                        JObject submitShare;
                        submitShare = GetPoolParameter("submitShare", solution, minerAddress, digest, difficulty, challenge,
                                                       m_customDifficulity > 0 ? "true" : "false", Miner.Work.GetKingAddressString());

                        var response = Utils.Json.InvokeJObjectRPC(s_PoolURL, submitShare);
                        var result   = response.SelectToken("$.result")?.Value <string>();

                        success = (result ?? string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase);
                        if (!success)
                        {
                            RejectedShares++;
                        }
                        SubmittedShares++;

                        Program.Print(string.Format("[INFO] {0} [{1}] submitted: {2}",
                                                    (minerAddress == DevFee.Address ? "Dev. fee share" : "Miner share"),
                                                    SubmittedShares,
                                                    (success ? "success" : "failed")));
#if DEBUG
                        Program.Print(submitShare.ToString());
                        Program.Print(response.ToString());
#endif
                    }
                    submitted = true;
                }
                catch (Exception ex)
                {
                    Program.Print(string.Format("[ERROR] {0}", ex.Message));

                    retryCount += 1;
                    if (retryCount < maxRetries)
                    {
                        Task.Delay(500);
                    }
                }
            } while (!submitted && retryCount < maxRetries);

            if (!success)
            {
                UpdateMiningParameters();
            }
        }
 public virtual void ShouldDecode0x0()
 {
     var x = new HexBigInteger("0x0");
     Assert.Equal(0, x.Value);
 }
Exemplo n.º 40
0
        public async Task <Tuple <string, string> > DeployContract(int id, string address1, string address2, decimal amount1, decimal amount2, decimal totalAmount, HexBigInteger fee, string address, string pass)
        {
            var wallet  = new Wallet(Words, Password);
            var account = wallet.GetAccount(id);
            var web3    = new Web3(account, this.Network);

            var abi      = File.ReadAllText(this.AbiPath);
            var contract = File.ReadAllText(this.Contract);

            var estimateGas = await web3.Eth.DeployContract.EstimateGasAsync(abi, contract, address, new string[] { address1, address2 }, new[] { CurrencyConverter.EtherToWei(amount1), CurrencyConverter.EtherToWei(amount2) }, new BigInteger(this.RequiredSign), CurrencyConverter.EtherToWei(totalAmount));

            BigInteger price          = fee.Value / estimateGas;
            var        contractDeploy = await web3.Eth.DeployContract.SendRequestAsync(abi, contract, address, estimateGas, new HexBigInteger(price), new HexBigInteger(new BigInteger(Decimal.Zero)), new string[] { address1, address2 }, new [] { CurrencyConverter.EtherToWei(amount1), CurrencyConverter.EtherToWei(amount2) }, new BigInteger(this.RequiredSign), CurrencyConverter.EtherToWei(totalAmount));

            var receipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(contractDeploy);

            try
            {
                while (receipt == null)
                {
                    Thread.Sleep(5000);
                    receipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(contractDeploy);
                }
            }
            catch (Exception e)
            {
                return(null);
            }

            var contractAddress = receipt.ContractAddress;

            return(new Tuple <string, string>(contractAddress, abi));
        }
Exemplo n.º 41
0
 public void SetValue(string blockNumberHex)
 {
     ParameterType = BlockParameterType.blockNumber;
     BlockNumber = new HexBigInteger(blockNumberHex);
 }
Exemplo n.º 42
0
 public static Task<string> DeployContractAsync(Web3.Web3 web3, string addressFrom, string ensAddr, HexBigInteger gas = null, HexBigInteger valueAmount = null) 
 {
     return web3.Eth.DeployContract.SendRequestAsync(ABI, BYTE_CODE, addressFrom, gas, valueAmount , ensAddr);
 }
Exemplo n.º 43
0
 public void SetValue(BigInteger blockNumber)
 {
     ParameterType = BlockParameterType.blockNumber;
     BlockNumber = new HexBigInteger(blockNumber);
 }
Exemplo n.º 44
0
 public Task<string> SetAddrAsync(string addressFrom, byte[] node, string addr, HexBigInteger gas = null, HexBigInteger valueAmount = null) {
     var function = GetFunctionSetAddr();
     return function.SendTransactionAsync(addressFrom, gas, valueAmount, node, addr);
 }
            public Task <string> RaiseEventMetadataAsync(string addressFrom, string creator, BigInteger id,
                                                         string description, string metadata, HexBigInteger gas = null, HexBigInteger valueAmount = null)
            {
                var function = GetFunctionRaiseEventMetadata();

                return(function.SendTransactionAsync(addressFrom, gas, valueAmount, creator, id, description, metadata));
            }
Exemplo n.º 46
0
        public Task <string> SendRequestAsync(HexBigInteger type, string abi, string contractByteCode, string from,
                                              HexBigInteger gas, HexBigInteger maxFeePerGas, HexBigInteger maxPriorityFeePerGas, HexBigInteger value, HexBigInteger nonce, params object[] values)
        {
            var transaction = _deployContractTransactionBuilder.BuildTransaction(type, abi, contractByteCode, from, gas, maxFeePerGas, maxPriorityFeePerGas, value, nonce, values);

            return(TransactionManager.SendTransactionAsync(transaction));
        }
Exemplo n.º 47
0
 public Task<string> SetContentAsync(string addressFrom, byte[] node, byte[] hash, HexBigInteger gas = null, HexBigInteger valueAmount = null) {
     var function = GetFunctionSetContent();
     return function.SendTransactionAsync(addressFrom, gas, valueAmount, node, hash);
 }
 public static Task <string> DeployContractAsync(Web3.Web3 web3, string addressFrom, HexBigInteger gas = null,
                                                 HexBigInteger valueAmount = null)
 {
     return(web3.Eth.DeployContract.SendRequestAsync(ABI, BYTE_CODE, addressFrom, gas, valueAmount));
 }
Exemplo n.º 49
0
 public CallInput(string data, string addressTo, HexBigInteger value) : this(data, addressTo)
 {
     Value = value;
 }
Exemplo n.º 50
0
        protected void HandleEvents(Event poRuleTreeEvent, Event poRuleSetEvent, Event poRuleEvent, HexBigInteger rtFilter, HexBigInteger rsFilter, HexBigInteger rlFilter)
        {
            var ruleTreeLog = poRuleTreeEvent.GetFilterChanges <CallRuleTreeEvent>(rtFilter).Result;
            var ruleSetLog  = poRuleSetEvent.GetFilterChanges <CallRuleSetEvent>(rsFilter).Result;
            var ruleLog     = poRuleEvent.GetFilterChanges <CallRuleEvent>(rlFilter).Result;

            // var ruleTreeLog = callRuleTreeEvent.GetAllChanges<CQS.Validation.CallRuleTreeEvent>(filterCRTAll).Result;
            // var ruleSetLog  = callRuleSetEvent.GetAllChanges<CQS.Validation.CallRuleSetEvent>(filterCRSAll).Result;
            // var ruleLog     = callRuleSetEvent.GetAllChanges<CQS.Validation.CallRuleEvent>(filterCRAll).Result;

            //
            //for (int i = 0; i < 5; ++i)
            //{
            //    System.Threading.Thread.Sleep(10000);
            //
            //    ruleTreeLog = callRuleTreeEvent.GetFilterChanges<CQS.Validation.CallRuleTreeEvent>(filterCRTAll).Result;
            //    ruleSetLog  = callRuleSetEvent.GetFilterChanges<CQS.Validation.CallRuleSetEvent>(filterCRSAll).Result;
            //    ruleLog     = callRuleSetEvent.GetFilterChanges<CQS.Validation.CallRuleEvent>(filterCRAll).Result;
            //}

            // Assert.Equal(1, ruleTreeLog.Count);

            if (ruleTreeLog.Count > 0)
            {
                System.Console.WriteLine("RuleTree Called that Belongs to : (" + ruleTreeLog[0].Event.TreeOwner + ")");
            }

            if (ruleSetLog.Count > 0)
            {
                foreach (EventLog <CallRuleSetEvent> TmpRuleSetEvent in ruleSetLog)
                {
                    System.Console.WriteLine("RuleSet Called with ID : (" + TmpRuleSetEvent.Event.RuleSetId + ")");
                }
            }

            if (ruleLog.Count > 0)
            {
                foreach (EventLog <CallRuleEvent> TmpRuleEvent in ruleLog)
                {
                    System.Console.WriteLine("Rule Called with ID : (" + TmpRuleEvent.Event.RuleId + ") and RuleType(" + TmpRuleEvent.Event.RuleType + ")");
                }
            }
        }
Exemplo n.º 51
0
 public CallInput(string data, HexBigInteger gas, string addressFrom)
 {
     Data = data;
     Gas = gas;
     From = addressFrom;
 }
Exemplo n.º 52
0
        public static async Task <string> DeployContractAsync(Web3 web3, string keyFrom, HexBigInteger gasPrice = null, HexBigInteger valueAmount = null)
        {
            string data = web3.Eth.DeployContract.GetData(BYTE_CODE, ABI);
            ITransactionService transactionService = new ConstantGasTransactionService(keyFrom, web3);

            return(await transactionService.SignAndSendTransaction(data, "", new HexBigInteger(0), gasPrice));
        }