These are chat archives for Nethereum/Nethereum

20th
Apr 2018
Daniel Krotov
@xtr33me
Apr 20 2018 00:00
@juanfranblanco Since you provide the example files for the flappy bird demo I figured I should first get that working and then come back to my project. I currently have a flappybird example up and working with the logic from your code brought over. I am getting an error that the namespace nethereum.keystore does not exist. When I looked at the files, I havent been able to find it. Is this expected?
Daniel Krotov
@xtr33me
Apr 20 2018 00:47

I ended up copying the dll over from an earlier 2.0.0 version you had. When running in the Unity player I now get the below error.

NullReferenceException: Object reference not set to an instance of an object
Nethereum.Signer.Crypto.ECKey.GetPubKey (Boolean isCompressed)
Nethereum.Signer.EthECKey.CalculateRecId (Nethereum.Signer.Crypto.ECDSASignature signature, System.Byte[] hash)
Nethereum.Signer.EthECKey.SignAndCalculateV (System.Byte[] hash)
Nethereum.Signer.RLPSigner.Sign (Nethereum.Signer.EthECKey key)
Nethereum.Signer.Transaction.Sign (Nethereum.Signer.EthECKey key)
Nethereum.Signer.TransactionSigner.SignTransaction (System.Byte[] privateKey, Nethereum.Signer.Transaction transaction)
Nethereum.Signer.TransactionSigner.SignTransaction (System.Byte[] privateKey, System.String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, System.String data)
Nethereum.Signer.TransactionSigner.SignTransaction (System.String privateKey, System.String to, BigInteger amount, BigInteger nonce, BigInteger gasPrice, BigInteger gasLimit, System.String data)
Nethereum.JsonRpc.UnityClient.TransactionSignedUnityRequest+<SignAndSendTransaction>d__7.MoveNext ()
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

