These are chat archives for Nethereum/Nethereum

13th
Jun 2017
om
@omkarkhair
Jun 13 2017 12:16
I have a contract that accepts strings, and my application converts byte[] to string before converting to data with function.GetData(data);. I use Encoding.UTF8.GetBytes(bytes) to convert Bytes to UTF8 string. But I keep hitting an exception Character '\u001c' at index '2' is not valid alphanumeric character.. The characters change. Stacktrace below.
   at Nethereum.Hex.HexConvertors.Extensions.HexByteConvertorExtensions.FromCharacterToByte(Char character, Int32 index, Int32 shift)
   at Nethereum.Hex.HexConvertors.Extensions.HexByteConvertorExtensions.HexToByteArray(String value)
   at Nethereum.ABI.Decoders.TypeDecoder.Decode(String encoded, Type type)
   at Nethereum.ABI.Decoders.TypeDecoder.Decode[T](String encoded)
   at Nethereum.ABI.Encoders.IntTypeEncoder.Encode(Object value)
   at Nethereum.ABI.Encoders.AddressTypeEncoder.Encode(Object value)
   at Nethereum.ABI.ABIType.Encode(Object value)
   at Nethereum.ABI.FunctionEncoding.ParametersEncoder.EncodeParameters(Parameter[] parameters, Object[] values)
   at Nethereum.ABI.FunctionEncoding.FunctionCallEncoder.EncodeRequest(String sha3Signature, Parameter[] parameters, Object[] values)
   at Nethereum.Web3.Function.GetData(Object[] functionInput)
   at Bloc.RPC.Helpers.RPCService.SendTransaction(String abi, String contractAddress, String functionName, Object[] data) in C:\RapidCircle\Bloc\Bloc\Bloc.RPC\Helpers\RPCService.cs:line 59
   at Bloc.Services.RPCMedicalRecordService.SignNewMedicalRecordWorkSpace(MedicalRecordWorkspace record) in C:\RapidCircle\Bloc\Bloc\Bloc.Services\RPCMedicalRecordService.cs:line 51
   at Bloc.Services.MedicalRecordService.SendToPatient(String CareProviderId, String CareProviderPassphrase, String PatientEmailId, String SigneeId, HCIM Hcim) in C:\RapidCircle\Bloc\Bloc\Bloc.Services\MedicalRecordService.cs:line 83
I see that the character range filter here triggers the exception
https://github.com/Nethereum/Nethereum/blob/350e55bac84ec6aeb0f3eff777296444ec6ac021/src/Nethereum.Hex/HexConvertors/Extensions/HexByteConvertorExtensions.cs

 else if ((0x29 < value) && (0x40 > value))
                value = (byte)((value - 0x30) << shift);
else
                throw new InvalidOperationException(String.Format("Character '{0}' at index '{1}' is not valid alphanumeric character.", character, index));
om
@omkarkhair
Jun 13 2017 12:22
I intend to store a byte array in a contract, what is the best way to do this? I understand this question is not strongly aligned to Nethereum, but any advise would be helpful. My problem here is that I tried to use string parameters in the function input to try and inject a byte array.
Juan Blanco
@juanfranblanco
Jun 13 2017 13:03
It seems that you are passing string to an address?
well the byte array to an address?
om
@omkarkhair
Jun 13 2017 17:57
@juanfranblanco argh, my bad I was querying an outdated contract. Thanks for pointing this out. The HexByteConverter was trying to parse an address out of my string.