示例#1
0
        public Task <string> SignAndSendTransactionAsync(string password, HexBigInteger gas, HexBigInteger value,
                                                         string from
                                                         )
        {
            var encodedInput = FunctionCallEncoder.EncodeRequest(FunctionABI.Sha3Signature);

            return
                (personalSignAndSendTransaction.SendRequestAsync(
                     new TransactionInput(encodedInput, ContractAddress, from, gas,
                                          value), password));
        }
        public override async Task <string> SendTransactionAsync(TransactionInput transactionInput)
        {
            if (Client == null)
            {
                throw new NullReferenceException("Client not configured");
            }
            if (transactionInput == null)
            {
                throw new ArgumentNullException(nameof(transactionInput));
            }
            if (!transactionInput.From.IsTheSameAddress(Account.Address))
            {
                throw new Exception("Invalid account used");
            }
            var gasPrice = await GetGasPriceAsync(transactionInput).ConfigureAwait(false);

            transactionInput.GasPrice = gasPrice;

            SetDefaultGasPriceAndCostIfNotSet(transactionInput);
            var nonce = await GetNonceAsync(transactionInput).ConfigureAwait(false);

            if (nonce != null)
            {
                transactionInput.Nonce = nonce;
            }
            var ethSendTransaction = new PersonalSignAndSendTransaction(Client);

            return(await ethSendTransaction.SendRequestAsync(transactionInput, ((ManagedAccount)Account).Password)
                   .ConfigureAwait(false));
        }
示例#3
0
        public Task <string> SignAndSendRequestAsync(string password, string abi, string contractByteCode, string from,
                                                     HexBigInteger gas,
                                                     params object[] values)
        {
            var transaction = BuildTransaction(abi, contractByteCode, from, gas, values);

            return(personalSignAndSendTransaction.SendRequestAsync(transaction, password));
        }
        public override async Task <string> ExecuteAsync(IClient client)
        {
            var personalSignAndSendTransaction = new PersonalSignAndSendTransaction(client);
            //contract test { function multiply(uint a) returns(uint d) { return a * 7; } }
            var contractByteCode =
                "0x606060405260728060106000396000f360606040526000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa1146037576035565b005b604b60048080359060200190919050506061565b6040518082815260200191505060405180910390f35b6000600782029050606d565b91905056";

            //As the input the compiled contract is the Data, together with our address
            var transactionInput = new TransactionInput();

            transactionInput.Data = contractByteCode;
            transactionInput.From = Settings.GetDefaultAccount();

            return(await personalSignAndSendTransaction.SendRequestAsync(transactionInput, Settings.GetDefaultAccountPassword()));
        }
        public override Task <string> SendTransactionAsync <T>(T transactionInput)
        {
            if (Client == null)
            {
                throw new NullReferenceException("Client not configured");
            }
            if (transactionInput == null)
            {
                throw new ArgumentNullException(nameof(transactionInput));
            }
            if (transactionInput.From != _accountAddress)
            {
                throw new Exception("Invalid account used");
            }
            var ethSendTransaction = new PersonalSignAndSendTransaction(Client);

            return(ethSendTransaction.SendRequestAsync(transactionInput, _password));
        }
示例#6
0
        private static async Task <string> SendTransaction(IClient client, string addressFrom,
                                                           string contractAddress, string password)
        {
            var transactionInput   = new TransactionInput();
            var ethSendTransaction = new PersonalSignAndSendTransaction(client);
            var function           = new FunctionCallEncoder();
            //Input the function method Sha3Encoded (4 bytes)
            var sha3Signature = "c6888fa1";
            //Define input parameters
            var inputParameters = new[] { new Parameter("uint", "a") };
            //encode the function call (function + parameter input)
            //using 69 as the input
            var functionCall = function.EncodeRequest(sha3Signature, inputParameters, 69);

            transactionInput.From = addressFrom;
            //the destination address is the contract address
            transactionInput.To = contractAddress;
            //use as data the function call
            transactionInput.Data = functionCall;

            return(await ethSendTransaction.SendRequestAsync(transactionInput, password));
        }
示例#7
0
 protected Task <string> SingAndSendTransactionAsync(string password, string encodedFunctionCall)
 {
     return(personalSignAndSendTransaction.SendRequestAsync(new TransactionInput(encodedFunctionCall, ContractAddress), password));
 }