Juan Blanco
@juanfranblanco
Apr 20 2018 06:34
@CryptoAlphaOne you can set your gas price
the price is the same as the standard gwei price
if you want to change your gas price for all the transactions just do this
Web3.TransactionManager.DefaultGasPrice and put your value there
or any TransactionInput set the gas price
plus your code does not allow me to do this. It only performs a transfer if I put the default value that is 0.00021 or a value above that.
???
what code?
@ShermanMeredith just declare it as a String
Juan Blanco
@juanfranblanco
Apr 20 2018 06:42
example [Parameter("bytes32", "xx", 1)]
public string XX {get; set;}
bytes32 is an array of bytes
so it could be an integer array, well anything
if you let it know the type you are expecting ie. a string it will decode it for you
strings use UTF8 as default for encoding
so internally will encode and decode the values using UTF8
This message was deleted
@xtr33me remove the namespace is not necessary
Juan Blanco
@juanfranblanco
Apr 20 2018 06:47
you should have that library in the release
The code is the same as the Unity3d only thing has changed is that I have removed the private key hiding / calculation
so it should work out of the box
Juan Blanco
@juanfranblanco
Apr 20 2018 08:49
The code is the same as the Unity3d only thing has changed is that I have removed the private key hiding / calculation (not necessary and adding extra complication)
zidzid1234
@zidzid1234
Apr 20 2018 09:07
Hi Juan Blanco, would you give a quick advice on How to change/specify Solidity linter [solc] compiler version in Visual Studio Code? Please check out this: juanfranblanco/vscode-solidity#61 Thank you :)
Juan Blanco
@juanfranblanco
Apr 20 2018 09:08
I am reading your issue
what linter / solidity compiler version you need
also it seems that there are conflicting issues with the "extended" version as it is a fork
zidzid1234
@zidzid1234
Apr 20 2018 09:10
Yes I've tried to do what that readme is saying but no success yet. May I use 0.4.22 or .23 ?
Juan Blanco
@juanfranblanco
Apr 20 2018 09:11
well i normally work on the latest
zidzid1234
@zidzid1234
Apr 20 2018 09:11
Sure. 0.4.23 is the latest
Juan Blanco
@juanfranblanco
Apr 20 2018 09:11
but that depends on your needs
you might have testing specific for a lower version
image.png
those are some settings
zidzid1234
@zidzid1234
Apr 20 2018 09:16
no I don't have testing specific... Both the Binary Packages and npm install the lastest 0.4.23, so I need the linter compiler to match the compiler compiler :)
Juan Blanco
@juanfranblanco
Apr 20 2018 09:16
the linter compiler
the linter is different from the compiler
zidzid1234
@zidzid1234
Apr 20 2018 09:17
sorry, I meant the linter compiler version setting
Juan Blanco
@juanfranblanco
Apr 20 2018 09:17
the linter compiler version setting?
what linter are you using
so you have a linter
and you have a compiler
zidzid1234
@zidzid1234
Apr 20 2018 09:19
in the Visual Studio Code > settings > compileUsingRemoteVersion" : "v0.4.23+commit.124ca40d", compileUsingLocalVersion" : "/mnt/../SolidityCompiler/4-23/soljson.js",
Juan Blanco
@juanfranblanco
Apr 20 2018 09:19
sure
obviously you chose one
i set it up as "latest"
for remote version
that is the compiler
not the linter
so what is your problem
if you want to select a different linter
zidzid1234
@zidzid1234
Apr 20 2018 09:21
Oh. got it. So my bad. How to change the linter compiler version?
Juan Blanco
@juanfranblanco
Apr 20 2018 09:21
there is not a linter compiler
there is a linter
if you want to change your linter
"solidity.linter": "solium",
or
"soliidy.linter":"solhint"
both linters have the latest
in the extension
I am yet to understand the problem
you have the pointed your compilers to the latest solc (by version and downloaded)
zidzid1234
@zidzid1234
Apr 20 2018 09:25
Sorry. In the snapshot I got the linter highlighting the compiler version.
Juan Blanco
@juanfranblanco
Apr 20 2018 09:26
you have your solium and or solhint linters (chose the one you fancy)
it might be an issue of combining the forked version with the solidity extension
zidzid1234
@zidzid1234
Apr 20 2018 09:28
Okay. So I am trying to point my compilers to the latest solc... how can I do that?
Juan Blanco
@juanfranblanco
Apr 20 2018 09:28
there is only one compiler
the simplest thing is to
"solidity.compileUsingRemoteVersion": "latest"
that should be the only setting
that gets the latest
BUT you may be offline
so you can point to a local path
or node installation
zidzid1234
@zidzid1234
Apr 20 2018 09:31
Yes, I've tried "solidity.compileUsingRemoteVersion" : "latest", but that red warning is still showing
Juan Blanco
@juanfranblanco
Apr 20 2018 09:31
ok have you tried un installing the "extended" version
as it may be hijacking the extension
also
"solidity.compileUsingRemoteVersion" : "latest",
zidzid1234
@zidzid1234
Apr 20 2018 09:32
trying now...
Juan Blanco
@juanfranblanco
Apr 20 2018 09:33
also remove the local version setting
if you have it (although it is pointing to the right file I presume)
just make sure
and if you have installed locally solc
by using npm install solc
this might be also an issue
as that will take preference
(Btw locally, specific for your project)
the idea of that one is that you may have different projects that require different versions
zidzid1234
@zidzid1234
Apr 20 2018 09:38
Yes I have npm install solc, and apt-get install solc both globally and locally only for a project... so I think I've got 3 compilers installed
Juan Blanco
@juanfranblanco
Apr 20 2018 09:39
well if all of them are pointing to the right solidity version it should not be a problem
the local will take preference
preference is defined as:
  1. local installation of node in the project
