These are chat archives for Nethereum/Nethereum

30th
Apr 2018
Juan Blanco
@juanfranblanco
Apr 30 2018 07:27
@kianmehr21 that should give you some results.. was your Transfer successful?
@dimonkov we will be starting making those generators soon, I want to refactor a bit the unity3d components so they are easier
to create the Calls and the Transactions
using the same Commands, DTOs as CQS
then the services will become as simple as the new ones
Kevin Small
@KevinSmall
Apr 30 2018 07:37

@juanfranblanco In the flappy unicorn demo, how do I work out what the partial private key value _privateKey needs to be here? https://github.com/Nethereum/Nethereum.Flappy/blob/ef48969b3fbcd2eea21dba0ad0eb319869998a4b/Scripts/TopScoreService.cs#L28

I deployed a fresh copy of playerscore.sol to Rinkeby, and everything works ok when I use the COMPLETE private key of the playerscore.sol contract address in _privateKey in TopScoreService.cs. How can I use a partial private key to do the same thing? I tried making the partial private key the first 44 chars but then transactions started failing:

Working high score tx (signed with gamer address+key and contract address+key) https://rinkeby.etherscan.io/tx/0xa36256975767774fb3afcd38fd1b8ad7f750fd55fb373981f94f6c3bcd946eec
Failing high score tx (signed with gamer address+key and contract address+key substring of 1st 44 chars) https://rinkeby.etherscan.io/tx/0x1be9745d94d9abac5a88cba29d98941a0c6158cc7de554043db14b71ca200022

Many thanks.

Juan Blanco
@juanfranblanco
Apr 30 2018 07:39
oh just put your full private key
i removed the logic to calculate the private key as it was rather complex
the full private key is the Nethereum test one
kianmehr21
@kianmehr21
Apr 30 2018 07:41

yes my transfer is successful
this test method pass success

public async Task TestTransactionMethod2()
        {
            var swecService = new SWECService();
            var acc1Token‌Before = await swecService.GetBalanceOfAsync<int>("0x1dc1579cf974EF4DFF28f67732Ff4607E3C1C033");
            var acc2Token‌Before = await swecService.GetBalanceOfAsync<int>("0x271E0ec77be1390edB93903d1B5bC258E293bBA3");

            TransferFunction tf = new TransferFunction()
            {
                FromAddress = "0x1dc1579cf974EF4DFF28f67732Ff4607E3C1C033",
                To = "0x271E0ec77be1390edB93903d1B5bC258E293bBA3",
                Gas = 4000000,
                TokenAmount = 5,
            };

            var transferEvent = swecService.GetTransferEvent();
            var filterInput = await transferEvent.CreateFilterAsync("0x1dc1579cf974EF4DFF28f67732Ff4607E3C1C033");
            TransactionReceipt res = await swecService.TransferAndWaitForReceiptAsync(tf);
            var logs = await transferEvent.GetFilterChanges<TransferEvent>(filterInput);

            var acc1TokenAfter = await swecService.GetBalanceOfAsync<int>("0x1dc1579cf974EF4DFF28f67732Ff4607E3C1C033");
            var acc2TokenAfter = await swecService.GetBalanceOfAsync<int>("0x271E0ec77be1390edB93903d1B5bC258E293bBA3");

            Assert.AreEqual(acc1TokenBefore - 5, acc1TokenAfter);
            Assert.AreEqual(acc2TokenBefore + 5, acc2TokenAfter);

        }

and TransferAndWaitForReceiptAsync in swecService

public async Task<TransactionReceipt> TransferAndWaitForReceiptAsync(TransferFunction transferMessage)
        {
            return await ContractHandler.SendRequestAndWaitForReceiptAsync(transferMessage);
        }

        protected Function GetTransferFunction()
        {
            return Contract.GetFunction("transfer");
        }
Juan Blanco
@juanfranblanco
Apr 30 2018 07:41
@KevinSmall ill modify it and put some comments
@kianmehr21 are you using a local node? like the geth poa?
kianmehr21
@kianmehr21
Apr 30 2018 07:43
I use Ganache private network
Juan Blanco
@juanfranblanco
Apr 30 2018 07:46
ok have you tried using geth poa? just validating is not ganache
also I will be releasing ASAP the nethererum integration testing
you can use that to validate your events
Kevin Small
@KevinSmall
Apr 30 2018 07:49
great thanks Juan
kianmehr21
@kianmehr21
Apr 30 2018 07:52
ok thanks. Do you think the problem is from Ganache?
Enigmatic
@EnigmaticUnreal_twitter
Apr 30 2018 08:07

Hi guys, is it possible to pass a BigInteger through Nethereum to a smart contract?
What I was doing was simply to pass a BigInteger object to a smart contract, however I am getting a System.ArgumentOutOfRangeException - Thinking it might be an encoding issue.

