These are chat archives for Nethereum/Nethereum

26th
Mar 2018
Chandra Sekhar
@tcsekhar
Mar 26 2018 14:37

@juanfranblanco When I try creating the transaction through Remix, it does work. I am able to create the transactions without any issue. But when I try to do it through Nethereum and infura is when I have this problem. I tried to reach out to Infura, but never got back from them.

Here is the stand alone code with everything hardcoded to my values - no other configuration needed. Can you please help me figure out where the problem could be:

           Nethereum.Contracts.Function function = new Nethereum.Web3.Web3(new Nethereum.Web3.Accounts.Account("b3d7d06a45d2ae2b39f7296af2b03b02ad034b47e3660554ddb440f0610c37b7")
                                                                                ,"https://ropsten.infura.io/pL7x9kxoWf5F4mzkeZ3q")
                                                                                    .Eth.GetContract("[{'constant':false,'inputs':[{'name':'inHashString','type':'string'},{'name':'inDescription','type':'string'},{'name':'inSubmitDate','type':'string'}],'name':'storeHash','outputs':[],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':true,'inputs':[],'name':'getStoredDescription','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':true,'inputs':[],'name':'getSubmittedDate','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':true,'inputs':[],'name':'getTransactionDate','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':true,'inputs':[],'name':'getStoredHash','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'}]"
                                                                                                    ,"0xae4b966957a88afb9fba84359014936520c68e7d")
                                                                                                        .GetFunction("storeHash");
            var transactionHash = function.SendTransactionAsync("0xf558e0532b817903b980bfd1164101aecb5c5368"
                                                                    , new HexBigInteger(9000000)
                                                                    , new HexBigInteger(0)
                                                                    , "Test"
                                                                    , "Something"
                                                                    , "1/1/2018").GetAwaiter().GetResult();
The contract can be seen here (it will have the source as well): https://ropsten.etherscan.io/address/0xae4b966957a88afb9fba84359014936520c68e7d#code
Juan Blanco
@juanfranblanco
Mar 26 2018 16:50
@bohuang3d_twitter in Nethereum you don't need metamask if working outside the browser.
You will use Metamask for Blazor / Wasm and Unity3d webgl
Read about accounts on the documentation
TarrahArshad
@TarrahArshad
Mar 26 2018 16:52
@juanfranblanco hey juan why no answer ?
Jose
@iGunSlingeRv2_twitter
Mar 26 2018 16:53
@ryoichirooka_twitter No I havent solved the error yet. Hoping that @juanfranblanco has a solution? Where did you find that link.xml?
Juan Blanco
@juanfranblanco
Mar 26 2018 16:53
I am going throug all the questions
TarrahArshad
@TarrahArshad
Mar 26 2018 16:54
@juanfranblanco juan plz answer my private question , its very important
Juan Blanco
@juanfranblanco
Mar 26 2018 16:54
@iGunSlingeRv2_twitter what is your problem
Jose
@iGunSlingeRv2_twitter
Mar 26 2018 17:00
@juanfranblanco Hey Juan. Yeah I mentioned a couple of days ago in here. I am getting an exception error when using Nethereum in Unity3d on mobile IOS. It happens when I am trying to request my ETH balance request and also the gaslimit estimation request. For example this one EthGetBalanceUnityRequest. It works fine on the Editor but XCode I get this error:
JsonException: No parameterless constructor defined for 'Nethereum.RPC.Eth.DTOs.BlockParameterJsonConverter'.
  at Newtonsoft.Json.Serialization.JsonTypeReflector+<>c__DisplayClass20_0.<GetCreator>b__0 (System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonTypeReflector.GetJsonConverter (System.Object attributeProvider) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract (Newtonsoft.Json.Serialization.JsonContract contract) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList (Newtonsoft.Json.JsonWriter writer, IEnumerable values, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable (Newtonsoft.Json.JsonWriter writer, Newtonsoft.Json.JsonConverter converter, System.Object value, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <filename unknown>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00000] in <filename unknown>:0 
  at Nethereum.JsonRpc.UnityClient.UnityRpcClient`1+<SendRequest>c__Iterator0[TResult].MoveNext () [0x00000] in <filename unknown>:0
Juan Blanco
@juanfranblanco
Mar 26 2018 17:02
are you using the custom Newtonsoft included
also from the comments the link.xml
file?
Ryo
@ryoichirooka_twitter
Mar 26 2018 17:05
@iGunSlingeRv2_twitter about the link.xml, you can just hand-make it by replacing assemblies/namespaces/types in a template file with those you want to include in the build. Template source: https://docs.unity3d.com/Manual/IL2CPP-BytecodeStripping.html Example:
<linker>
     <assembly fullname="Nethereum.JsonRpc.Client">
           <type fullname="Nethereum.JsonRpc.Client.RpcMessages.RpcParametersJsonConverter" preserve="all"/>
     </assembly>
</linker>
@juanfranblanco Custom Netwonsoft?
Juan Blanco
@juanfranblanco
Mar 26 2018 17:06
For Unity to have AOT Nethereum includes an optimised Newtonsoft library
Ryo
@ryoichirooka_twitter
Mar 26 2018 17:08
SWEET. I've totally missed that. I'll give it a try
Juan Blanco
@juanfranblanco
Mar 26 2018 17:09
It is included in the "package"
so if you used your own it will probably break
Jose
@iGunSlingeRv2_twitter
Mar 26 2018 17:09
Nice! I missed that too. I will try this out right now and also including the link.xml
Juan Blanco
@juanfranblanco
Mar 26 2018 17:10
and the link.xml is to prevent stripping the Nethereum dlls
and the ones required by the custom Json library
Juan Blanco
@juanfranblanco
Mar 26 2018 17:51
@tcsekhar you are using a wcf service aren't you?
@tcsekhar see above, you were using too much gas
Jose
@iGunSlingeRv2_twitter
Mar 26 2018 18:42

@juanfranblanco I was able to remove that error out of the way by adding the Custom Newton and link.xml file which is great! Thanks for that. But now I have a new error when I am requesting my balance:

Unable to convert the result to type Nethereum.Hex.HexTypes.HexBigInteger

Is this related to the previous error I had?

I do have a balance greater than zero and the url I pass in is the mainnet.infura.io
Jose
@iGunSlingeRv2_twitter
Mar 26 2018 19:33
@juanfranblanco Looking at the UnityRPCRequests.cs in github I ended up copying the EthGetBalanceUnityRequest and made it return a string instead of HexBigInteger which then I convert back to a BigInteger and I got it to work. Not sure if this is the best solution.
Ryo
@ryoichirooka_twitter
Mar 26 2018 19:36
@iGunSlingeRv2_twitter It may be that the HexBigInteger was getting stripped out until you explicitly referred to it in your code. Did you try including the assembly/namespace/type of HexBigInteger in link.xml?
Jose
@iGunSlingeRv2_twitter
Mar 26 2018 19:49
@ryoichirooka_twitter Good point but sadly that didnt work though :/
Chandra Sekhar
@tcsekhar
Mar 26 2018 19:50

@juanfranblanco Thanks for sending me the code. This is really insane. It didn't work on MVC web service - but worked on WCF when I created a new project. I will take it from here. Thank you so very much!!

May be I have referenced wrong things in the MVC application. I will look.

Ryo
@ryoichirooka_twitter
Mar 26 2018 19:52
@juanfranblanco Recap with the Unity-optimized Newtonsoft DLL -- the one included in packages didn't work, but a fresh DLL out of the original repo in SaladLab worked.