(2) local path using the user setting
(3) remote path
or remote setting like 'latest'
Juan Blanco
@juanfranblanco
Apr 20 2018 09:44
if nothing is set it uses the current version included in the extension
zidzid1234
@zidzid1234
Apr 20 2018 09:45
Wow. Thank you. So the current version included in the extension is 0.4.17 ?
Juan Blanco
@juanfranblanco
Apr 20 2018 09:46
no it is 0.4.21
that might be the extended one that conflicts
ill make a release soon anyway to update the code generator
so it will be the latest
zidzid1234
@zidzid1234
Apr 20 2018 09:47
Okay, now I have completely uninstalled the extended extension, but "solidity.linter":"solium", makes the linter not working at all
Juan Blanco
@juanfranblanco
Apr 20 2018 09:47
ok
what settings you have
you may have outdated settings for solium
zidzid1234
@zidzid1234
Apr 20 2018 09:48
{"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
"editor.minimap.enabled": false,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.wordWrap": "on",
"workbench.iconTheme": "material-icon-theme",
"material-icon-theme.showUpdateMessage": false,
"solidity.compileUsingRemoteVersion" : "latest",
"solidity.linter":"solium",
"solidity.solhintRules": {
"extends": "default",
"rules": {
"avoid-throw": false,
"avoid-suicide": "error",
"avoid-sha3": "warn",
"indent": ["warn", 2]
}
},
"solidity.soliumRules": {
"no-inline-assembly": 5,
"imports-on-top": 0,
"variable-declarations": 0,
"indentation": ["error",2],
"quotes": ["error","double"]
},
"solidity.validationDelay": 1000,
"files.associations": {
"*.sol": "solidity"
},
}
Juan Blanco
@juanfranblanco
Apr 20 2018 09:50
try simple rules like
"solidity.soliumRules": {
"imports-on-top": 0,
"variable-declarations": 0
},
although those seem fine
zidzid1234
@zidzid1234
Apr 20 2018 09:53
linter is not working at all...
Juan Blanco
@juanfranblanco
Apr 20 2018 09:53
that is strange
zidzid1234
@zidzid1234
Apr 20 2018 09:53
as I have typed some nonsense typos but no warning/error at all
Juan Blanco
@juanfranblanco
Apr 20 2018 09:54
remove "solidity.validationDelay": 1000,
also restart
visual studio code
well first restart
then remove that setting
although the default is 1500 so it should be faster
zidzid1234
@zidzid1234
Apr 20 2018 09:55
Okay just restarted vscode, but still the same :(
Juan Blanco
@juanfranblanco
Apr 20 2018 09:56
have you got liveshare?
zidzid1234
@zidzid1234
Apr 20 2018 09:58
Not yet. let me get it now...
I am new to this liveshare
Juan Blanco
@juanfranblanco
Apr 20 2018 09:58
oh ignore it
is not released
it is in preview
but when it comes it will be handy
image.png
i have updated visual studio and reinstalled just in case it is in the extension end
but the linter works
zidzid1234
@zidzid1234
Apr 20 2018 10:03
Wow. You are using 0.4.23! That's the latest. Let me reinstall my extension as well.
Juan Blanco
@juanfranblanco
Apr 20 2018 10:05
image.png
Juan Blanco
@juanfranblanco
Apr 20 2018 10:15
@zidzid1234 my settings
zidzid1234
@zidzid1234
Apr 20 2018 10:18
yes, I don't know why my linter in vscode(of the latest version 1.22.2) is not working :( I am on Linux though, does that matter?
Juan Blanco
@juanfranblanco
Apr 20 2018 10:18
no it shouldn't be a problem
i have just deleted my linux vm
what are the chances eh?
zidzid1234
@zidzid1234
Apr 20 2018 10:19
:worried:
Juan Blanco
@juanfranblanco
Apr 20 2018 10:20
ill setup one and test it to validate
but it should not be an issue
have you tested it on a vanilla project
with my settings?
ie.. new folder
simple solidity file
and the user settings above?
zidzid1234
@zidzid1234
Apr 20 2018 10:24
Okay the linter is working now...
on my another simpler sol file
Juan Blanco
@juanfranblanco
Apr 20 2018 10:24
cool :D
zidzid1234
@zidzid1234
Apr 20 2018 10:25
The linter is fine with 0.4.23 now :)
Juan Blanco
@juanfranblanco
Apr 20 2018 10:25
cool, so your main issue is that the forked extension was highjacking this one
hence you had the old version
of the compiler
zidzid1234
@zidzid1234
Apr 20 2018 10:43
Indeed. THANK YOU! :clap: :satisfied:
Juan Blanco
@juanfranblanco
Apr 20 2018 10:45
Thanks to you too :)
zidzid1234
@zidzid1234
Apr 20 2018 10:45
I will clarify that in my Github issue page
Juan Blanco
@juanfranblanco
Apr 20 2018 10:46
Great thanks
also ill write a note on the order of preference of compilers on the readme as it was not clear
Psilon
@Pzixel
Apr 20 2018 11:18
@juanfranblanco hello again juan
I need your help
I have a contract that has uint value which also can be null
I don't see Encoder that handles nullable values
can you please give me an advice what byte[] Encode(object value) result represents null values?
Juan Blanco
@juanfranblanco
Apr 20 2018 11:36
everything in solidity it is initiated as zero
you could use an empty array
Unfortunately I'm not able to build the whole nethereum locally (it always complains about Common.Logging.Core, I'm not sure why)
so I really hope you merge and publish nuget asap
Juan Blanco
@juanfranblanco
Apr 20 2018 11:50
that needs to be tested in solidity
that won't fly
Psilon
@Pzixel
Apr 20 2018 11:50
yep
I wanted to test it but I can't run it
Juan Blanco
@juanfranblanco
Apr 20 2018 11:51
you need to install that package
althouhg you wont need it
for abi conversion
you are mainly implying that nullable types
like int?
uint?
can be converted directly to an object
well it is not correct
because their value expected is zero
Psilon
@Pzixel
Apr 20 2018 11:53
well
Juan Blanco
@juanfranblanco
Apr 20 2018 11:53
so the user needs to work on that fact
the encoding will be converted to
Psilon
@Pzixel
Apr 20 2018 11:53
Solidity expects their default value is null
Juan Blanco
@juanfranblanco
Apr 20 2018 11:53
0000000000000000000000000000000000000000000
no the value is 0
Psilon
@Pzixel
Apr 20 2018 11:54
Hmm
okay
the default value of an int uint is 0
if you are working with bytes yeah
so mainly having solidity expecting a byte[]
that has no values
ie lenght zero
then you can do your magic to convert it to int / uint
so the conversation we are having is great :)
all the users that have this doubt should think about it..
imagine end user that does not touch solidity
and thinks he is passing a null value
the other solidity developer thinks the opposite and has not dealt for that fact
like an external smart contract
Psilon
@Pzixel
Apr 20 2018 11:58
Yes, for some reason I was recalling that default is null
I just was wrong:)
Juan Blanco
@juanfranblanco
Apr 20 2018 12:00
just temporarily forgotten
it happens :)
Psilon
@Pzixel
Apr 20 2018 12:21
Close a PR then please
Juan Blanco
@juanfranblanco
Apr 20 2018 12:22
done
Daniel Krotov
@xtr33me
Apr 20 2018 12:43
Screen Shot 2018-04-20 at 8.40.27 AM.png
@juanfranblanco Thanks for the info. I re-downloaded the latest unity build and sure enough keystore was there. Unsure what the heck I downloaded before, so sorry about that. I am currently getting an error around an object reference not being set to an instance of an object and it seems to be tied to the Signing of a transaction. You mentioned that before...that I can just sign it myself, but I wasn't quite sure what you meant. Might you elaborate?
Juan Blanco
@juanfranblanco
Apr 20 2018 12:45
what is your private key you user for testing?
ALSO NOTE IT IS FOR TESTING
not the same as you use to hold your real Ether
Daniel Krotov
@xtr33me
Apr 20 2018 12:50
So as you can probably already tell, I'm new to blockchain. I am taking a course and they through a quick sample together which pulled some info from a wallet in unity and referred us to your project. We have just used metamask for that and the Ropsten Test net. So that is what I have been using for projects outside of unity as well. Now the first week they had us install geth just to go through the process, but primarily we have just been using the Ropsten testnet for testing via metamask.
Juan Blanco
@juanfranblanco
Apr 20 2018 12:51
yes no problem dont worry about that
every feedback as a starter is fantastic feedback
just trying to figure out why you have null values
hence I am asking when you are signing what is the key you are using just to check if it is null
no need to post it
just to validate it is there
Daniel Krotov
@xtr33me
Apr 20 2018 12:57
In the score manager do I need to select "External Provider"? I don't believe I would select that since I'm using the Unity player though right? And the private key I have assigned is the same one you had in the TopScoreService. Should I have changed that? I only modified the addressOwner and userAddress to mytest account :p
Daniel Krotov
@xtr33me
Apr 20 2018 13:06
Ok....so I just got my private key from metamask and assigned it to the _privatekey variable in TopScoreService but I still have the same issue. I'm going to see if I can trace where the null is coming from. Thanks again
Juan Blanco
@juanfranblanco
Apr 20 2018 13:07
yeah thats about it
Daniel Krotov
@xtr33me
Apr 20 2018 13:33
I just wanted to post here incase anyone runs into this in the future. So it seems that in TopScoreService's CheckSubmitScore, when it was creating the transactionSignedRequest it was using GameControl.instance.Key and not _privateKey, which was returning null since it didn't seem to be assigned at any point that I could find. So I assigned GameControl.instance.Key = _privateKey in the "Start" block and that issue is resolved. Is that the way you would have recommended doing this? Now I am only getting the "exceeds gas block limit" error which I will see if I can find the source of.
CryptoAlphaOne
@CryptoAlphaOne
Apr 20 2018 13:41
@juanfranblanco I do not know what changed, but I succeeded in sending with up to a thousandth of a cent. Now I can continue with my dream of writing a code for an Exclange! Thanks for all the support. Would you like to indicate a network of forehead for BitCoin in the mold of Rospten for the Etherium?
Daniel Krotov
@xtr33me
Apr 20 2018 13:53
@juanfranblanco In the function checkSubmitScore, are we supposed to modify the transactionInput at all? I noticed gas is large, but I'm assuming this is in GWEI so it is ok, but there is also no valueAmount passed. Is that fine?
Juan Blanco
@juanfranblanco
Apr 20 2018 13:56
@CryptoAlphaOne it is ok, thanks for the feedback we (well Gael who is the super tech writer) will add a workbook to explain how to set the gas price
I just wanted to post here incase anyone runs into this in the future. So it seems that in TopScoreService's CheckSubmitScore, when it was creating the transactionSignedRequest it was using GameControl.instance.Key and not _privateKey, which was returning null since it didn't seem to be assigned at any point that I could find. So I assigned GameControl.instance.Key = _privateKey in the "Start" block and that issue is resolved. Is that the way you would have recommended doing this? Now I am only getting the "exceeds gas block limit" error which I will see if I can find the source of.
@xtr33me yes
there is one key for the user sending the transaction
and one key for the game to sing it to verify the user is not tampering with the code
and sending his own scores
Daniel Krotov
@xtr33me
Apr 20 2018 13:58
Ahh ok
Juan Blanco
@juanfranblanco
Apr 20 2018 13:58
that is kind of hidden in the Flappy Eth game, even if we all know the key
but to demonstrate what is possible
In the source code is visible
anyway
Daniel Krotov
@xtr33me
Apr 20 2018 14:00
That makes sense thank you
Juan Blanco
@juanfranblanco
Apr 20 2018 14:03
It will get easier, with a project template and code generated integration points
Daniel Krotov
@xtr33me
Apr 20 2018 14:14
Yea...I thought I had grips on things until I realized that I didn't :) Just more practice and time will resolve that I guess. Quick question...so when I created the contract playerScore.sol via remix, I literally just hit create with the default values. I now see there is a "Gas limit" value populated there of 3000000 and a value of 0. Is this where these settings are initially set? Is that what my gas limit is that I keep getting my errors for?
Holy crap that worked! I changed the value in the call to CreateSetTopScoreTransactionInput to 3000000 and it set the top score. Couldn't have done it without your help! Thank you so much for your patience. Do you by chance have an eth wallet I can make a donation to for your help?
ShermanMeredith
@ShermanMeredith
Apr 20 2018 16:50
@juanfranblanco I do declare the bytes32 as a string, the result looks like this: J(��m�ւ�K����c�,�M�}���x!�
public class DataDto
{
    [Parameter("string", "name", 1)]
    public string Name { get; set; }
    [Parameter("bytes32", "data", 2)]
    public string Data { get; set; }
    [Parameter("bytes32", "moreData", 3)]
    public string moreData { get; set; }
}
looks like this
Juan Blanco
@juanfranblanco
Apr 20 2018 18:08
@ShermanMeredith then your string is not utf8 encoded
so you just want the bytes?
@xtr33me it is great that you are sorted :) although it might have take a while I think it is better than working by magic. Thanks for the offer btw apprecited
ShermanMeredith
@ShermanMeredith
Apr 20 2018 18:23
yes, the raw bytes in hex
Juan Blanco
@juanfranblanco
Apr 20 2018 18:24
ah then you want the byte[]
and then use your custom conversion
ShermanMeredith
@ShermanMeredith
Apr 20 2018 18:24
so public byte[] Data { get; set;} ?
Juan Blanco
@juanfranblanco
Apr 20 2018 18:25
no List<byte[]> Data {get; set;}
then you could use ToArray().ToHex()
if you want
ShermanMeredith
@ShermanMeredith
Apr 20 2018 18:34
thanks!
ShermanMeredith
@ShermanMeredith
Apr 20 2018 18:59
It's still not working...
I assumed ToHex() you meant Nethereum.Hex.HexConvertors.Extensions.HexByteConvertorExtensions.ToHex()?
Im getting an error when I do it exactly the way you typed
Nethereum.Hex.HexTypes.HexBigInteger = Nethereum.Hex.HexConvertors.Extensions.HexByteConvertorExtensions.ToHex(Data.ToArray());
gives me the error message
Argument `#1' cannot convert `byte[][]' expression to type `byte[]'
if I do List<byte> Data {get;set;}, then the value is a byte[] expression, but then I get this error:
Cannot implicitly convert type `string' to `Nethereum.Hex.HexTypes.HexBigInteger'
It's interpreting the byte[] value as a string
ShermanMeredith
@ShermanMeredith
Apr 20 2018 19:28
The system won't let me use List<Byte[]> as an output type anyway. byte[] is the only thing I can use.
ShermanMeredith
@ShermanMeredith
Apr 20 2018 19:42
Ok yes this works now!
string dataStr = Nethereum.Hex.HexConvertors.Extensions.HexByteConvertorExtensions.ToHex(result.Data);
[FunctionOutput]
public class DataDTO{
[Parameter("bytes32", "data", 1)]
public byte[] Data{ get; set; }
[Parameter("bytes32", "moreData", 2)]
public byte[] MoreData{ get;set; }
}