Dim maxUIntMinusOneDay As BigInteger = BigInteger.Parse("115792089237316195423570985008687907853269984665640564039457584007913129553528")
transactionHash = Await contractCall.SendTransactionAndWaitForReceiptAsync(account.Address, gas, gasPrice, value, Nothing, sentValue, maxUIntMinusOneDay) //threw an exception of type 'System.ArgumentOutOfRangeException'

I've tried to encode the BigInteger manually and it doesn't seem to work either:

Dim maxUIntMinusOneDay As BigInteger = BigInteger.Parse("115792089237316195423570985008687907853269984665640564039457584007913129553528")
Dim objEncode As New Nethereum.ABI.Encoders.IntTypeEncoder
Dim test = objEncode.Encode(maxUintMinusOneDay) //threw an exception of type 'System.ArgumentOutOfRangeException'

Maybe it is something obvious I am missing...

Juan Blanco
@juanfranblanco
Apr 30 2018 08:09
@EnigmaticUnreal_twitter added comments
and private key :)
@EnigmaticUnreal_twitter I guess it is one of the overloads
that is confusing your call
Have you tried the new code generator that uses the "Commands and Queries" in Vb.Net?
your feedback will be appreciated for that
codegenerationv1.gif
Enigmatic
@EnigmaticUnreal_twitter
Apr 30 2018 08:19

Private key? Where where? :D Ahaha. Nah, this is part of the solution for one of Smarx's CaptureTheEther challenge, I am logging down my steps with VB.NET.

Hmm... Not sure if it's overloads though, as I get the same error when I manually call IntTypeEncoder.Encode. Something reasonably big is still fine, but up to a point the number I am working with seems to be too big - Let me experiment a little more first.

Oooh I haven't tried the code generator yet! Looks awesome! I've seen you mentioning it on Twitter a couple weeks back but was a little occupied then. Will play with it this week - Thanks for coming up with this Juan!

Juan Blanco
@juanfranblanco
Apr 30 2018 08:20
oh sorry ignore the first comment
it was for @KevinSmall
Enigmatic
@EnigmaticUnreal_twitter
Apr 30 2018 08:20
nods :D Figured.
Juan Blanco
@juanfranblanco
Apr 30 2018 08:21
the code generator guesses your namespaces at the moment based on the location we will be adding some configuration
and release the UI this week
(the very simple UI ;) )
Kevin Small
@KevinSmall
Apr 30 2018 09:23
thanks Juan, that is all clear now
Kirankumar
@kiranbasvaraj
Apr 30 2018 10:16
Hi juan,
we followed your method for converting string in to byte32 which is described in this issue in github https://github.com/Nethereum/Nethereum/issues/219#event-1503484509. But i am getting exception as {System.ArgumentException: Destination array was not long enough. Check destIndex and length, and the array's lower bounds}
my abi inputs is this ""inputs"": [
{
""name"": ""WalletAddres"",
""type"": ""address""
},
{
""name"": ""Name"",
""type"": ""bytes32""
}]
can you please guide me . Thanks in adavance
Juan Blanco
@juanfranblanco
Apr 30 2018 11:30
@kiranbasvaraj is your name too long that it does not fit in a bytes32?
using UTF-8?
try using a string
instead
bytes32 fixed length string
string dynamic
Kirankumar
@kiranbasvaraj
Apr 30 2018 12:45
Yes it doesn't fit in byte32 because it is a keccak256 hash.
Juan Blanco
@juanfranblanco
Apr 30 2018 12:45
then use the byte array instead
of the string
Kirankumar
@kiranbasvaraj
Apr 30 2018 12:47
Let me try ..I will back to you if I face any issue.
Thanks .
Ganesh Prasad Kumble
@0zAND1z
Apr 30 2018 13:17
Can we convert a Hex string like the Keccack hash into a bytes 32?
The length is 66 (inclusing the “0x")
so how is it that I can pass the hashes in the Remix IDE as a string.. say “0x9fcbd636a8e7623a9223adfe34f4cf6cd48f1115318c199b72da2854cfde4af4” and gets converted into bytes32 implicitly :question:
But not happening in Nethereum call..
Getting type mismatch error
Right @kiranbasvaraj ?
Kirankumar
@kiranbasvaraj
Apr 30 2018 15:32
Yeah @kggp1995
topproto
@topproto
Apr 30 2018 16:54
hey all :) has anyone seen this error before service.EncryptAndGenerateDefaultKeyStoreAsJson(password, ecKey.GetPrivateKeyAsBytes(), ecKey.GetPublicAddress()); hits the following exception. ArgumentException: Cost parameter N must be > 1 and < 65536.
ecKey is just a simple var ecKey = Nethereum.Signer.EthECKey.GenerateKey();
@kggp1995 try var ecKey = Nethereum.Signer.EthECKey.GenerateKey();
var privateKey = ecKey.GetPrivateKeyAsBytes().ToHex();
topproto
@topproto
Apr 30 2018 19:20
never mind managed to fix it. had some junk in app.config <dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.1" newVersion="4.1.1.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.8.2.0" newVersion="1.8.2.0" />
</dependentAssembly>
it was overriding any dependency's added though References manually or using nuget.