public async Task RunAsync() { var web3 = new Web3(new Account(PrivateKey), "http://localhost:8545"); var deploymentHandler = web3.Eth.GetContractDeploymentHandler <TheOtherDeployment>(); var deploymentReceipt = await deploymentHandler.SendRequestAndWaitForReceiptAsync(); var deploymentCallerHandler = web3.Eth.GetContractDeploymentHandler <TestDeployment>(); var deploymentReceiptCaller = await deploymentCallerHandler.SendRequestAndWaitForReceiptAsync();; var contracthandler = web3.Eth.GetContractHandler(deploymentReceiptCaller.ContractAddress); var callAnotherFunctionMessage = new CallAnotherContractFunction() { TheOther = deploymentReceipt.ContractAddress }; var returnValue = await contracthandler.QueryRawAsync <CallAnotherContractFunction>(callAnotherFunctionMessage); var returnStartingAtData = returnValue.Skip(32).ToArray(); var returnToString = new StringBytes32Decoder().Decode(returnStartingAtData); System.Console.WriteLine(returnToString); }
public Task <byte[]> CallAnotherContractQueryAsync(CallAnotherContractFunction callAnotherContractFunction, BlockParameter blockParameter = null) { return(ContractHandler.QueryAsync <CallAnotherContractFunction, byte[]>(callAnotherContractFunction, blockParameter)); }
public async void ShouldDecodeFixedWithVariableElementsAndVariableElements() { if (_ethereumClientIntegrationFixture.Geth) { //also should be able to call another contract and get the output as bytes and bytes arrays var web3 = _ethereumClientIntegrationFixture.GetWeb3(); var deploymentHandler = web3.Eth.GetContractDeploymentHandler <TheOtherDeployment>(); var deploymentReceipt = await deploymentHandler.SendRequestAndWaitForReceiptAsync(); var deploymentCallerHandler = web3.Eth .GetContractDeploymentHandler <SolidityCallAnotherContract.Contracts.Test.CQS.TestDeployment>(); var deploymentReceiptCaller = await deploymentCallerHandler.SendRequestAndWaitForReceiptAsync(); ; var contracthandler = web3.Eth.GetContractHandler(deploymentReceiptCaller.ContractAddress); var callManyOthersFunctionMessage = new CallManyOtherContractsFixedArrayReturnFunction() { TheOther = deploymentReceipt.ContractAddress }; var callOtherFunctionMessage = new CallAnotherContractFunction() { TheOther = deploymentReceipt.ContractAddress }; var returnValue = await contracthandler.QueryRawAsync(callManyOthersFunctionMessage); var inHex = returnValue.ToHex(); var expected = "Hello Solidity Welcome something much much biggger jlkjfslkfjslkdfjsldfjasdflkjsafdlkjasdfljsadfljasdfkljasdkfljsadfljasdfldsfaj booh!"; var returnByteArray = await contracthandler.QueryAsync <CallManyOtherContractsFixedArrayReturnFunction, List <Byte[]> >( callManyOthersFunctionMessage); //var inHex = returnValue.ToHex(); var first = new StringTypeDecoder().Decode(returnByteArray[0]); var second = new StringTypeDecoder().Decode(returnByteArray[1]); var third = new StringTypeDecoder().Decode(returnByteArray[2]); Assert.Equal(expected, first); Assert.Equal(expected, second); Assert.Equal(expected, third); var callManyOthersVariableFunctionMessage = new CallManyOtherContractsVariableArrayReturnFunction() { TheOther = deploymentReceipt.ContractAddress }; var returnVarByteArray = await contracthandler.QueryAsync <CallManyOtherContractsVariableArrayReturnFunction, List <Byte[]> >( callManyOthersVariableFunctionMessage); //var inHex = returnValue.ToHex(); var firstVar = new StringTypeDecoder().Decode(returnVarByteArray[0]); var secondVar = new StringTypeDecoder().Decode(returnVarByteArray[1]); var thirdVar = new StringTypeDecoder().Decode(returnVarByteArray[2]); Assert.Equal(expected, firstVar); Assert.Equal(expected, secondVar); Assert.Equal(expected, thirdVar); var returnValue1Call = await contracthandler.QueryAsync <CallAnotherContractFunction, byte[]>(callOtherFunctionMessage); var return1ValueString = new StringTypeDecoder().Decode(returnValue1Call); Assert.Equal(expected, return1ValueString); } }