These are chat archives for Nethereum/Nethereum

17th
Jul 2018
Anthony Leong
@acidfreako
Jul 17 2018 00:04
@andrei_dvp_twitter I am having the same problem with getting the events I have tried web3.js and it worked for me . I didn’t bother to find out the reason or raise an issue in github
haili1234
@haili1234
Jul 17 2018 06:10

Hello!Unity to deploy on the iphone version project, appear such errors, hope to get help, thank you!<transferToRequest>c__Iterator4:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
UnityEngine.Events.InvokableCallList:Invoke(Object[])
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
UnityEngine.EventSystems.StandaloneInputModule:Process()

(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)

JsonException: No parameterless constructor defined for 'Nethereum.Unity.RpcModel.RpcParametersJsonConverter'.
at Newtonsoft.Json.Serialization.JsonTypeReflector+<>cDisplayClass20_0.<GetCreator>b0 (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.SetPropertySettingsFromAttributes (Newtonsoft.Json.Serialization.JsonProperty property, System.Object attributeProvider, System.String name, System.Type declaringType, MemberSerialization memberSerialization, Boolean& allowNonPublicAccess) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperty (System.Reflection.MemberInfo member, MemberSerialization memberSerialization) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties (System.Type type, MemberSerialization memberSerialization) [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.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.UnityRpcClient1+<SendRequest>d__7[TResult].MoveNext () [0x00000] in <filename unknown>:0 at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00000] in <filename unknown>:0 at UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0 at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction1 functor) [0x00000] in <filename unknown>:0
at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, Boolean pressed, Boolean released) [0x00000] in <filename unknown>:0
at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () [0x00000] in <filename unknown>:0
at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00000] in <filename unknown>:0
Rethrow as JsonException: Error creating 'Nethereum.Unity.RpcModel.RpcParametersJsonConverter'.
at Newtonsoft.Json.Serialization.JsonTypeReflector+<>cDisplayClass20_0.<GetCreator>b0 (System.Object[] parameters) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.JsonTypeReflector.GetJsonConverter (System.Object attributePro

Juan Blanco
@juanfranblanco
Jul 17 2018 07:27
@CryptonAdmin well that is an interesting conundrum
@DangNghia123_twitter Nethereum manages the nonces for you
if you do web3.Eth.TransactionManager.Send.. ()
of course you will need to use
an instance of web3 created with your private key to sign offlline and send raw transactions
like this:
var web3 = new Web3(new Account("privateKey"));
@akudrytski the Event filters take an array of topics because you can filter for more than one value for the first topic
secondly the first topic is your method signature
Juan Blanco
@juanfranblanco
Jul 17 2018 07:37
and the event for a contract needs to belong to contract address (as you are filtering for a specific contract address)
@acidfreako
what Nethereum does is validate if the filter is specific for that address, when you use a filter
and you can see unit tests also
Now.. obviously there is an issue on your side and it has happend more than once
so can you post a sample of what you are doing
to verify it?
Juan Blanco
@juanfranblanco
Jul 17 2018 07:47
Also to make it simpler, so it does not happen to anyone else
Grey007
@Grey007
Jul 17 2018 08:53

Hi,
I am trying to sign a transfer for an ERC20 token. I've been trying to use the following reference listed here: https://github.com/Nethereum/Nethereum/blob/master/src/Nethereum.Accounts.IntegrationTests/SignOfflineTransactionTest.cs#L23-L39

However, after you have the signed message, where/how should you submit it to the node?

Juan Blanco
@juanfranblanco
Jul 17 2018 08:54
@Grey007 do you just want to sign and transfer?
Grey007
@Grey007
Jul 17 2018 08:55
Yeah.
Juan Blanco
@juanfranblanco
Jul 17 2018 08:55
just create web3 like this
var web3 = new Web3(new Account("privateKey"));
and send the transaction as normal
this is a sample
for more info on Acccounts
Grey007
@Grey007
Jul 17 2018 08:58

But doing that keeps the private key in memory? I'm wanting to pass through a transaction message to a separate library and do the signing in a separate library and pass through the sign transaction and then submit to the node. Just like you can do with a normal ETH transfer like:

var encoded = Web3.OfflineTransactionSigner.SignTransaction(privatekey, receiveAddress, amount, txCount.Value);

And then submit the value of that:

var txId = await web3.Eth.Transactions.SendRawTransaction.SendRequestAsync("0x" + encoded);

Juan Blanco
@juanfranblanco
Jul 17 2018 08:59
right
well that is your answer :)
now are you passing the message to another external component?
a fully external...
Grey007
@Grey007
Jul 17 2018 09:02
For now, just an internal library project.
for signing
on the newer version the transaction manager and handlers include signing, create transaction input etc for further decoupling
and be able to sign using other services
Grey007
@Grey007
Jul 17 2018 09:15
@juanfranblanco Thanks for the examples. I'll admit, I'm still a bit confused but let me see if I can figure it out.
Juan Blanco
@juanfranblanco
Jul 17 2018 09:15
right that example mainly
shows you that a separate component can do the signing
so you can delegate either the FunctionMessage as per the workbook to do a Transfer
or just the full transaction input
for simplicity I am just using Web3 with a Contracthandler to send the transaction (and interpret the command message in this scenario)
or the other part is the simple send transaction input
BUT for delegation of transactions
fully delegation to another service
I will be creating after this release another transaction manager
which can build the TransactionInput using the contract information, but send it to another service for signing
Grey007
@Grey007
Jul 17 2018 09:21
Okay cool. That would make it a lot easier.
Juan Blanco
@juanfranblanco
Jul 17 2018 09:22
so in that scenario you will need to pass the "endpoint" for your signer
and if using Nethereum lets say
at the other side you can sign if wanted a CommandMesssage or just the TransactionInput
well that is the plan :D
so ... if you use web3 as it stands
it should work the same in the future
Grey007
@Grey007
Jul 17 2018 09:28
Perfect, for now I'll use Web3. Much easier for now.
Grey007
@Grey007
Jul 17 2018 09:49

