protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, string encodedFunctionCall, CallInput callInput) { callInput.Data = encodedFunctionCall; var result = await ethCall.SendRequestAsync(callInput, DefaultBlock).ConfigureAwait(false); return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result)); }
protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, string encodedFunctionCall, CallInput callInput, BlockParameter block) { callInput.Data = encodedFunctionCall; var result = await ethCall.SendRequestAsync(callInput, block); return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result)); }
/// <summary> /// 解析output /// </summary> /// <typeparam name="FunctionOutputDTO">解析output Dto</typeparam> /// <param name="encodeOutput">原始output</param> /// <returns>解析后得到对象</returns> public FunctionOutputDTO OutputDecode <FunctionOutputDTO>(FunctionOutputDTO outputDto, string encodeOutput) { var functionCallDecoder = new FunctionCallDecoder(); var outputData = functionCallDecoder.DecodeFunctionOutput <FunctionOutputDTO>(outputDto, encodeOutput); return(outputData); }
public virtual void ShouldDecodeMultipleArrays() { var functionCallDecoder = new FunctionCallDecoder(); var outputParameters = new[] { CreateParamO("uint[]", "a", typeof(List <int>)), CreateParamO("uint[]", "b", typeof(List <int>)) }; var result = functionCallDecoder.DecodeOutput( "0x" + "000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002", outputParameters); Assert.True(result.Count == 2); var output1 = (List <int>)result[0].Result; var output2 = (List <int>)result[1].Result; Assert.Equal(3, output1.Count); Assert.Equal(3, output2.Count); Assert.Equal(0, output1[0]); Assert.Equal(1, output1[1]); Assert.Equal(2, output1[2]); Assert.Equal(0, output2[0]); Assert.Equal(1, output2[1]); Assert.Equal(2, output2[2]); }
protected async Task <TReturn> CallAsync <TReturn>(string encodedFunctionCall, CallInput callInput, BlockParameter block) { callInput.Data = encodedFunctionCall; var result = await ethCall.SendRequestAsync(callInput, block); return(FunctionCallDecoder.DecodeSimpleTypeOutput <TReturn>(GetFirstParameterOrNull(FunctionABI.OutputParameters), result)); }
public void WhenTypeDoesApplyFunctionOutputAttribute_ReturnsInstanceOfType() { //ensure an error is NOT throw when attribute IS specified var decodedResult = new FunctionCallDecoder().DecodeFunctionOutput <FunctionOutputWithAttribute>(""); Assert.NotNull(decodedResult); }
public virtual void ShouldDecodeMultipleTypesIncludingDynamicStringAndIntArray() { var functionCallDecoder = new FunctionCallDecoder(); var outputParameters = new[] { CreateParamO("string", "a", typeof(string)), CreateParamO("uint[20]", "b", typeof(List <uint>)), CreateParamO("string", "c", typeof(string)) }; var array = new uint[20]; for (uint i = 0; i < 20; i++) { array[i] = i + 234567; } var result = functionCallDecoder.DecodeOutput( "0x" + "00000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000003944700000000000000000000000000000000000000000000000000000000000394480000000000000000000000000000000000000000000000000000000000039449000000000000000000000000000000000000000000000000000000000003944a000000000000000000000000000000000000000000000000000000000003944b000000000000000000000000000000000000000000000000000000000003944c000000000000000000000000000000000000000000000000000000000003944d000000000000000000000000000000000000000000000000000000000003944e000000000000000000000000000000000000000000000000000000000003944f0000000000000000000000000000000000000000000000000000000000039450000000000000000000000000000000000000000000000000000000000003945100000000000000000000000000000000000000000000000000000000000394520000000000000000000000000000000000000000000000000000000000039453000000000000000000000000000000000000000000000000000000000003945400000000000000000000000000000000000000000000000000000000000394550000000000000000000000000000000000000000000000000000000000039456000000000000000000000000000000000000000000000000000000000003945700000000000000000000000000000000000000000000000000000000000394580000000000000000000000000000000000000000000000000000000000039459000000000000000000000000000000000000000000000000000000000003945a0000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000568656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005776f726c64000000000000000000000000000000000000000000000000000000", outputParameters); Assert.Equal("hello", result.First(x => x.Parameter.Name == "a").Result); Assert.Equal("world", result.First(x => x.Parameter.Name == "c").Result); }
public async Task <dynamic> ExecuteTestAsync(RpcClient client) { //The compiled solidity contract to be deployed //contract test { function multiply(uint a) returns(uint d) { return a * 7; } } var contractByteCode = "0x606060405260728060106000396000f360606040526000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa1146037576035565b005b604b60048080359060200190919050506061565b6040518082815260200191505060405180910390f35b6000600782029050606d565b91905056"; //Create a new Eth Send Transanction RPC Handler var ethSendTransation = new EthSendTransaction(client); //As the input the compiled contract is the Data, together with our address var transactionInput = new TransactionInput(); transactionInput.Data = contractByteCode; transactionInput.From = "0x12890d2cce102216644c59dae5baed380d84830c"; // retrieve the hash var transactionHash = await ethSendTransation.SendRequestAsync(transactionInput); //the contract should be mining now //get contract address var ethGetTransactionReceipt = new EthGetTransactionReceipt(client); TransactionReceipt receipt = null; //wait for the contract to be mined to the address while (receipt == null) { receipt = await ethGetTransactionReceipt.SendRequestAsync(transactionHash); } //Encode and build function parameters 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); //reuse the transaction input, (just the address) //the destination address is the contract address transactionInput.To = receipt.ContractAddress; //use as data the function call transactionInput.Data = functionCall; // rpc method to do the call var ethCall = new EthCall(client); // call and get the result var resultFunction = await ethCall.SendRequestAsync(transactionInput); // decode the output var functionDecoder = new FunctionCallDecoder(); var output = functionDecoder.DecodeOutput <int>(resultFunction, new Parameter("uint", "d")); //visual test return("The result of deploying a contract and calling a function to multiply 7 by 69 is: " + output + " and should be 483"); }
public async Task <string> SendRequestAsync(string transactionHash) { var transaction = await _apiTransactionsService.GetTransactionByHash.SendRequestAsync(transactionHash); var transactionInput = transaction.ConvertToTransactionInput(); var functionCallDecoder = new FunctionCallDecoder(); if (transactionInput.MaxFeePerGas != null) { transactionInput.GasPrice = null; } try { var errorHex = await _apiTransactionsService.Call.SendRequestAsync(transactionInput, new BlockParameter(transaction.BlockNumber)); if (ErrorFunction.IsErrorData(errorHex)) { return(functionCallDecoder.DecodeFunctionErrorMessage(errorHex)); } return(string.Empty); } catch (RpcResponseException rpcException) { ContractRevertExceptionHandler.HandleContractRevertException(rpcException); throw; } }
protected FunctionBuilderBase(ContractBuilder contract, FunctionABI functionAbi) { FunctionABI = functionAbi; _contract = contract; FunctionCallDecoder = new FunctionCallDecoder(); FunctionCallEncoder = new FunctionCallEncoder(); }
protected async Task <TReturn> CallAsync <TReturn>(string encodedFunctionCall, CallInput callInput, BlockParameter block) where TReturn : new() { callInput.Data = encodedFunctionCall; var result = await ethCall.SendRequestAsync(callInput, block); return(FunctionCallDecoder.DecodeOutput <TReturn>(result, FunctionABI.OutputParameters)); }
public async Task<dynamic> ExecuteTestAsync(RpcClient client) { //The compiled solidity contract to be deployed //contract test { function multiply(uint a) returns(uint d) { return a * 7; } } var contractByteCode = "0x606060405260728060106000396000f360606040526000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa1146037576035565b005b604b60048080359060200190919050506061565b6040518082815260200191505060405180910390f35b6000600782029050606d565b91905056"; //Create a new Eth Send Transanction RPC Handler var ethSendTransation = new EthSendTransaction(client); //As the input the compiled contract is the Data, together with our address var transactionInput = new TransactionInput(); transactionInput.Data = contractByteCode; transactionInput.From = "0x12890d2cce102216644c59dae5baed380d84830c"; // retrieve the hash var transactionHash = await ethSendTransation.SendRequestAsync( transactionInput); //the contract should be mining now //get contract address var ethGetTransactionReceipt = new EthGetTransactionReceipt(client); TransactionReceipt receipt = null; //wait for the contract to be mined to the address while (receipt == null) { receipt = await ethGetTransactionReceipt.SendRequestAsync( transactionHash); } //Encode and build function parameters 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); //reuse the transaction input, (just the address) //the destination address is the contract address transactionInput.To = receipt.ContractAddress; //use as data the function call transactionInput.Data = functionCall; // rpc method to do the call var ethCall = new EthCall(client); // call and get the result var resultFunction = await ethCall.SendRequestAsync( transactionInput); // decode the output var functionDecoder = new FunctionCallDecoder(); var output = functionDecoder.DecodeOutput<int>(resultFunction, new Parameter("uint", "d")); //visual test return "The result of deploying a contract and calling a function to multiply 7 by 69 is: " + output + " and should be 483"; }
protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, CallInput callInput, BlockParameter block) { var result = await EthCall.SendRequestAsync(callInput, block) .ConfigureAwait(false); return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result)); }
protected async Task <TReturn> CallAsync <TReturn>(string encodedFunctionCall, CallInput callInput) { callInput.Data = encodedFunctionCall; var result = await EthCall.SendRequestAsync(callInput, DefaultBlock).ConfigureAwait(false); return (FunctionCallDecoder.DecodeSimpleTypeOutput <TReturn>( GetFirstParameterOrNull(FunctionABI.OutputParameters), result)); }
protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, string encodedFunctionCall) { var result = await ethCall.SendRequestAsync(new CallInput(encodedFunctionCall, ContractAddress), DefaultBlock) .ConfigureAwait(false); return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result)); }
protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, string encodedFunctionCall, string from, HexBigInteger gas, HexBigInteger value, BlockParameter block) { var result = await EthCall.SendRequestAsync(new CallInput(encodedFunctionCall, ContractAddress, @from, gas, value), block).ConfigureAwait(false); return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result)); }
public async Task <decimal> BalanceOfAsync(string contractAddress, ITronAccount ownerAccount) { var contractAddressBytes = Base58Encoder.DecodeFromBase58Check(contractAddress); var ownerAddressBytes = Base58Encoder.DecodeFromBase58Check(ownerAccount.Address); var wallet = _walletClient.GetProtocol(); var functionABI = ABITypedRegistry.GetFunctionABI <BalanceOfFunction>(); try { var addressBytes = new byte[20]; Array.Copy(ownerAddressBytes, 1, addressBytes, 0, addressBytes.Length); var addressBytesHex = "0x" + addressBytes.ToHex(); var balanceOf = new BalanceOfFunction { Owner = addressBytesHex }; var decimals = GetDecimals(wallet, contractAddressBytes); var encodedHex = new FunctionCallEncoder().EncodeRequest(balanceOf, functionABI.Sha3Signature); var trigger = new TriggerSmartContract { ContractAddress = ByteString.CopyFrom(contractAddressBytes), OwnerAddress = ByteString.CopyFrom(ownerAddressBytes), Data = ByteString.CopyFrom(encodedHex.HexToByteArray()), }; var transactionExtention = await wallet.TriggerConstantContractAsync(trigger, headers : _walletClient.GetHeaders()); if (!transactionExtention.Result.Result) { throw new Exception(transactionExtention.Result.Message.ToStringUtf8()); } if (transactionExtention.ConstantResult.Count == 0) { throw new Exception($"result error, ConstantResult length=0."); } var result = new FunctionCallDecoder().DecodeFunctionOutput <BalanceOfFunctionOutput>(transactionExtention.ConstantResult[0].ToByteArray().ToHex()); var balance = Convert.ToDecimal(result.Balance); if (decimals > 0) { balance /= Convert.ToDecimal(Math.Pow(10, decimals)); } return(balance); } catch (Exception ex) { _logger.LogError(ex, ex.Message); throw; } }
protected Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, CallInput callInput, BlockParameter block) { return(EthCall.SendRequestAsync(callInput, block).ContinueWith(result => { if (result.Exception != null) { throw result.Exception; } return FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result.Result); })); }
protected async Task <TReturn> CallAsync <TReturn>(string encodedFunctionCall) { var result = await ethCall.SendRequestAsync(new CallInput(encodedFunctionCall, ContractAddress), DefaultBlock) .ConfigureAwait(false); return (FunctionCallDecoder.DecodeSimpleTypeOutput <TReturn>( GetFirstParameterOrNull(FunctionABI.OutputParameters), result)); }
protected async Task <TReturn> CallAsync <TReturn>(string encodedFunctionCall, string from, HexBigInteger gas, HexBigInteger value, BlockParameter block) { var result = await EthCall.SendRequestAsync(new CallInput(encodedFunctionCall, ContractAddress, @from, gas, value), block).ConfigureAwait(false); return (FunctionCallDecoder.DecodeSimpleTypeOutput <TReturn>( GetFirstParameterOrNull(FunctionABI.OutputParameters), result)); }
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); FunctionCallDecoder = new FunctionCallDecoder(); FunctionCallEncoder = new FunctionCallEncoder(); }
public void WhenThereAreNoInputParametersDecodingShouldReturnTheUnalteredFunctionInputDTO() { const string signature = "0x82692679"; //function name = doSomething const string data = signature; var decoder = new FunctionCallDecoder(); var functionInput = new object(); var decodedFunctionInput = decoder.DecodeFunctionInput(functionInput, signature, data); Assert.Equal(functionInput, decodedFunctionInput); }
public TReturn DecodeTypeOutput <TReturn>(string output) { var function = FunctionOutputAttribute.GetAttribute <TReturn>(); if (function != null) { var instance = Activator.CreateInstance(typeof(TReturn)); return(DecodeDTOTypeOutput <TReturn>((TReturn)instance, output)); } else { return(FunctionCallDecoder.DecodeSimpleTypeOutput <TReturn>( GetFirstParameterOrNull(FunctionABI.OutputParameters), output)); } }
public virtual void ShouldDecodeMultipleTypesIncludingDynamicStringAndIntArray() { var functionCallDecoder = new FunctionCallDecoder(); var array = new uint[20]; for (uint i = 0; i < 20; i++) { array[i] = i + 234567; } var result = functionCallDecoder. DecodeOutput <FunctionMultipleInputOutput>("0x" + "00000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000003944700000000000000000000000000000000000000000000000000000000000394480000000000000000000000000000000000000000000000000000000000039449000000000000000000000000000000000000000000000000000000000003944a000000000000000000000000000000000000000000000000000000000003944b000000000000000000000000000000000000000000000000000000000003944c000000000000000000000000000000000000000000000000000000000003944d000000000000000000000000000000000000000000000000000000000003944e000000000000000000000000000000000000000000000000000000000003944f0000000000000000000000000000000000000000000000000000000000039450000000000000000000000000000000000000000000000000000000000003945100000000000000000000000000000000000000000000000000000000000394520000000000000000000000000000000000000000000000000000000000039453000000000000000000000000000000000000000000000000000000000003945400000000000000000000000000000000000000000000000000000000000394550000000000000000000000000000000000000000000000000000000000039456000000000000000000000000000000000000000000000000000000000003945700000000000000000000000000000000000000000000000000000000000394580000000000000000000000000000000000000000000000000000000000039459000000000000000000000000000000000000000000000000000000000003945a0000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000568656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005776f726c64000000000000000000000000000000000000000000000000000000" ); Assert.Equal("hello", result.A); Assert.Equal("world", result.C); Assert.Equal(array[6], result.B[6]); }
public TReturn DecodeSimpleTypeOutput <TReturn>(string output) { return(FunctionCallDecoder.DecodeSimpleTypeOutput <TReturn>( GetFirstParameterOrNull(FunctionABI.OutputParameters), output)); }
public List <ParameterOutput> DecodeInput(string data) { return(FunctionCallDecoder.DecodeFunctionInput(FunctionABI.Sha3Signature, data, FunctionABI.InputParameters)); }
public virtual void ShouldDecodeMultipleTypesIncludingDynamicStringAndIntArray() { var functionCallDecoder = new FunctionCallDecoder(); var outputParameters = new[] { CreateParamO("string", "a", typeof(string)), CreateParamO("uint[20]", "b", typeof(List<uint>)), CreateParamO("string", "c", typeof(string)) }; var array = new uint[20]; for (uint i = 0; i < 20; i++) { array[i] = i + 234567; } var result = functionCallDecoder. DecodeOutput("0x" + "00000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000003944700000000000000000000000000000000000000000000000000000000000394480000000000000000000000000000000000000000000000000000000000039449000000000000000000000000000000000000000000000000000000000003944a000000000000000000000000000000000000000000000000000000000003944b000000000000000000000000000000000000000000000000000000000003944c000000000000000000000000000000000000000000000000000000000003944d000000000000000000000000000000000000000000000000000000000003944e000000000000000000000000000000000000000000000000000000000003944f0000000000000000000000000000000000000000000000000000000000039450000000000000000000000000000000000000000000000000000000000003945100000000000000000000000000000000000000000000000000000000000394520000000000000000000000000000000000000000000000000000000000039453000000000000000000000000000000000000000000000000000000000003945400000000000000000000000000000000000000000000000000000000000394550000000000000000000000000000000000000000000000000000000000039456000000000000000000000000000000000000000000000000000000000003945700000000000000000000000000000000000000000000000000000000000394580000000000000000000000000000000000000000000000000000000000039459000000000000000000000000000000000000000000000000000000000003945a0000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000568656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005776f726c64000000000000000000000000000000000000000000000000000000", outputParameters); Assert.Equal("hello", result.First(x => x.Parameter.Name == "a").Result); Assert.Equal("world", result.First(x => x.Parameter.Name == "c").Result); }
public virtual void ShouldDecodeMultipleTypesIncludingDynamicStringAndIntArray() { var functionCallDecoder = new FunctionCallDecoder(); var array = new uint[20]; for (uint i = 0; i < 20; i++) { array[i] = i + 234567; } var result = functionCallDecoder. DecodeFunctionOutput<FunctionMultipleInputOutput>("0x" + "00000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000003944700000000000000000000000000000000000000000000000000000000000394480000000000000000000000000000000000000000000000000000000000039449000000000000000000000000000000000000000000000000000000000003944a000000000000000000000000000000000000000000000000000000000003944b000000000000000000000000000000000000000000000000000000000003944c000000000000000000000000000000000000000000000000000000000003944d000000000000000000000000000000000000000000000000000000000003944e000000000000000000000000000000000000000000000000000000000003944f0000000000000000000000000000000000000000000000000000000000039450000000000000000000000000000000000000000000000000000000000003945100000000000000000000000000000000000000000000000000000000000394520000000000000000000000000000000000000000000000000000000000039453000000000000000000000000000000000000000000000000000000000003945400000000000000000000000000000000000000000000000000000000000394550000000000000000000000000000000000000000000000000000000000039456000000000000000000000000000000000000000000000000000000000003945700000000000000000000000000000000000000000000000000000000000394580000000000000000000000000000000000000000000000000000000000039459000000000000000000000000000000000000000000000000000000000003945a0000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000568656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005776f726c64000000000000000000000000000000000000000000000000000000" ); Assert.Equal("hello", result.A); Assert.Equal("world", result.C); Assert.Equal(array[6], result.B[6]); }
protected async Task <TReturn> CallAsync <TReturn>(TReturn functionOuput, string encodedFunctionCall, string from, HexBigInteger gas, HexBigInteger value) { var result = await ethCall.SendRequestAsync(new CallInput(encodedFunctionCall, ContractAddress, from, gas, value), DefaultBlock); return(FunctionCallDecoder.DecodeFunctionOutput(functionOuput, result)); }
public TReturn DecodeDTOTypeOutput <TReturn>(TReturn functionOuput, string output) { return(FunctionCallDecoder.DecodeFunctionOutput <TReturn>(functionOuput, output)); }
public override async Task <string> ExecuteAsync(IClient client) { //The compiled solidity contract to be deployed //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(); // retrieve the hash var minerStart = new MinerStart(client); var minerStartResult = await minerStart.SendRequestAsync(); var transactionHash = await new PersonalSignAndSendTransaction(client).SendRequestAsync(transactionInput, Settings.GetDefaultAccountPassword()); //get contract address var ethGetTransactionReceipt = new EthGetTransactionReceipt(client); TransactionReceipt receipt = null; //wait for the contract to be mined to the address while (receipt == null) { await Task.Delay(1000); receipt = await ethGetTransactionReceipt.SendRequestAsync(transactionHash); } var minerStop = new MinerStop(client); var minerStopResult = await minerStop.SendRequestAsync(); //Encode and build function parameters 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); //reuse the transaction input, (just the address) //the destination address is the contract address transactionInput.To = receipt.ContractAddress; //use as data the function call transactionInput.Data = functionCall; // rpc method to do the call var ethCall = new EthCall(client); // call and get the result var resultFunction = await ethCall.SendRequestAsync(transactionInput); // decode the output var functionDecoder = new FunctionCallDecoder(); var output = functionDecoder.DecodeOutput <int>(resultFunction, new Parameter("uint", "d")); var message = "The result of deploying a contract and calling a function to multiply 7 by 69 is: " + output + " and should be 483"; Assert.Equal(483, output); return(message); }
public TReturn DecodeDTOTypeOutput <TReturn>(string output) where TReturn : new() { return(FunctionCallDecoder.DecodeFunctionOutput <TReturn>(output)); }
public List <ParameterOutput> DecodeOutput(string data) { return(FunctionCallDecoder.DecodeDefaultData(data, FunctionABI.OutputParameters)); }