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));
        }
예제 #2
0
 public DeployContract(IClient client)
 {
     this.client                    = client;
     ethSendTransaction             = new EthSendTransaction(client);
     personalSignAndSendTransaction = new PersonalSignAndSendTransaction(client);
     constructorCallEncoder         = new ConstructorCallEncoder();
     abiDeserialiser                = new ABIDeserialiser();
 }
예제 #3
0
 public Personal(IClient client) : base(client)
 {
     ListAccounts           = new PersonalListAccounts(client);
     NewAccount             = new PersonalNewAccount(client);
     UnlockAccount          = new PersonalUnlockAccount(client);
     LockAccount            = new PersonalLockAccount(client);
     SignAndSendTransaction = new PersonalSignAndSendTransaction(client);
 }
예제 #4
0
 public Personal(IClient client) : base(client)
 {
     ListAccounts = new PersonalListAccounts(client);
     NewAccount = new PersonalNewAccount(client);
     UnlockAccount = new PersonalUnlockAccount(client);
     LockAccount = new PersonalLockAccount(client);
     SignAndSendTransaction = new PersonalSignAndSendTransaction(client);
 }
예제 #5
0
 protected FunctionBase(IClient rpcClient, Contract contract, FunctionABI functionABI)
 {
     FunctionABI                    = functionABI;
     this.rpcClient                 = rpcClient;
     this.contract                  = contract;
     ethCall                        = new EthCall(rpcClient);
     ethSendTransaction             = new EthSendTransaction(rpcClient);
     ethEstimateGas                 = new EthEstimateGas(rpcClient);
     personalSignAndSendTransaction = new PersonalSignAndSendTransaction(rpcClient);
     FunctionCallDecoder            = new FunctionCallDecoder();
     FunctionCallEncoder            = new FunctionCallEncoder();
 }
        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));
        }
예제 #8
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));
        }