I have this: var signedMessage = await web3.Eth.GetContractHandler(contract.Address).SignTransactionAsync(transactionMessage);

So, I've got a signed message, what do i use now to send the transaction?

Juan Blanco
@juanfranblanco
Jul 17 2018 09:52
oh.. just use SendTransactionAsync
that will sign it and send it for you
Grey007
@Grey007
Jul 17 2018 09:55
I don't have a SendTransactionAsync option
Juan Blanco
@juanfranblanco
Jul 17 2018 09:56
sorry SendRequestAsync
Zeshan Virk
@zeshanvirk
Jul 17 2018 11:06
is there any method to validate Eth address?
25yuanzijian
@25yuanzijian
Jul 17 2018 11:22
Help: Transfer money on tokens, how do I write
Juan Blanco
@juanfranblanco
Jul 17 2018 14:00
@zeshanvirk there is one to validate the length, alphanumeric but not released yet. Well you can use CI
Andrei Kudrytski
@akudrytski
Jul 17 2018 14:00

and you can see unit tests also --

it is actually not that correct, there is no a single test that covers GetAllChanges invoked with NewFilterInput that holds multiple topics. This is the result of such invocation inside IsFilterInputForEvent https://cl.ly/0t2f050J2K2O.

Juan Blanco
@juanfranblanco
Jul 17 2018 14:01
??
yes it is validating the signature is for the event
which is topic 1
or 0
ignore all that
i see the issue
Andrei Kudrytski
@akudrytski
Jul 17 2018 14:05
yes, so Topics[0] holds an array if you CreateFilter with at least one topic
which means that if you want to check if any of Topics[0] objects is an event signature, you need to iterate over the array inside Topics[0]
Juan Blanco
@juanfranblanco
Jul 17 2018 14:07
image.png
no
sorry just checking your thoughts
each log belongs to an event
in this scenario
so the topic[0] is the signature of the address
you made me doubt :D
the structure is =>
Andrei Kudrytski
@akudrytski
Jul 17 2018 14:10
right, and it is correct if you are not using any EventBase.CreateFilterInput without filterTopic
and if you are, adding at least one topic
Juan Blanco
@juanfranblanco
Jul 17 2018 14:11
back to the structure..
so you get Logs array
each log will be for a contract address
and an event (signature)
and each will have indexes
for a contract
you can create a filter for all the events for that contract
and you can filter more for an specific event
etc
so.. where is the bug or the issue
if you post what you are doing and if there is not a bug ill make it simpler
and if there is a bug ill fix it
but if we start with the latter we will meet in the middle and hopefully is not a bug :)
Juan Blanco
@juanfranblanco
Jul 17 2018 14:22
@akudrytski ^^
Andrei Kudrytski
@akudrytski
Jul 17 2018 14:26
sure, not a problem !
here the description of what I am doing, hope it will make things more clear
I am trying to filter events not only by event signature, but by indexed parameter as well,
in order to do that I use EventBase CreateFilterInput(object[] filterTopic1, BlockParameter fromBlock =null,BlockParameter toBlock = null)
which results in EventABI.CreateFilterInput(ContractAddress, filterTopic1, fromBlock, toBlock) being invoked, that inside of its body sets the following structure for Topics https://cl.ly/3W0z3e2s2G1F. as you can see in Topics[0] there is an array, and yes first element of this array holds event signature.
And this results in eventtopic inside EventExtensions.IsFilterInputForEvent to be equal to “System.String[]”, and I am afraid this is not the event signature. https://cl.ly/3c133q1B3e44
which is basically the issue I am trying to describe, please let me know I can help with any additional details, probably I am doing smth wrong in general
Juan Blanco
@juanfranblanco
Jul 17 2018 14:27
cool thanks!!
Let me digest for a second
Any reason why don't you use Contract.GetEvent("")
or ContractHandler.GetEvent<>()
Andrei Kudrytski
@akudrytski
Jul 17 2018 14:34
hmm, I actually use ContractHandler.GetEvent<>()
Juan Blanco
@juanfranblanco
Jul 17 2018 14:34
ah ok cook
cool i mean
Andrei Kudrytski
@akudrytski
Jul 17 2018 14:35
actually I can dm you a test console project that you can plug into solution and reproduce the error, if needed
Juan Blanco
@juanfranblanco
Jul 17 2018 14:35
sure that is even better
as I cannot see how the NewFilterInput
has suddenly removed the topic 0
Andrei Kudrytski
@akudrytski
Jul 17 2018 14:37
right, now how do I dm you in gitter?
Juan Blanco
@juanfranblanco
Jul 17 2018 14:37
yeah :)
please
Andrei Kudrytski
@akudrytski
Jul 17 2018 14:40
ok, so I created temp community for file transfer and invited you
Juan Blanco
@juanfranblanco
Jul 17 2018 14:40
thank you
@akudrytski cannot see the invite
Truong Dang Nghia
@DangNghia123_twitter
Jul 17 2018 18:25
Nethereum manages the nonces for you
if you do web3.Eth.TransactionManager.Send.. ()
of course you will need to use
you mean i do not need set TransactionInput.Nonce? i just tried, the error is the nonce has not been set
@juanfranblanco