These are chat archives for Nethereum/Nethereum

27th
Jun 2018
Truong Dang Nghia
@DangNghia123_twitter
Jun 27 2018 00:20
hi anyone, i have a idea, i will create a smart contract to auto tranfer eth from one wallet to multiple wallets, receiver wallets will send 0 eth to smart contract and get amount of eth from sender wallet but if receiver wallet has 0 eth for gas price , will the transaction be executed?
tmyngu11
@tmyngu11
Jun 27 2018 01:36
I cant seem to get the DTO functions working. I keep getting this error.
The DTO work when i try the Flappy eth where it reads the array, but doesnt work when I try getting function outputs of my own contract
IndexOutOfRangeException: Array index is out of range.
System.Numerics.BigInteger..ctor (System.Byte[] value)
Nethereum.ABI.Decoders.IntTypeDecoder.DecodeBigInteger (System.Byte[] encoded)
Nethereum.ABI.Decoders.IntTypeDecoder.Decode (System.Byte[] encoded, System.Type type)
Nethereum.ABI.ABIType.Decode (System.Byte[] encoded, System.Type type)
Nethereum.ABI.Decoders.ArrayTypeDecoder.DecodeStaticElementType (System.Byte[] encoded, System.Type type)
Nethereum.ABI.Decoders.ArrayTypeDecoder.Decode (System.Byte[] encoded, System.Type type)
Nethereum.ABI.Decoders.DynamicArrayTypeDecoder.Decode (System.Byte[] encoded, System.Type type)
Nethereum.ABI.ABIType.Decode (System.Byte[] encoded, System.Type type)
Nethereum.ABI.FunctionEncoding.ParameterDecoder.DecodeOutput (System.String output, Nethereum.ABI.FunctionEncoding.ParameterOutput[] outputParameters)
Nethereum.ABI.FunctionEncoding.ParameterDecoder.DecodeAttributes[TokensOfOwnerOutputDTO1] (System.String output, .TokensOfOwnerOutputDTO1 result, System.Reflection.PropertyInfo[] properties)
Nethereum.ABI.FunctionEncoding.FunctionCallDecoder.DecodeFunctionOutput[TokensOfOwnerOutputDTO1] (.TokensOfOwnerOutputDTO1 functionOutputResult, System.String output)
Nethereum.ABI.FunctionEncoding.FunctionCallDecoder.DecodeFunctionOutput[TokensOfOwnerOutputDTO1] (System.String output)
Nethereum.Contracts.FunctionBase.DecodeDTOTypeOutput[TokensOfOwnerOutputDTO1] (System.String output)
ScoreContractService.DecodeTopScoreDTO (System.String result) (at Assets/Scripts/ScoreContractService.cs:90)
TopScoreService+<GetTopScores>c__Iterator0.MoveNext () (at Assets/Scripts/TopScoreService.cs:80)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
Juan Blanco
@juanfranblanco
Jun 27 2018 06:30
@tmyngu11 can you post a sample?
I'll see where is failing
Also if you install the vscode extension will generate it for you
Juan Blanco
@juanfranblanco
Jun 27 2018 06:35
codegenerationv1.gif
codegenerationv3.gif
Juan Blanco
@juanfranblanco
Jun 27 2018 06:50
here are the new and old code generators
to try
Stef Heyenrath
@StefH
Jun 27 2018 06:53
@tmyngu11 Can you post your contract?
Zeshan Virk
@zeshanvirk
Jun 27 2018 07:43
what is the logic behind generating a paper wallet for ethereum?
how can i achieve this in web integration of ethereum using nethereum?
just generate a new Account
and display the private / address using qr
Zeshan Virk
@zeshanvirk
Jun 27 2018 10:12
when we generate new Account it gave us address only
how to get private key of address generated?
is the password is private key that we used to generate new account?
Juan Blanco
@juanfranblanco
Jun 27 2018 10:13
???
i think we are talking about different accounts :)
check the creating an account in the docs above
Zeshan Virk
@zeshanvirk
Jun 27 2018 11:00
can we import our ether wallet somewhere else using our password that we used to generate account?
Zeshan Virk
@zeshanvirk
Jun 27 2018 11:33
i generated an account on geth using password 123456.. it gave me an adresss, i sent some testnet ether on it, Now how can i export that account to MyEtherWallet.com?
Juan Blanco
@juanfranblanco
Jun 27 2018 11:43
if you used geth find it in your path
as per the docs above
the key store file
Zeshan Virk
@zeshanvirk
Jun 27 2018 12:07
but what if i want to export on the basis of private key?
how can i get the private key of address?
Juan Blanco
@juanfranblanco
Jun 27 2018 12:32
the same is on that doc
use the keystore service to decrypt the file
Zeshan Virk
@zeshanvirk
Jun 27 2018 12:35
tried but getting this exception
Cannot derive the same mac as the one provided from the cipher and derived key
what does that mean?
Juan Blanco
@juanfranblanco
Jun 27 2018 12:38
There is a problem generating the same mac
so is your password the same?
Zeshan Virk
@zeshanvirk
Jun 27 2018 12:40

http://nethereum.readthedocs.io/en/latest/accounts/

var account = Nethereum.Web3.Accounts.Account.LoadFromKeyStoreFile(accountFilePath, string password);

that code gave me Account doesn't contains the definiton of LoadFromKeyStoreFile

yes
Juan Blanco
@juanfranblanco
Jun 27 2018 12:44
if you are not using the full .net framework you have to load the json yourself
due to portability
Zeshan Virk
@zeshanvirk
Jun 27 2018 12:45
i'm using .net framework
Zeshan Virk
@zeshanvirk
Jun 27 2018 12:46

Cannot derive the same mac as the one provided from the cipher and derived key

What about this?

Juan Blanco
@juanfranblanco
Jun 27 2018 12:47
well
i dont know now your problem
can you post a snippet
Zeshan Virk
@zeshanvirk
Jun 27 2018 12:47
var password = "12345678";
            var keyStoreEncryptedJson =
                        @"{""address"":""37dfe826706323e01292b002cf09113f85377b7f"",""crypto"":{""cipher"":""aes - 128 - ctr"",""ciphertext"":""cbd175404554766d1d0248cd74cb69c673c2eebc4af7bef78351b05b904b128b"",""cipherparams"":{""iv"":""9b3ef8f2e5c09a6e3c4175bb80de8465""},""kdf"":""scrypt"",""kdfparams"":{""dklen"":32,""n"":262144,""p"":1,""r"":8,""salt"":""4543d3db86f66ccec9388b59de4a5a8f530e3c7ec1e5e0e264b1ebf83c84e495""},""mac"":""617e27751ab4d7294651ae70869f091df26ace1146a1332b0f2cdedbc1afa5f9""},""id"":""a8e80e2c - 78f2 - 4bc2 - 8846 - eae506b60e66"",""version"":3}";
            var account = Nethereum.Web3.Accounts.Account.LoadFromKeyStore(keyStoreEncryptedJson, password);
Juan Blanco
@juanfranblanco
Jun 27 2018 12:47
and your test keystore file
keyStoreEncryptedJson
is that yours
is that the one you have generated?
Zeshan Virk
@zeshanvirk
Jun 27 2018 12:49
yes
Juan Blanco
@juanfranblanco
Jun 27 2018 12:49
can you post the file
12.PNG
look LoadFromKeyStoreFile isn't available
Juan Blanco
@juanfranblanco
Jun 27 2018 12:53
sure
just copy and paste the code from there
if you are comfortable that your os supports it
what version of geth are you using?
Zeshan Virk
@zeshanvirk
Jun 27 2018 13:01
i copied and pasted, same error
don't know about the version
how can i know it?
Juan Blanco
@juanfranblanco
Jun 27 2018 13:02
ok sure i am looking into it
i can reproduce it
Zeshan Virk
@zeshanvirk
Jun 27 2018 13:08
waiting for you response
Juan Blanco
@juanfranblanco
Jun 27 2018 13:09
you will have to wait a while more as I can reproduce it
so I am trying to figure out if there is a bug or not
so this might take 1 minute or hours
Zeshan Virk
@zeshanvirk
Jun 27 2018 13:10
okay, if it is a bug then i've to update my lib?
no problem at all
take your time
:)
Juan Blanco
@juanfranblanco
Jun 27 2018 14:06
@zeshanvirk right i have created many accounts and i don't see any problem
i hit so many red herrings but it has endup being your same file
can you regenerate the account using your password?
Juan Blanco
@juanfranblanco
Jun 27 2018 14:14
image.png
so the simplest test was to actually using geth to decrypt your file
and it is not working
p0isoN
@p0isoNz_twitter
Jun 27 2018 15:18
@juanfranblanco
This is thanks to you!
tmyngu11
@tmyngu11
Jun 27 2018 16:39

@juanfranblanco @StefH Here is my code: https://gist.github.com/tmyngu11/71d1151a99ee86edb6ad7315760f7862

I feel like it should work but I keep getting the array bounds error

Juan Blanco
@juanfranblanco
Jun 27 2018 16:48
@p0isoNz_twitter that is really cool :)
very nice!!!
Juan Blanco
@juanfranblanco
Jun 27 2018 16:53
@tmyngu11 how many items do you have in the Array?
tmyngu11
@tmyngu11
Jun 27 2018 16:56
it would depend on each address but in this case, 2
the result is right i believe but the problem is decoding the result into the array
@juanfranblanco
Juan Blanco
@juanfranblanco
Jun 27 2018 16:59
yeah that is what I am wondering if it was due to an empty array
give me a second ill test it with the current
tmyngu11
@tmyngu11
Jun 27 2018 17:01
sure thing. it seems like the result is correct for other methods too, just decoding gives an error.
Juan Blanco
@juanfranblanco
Jun 27 2018 17:17
ok testing with Dev it works
let me do a pre dev release for Unity
and Ill post it
tmyngu11
@tmyngu11
Jun 27 2018 17:32
sure thing, was it something I did wrong though?
Juan Blanco
@juanfranblanco
Jun 27 2018 17:41
the truth is that is strange
as dynamic arrays have been supported for ages (and have not changed)
(like years :D)
and have not changed much!
but I am working on other bits and bobs on the area
Stef Heyenrath
@StefH
Jun 27 2018 17:43
@tmyngu11 Did you also post your contract as gist ?
Juan Blanco
@juanfranblanco
Jun 27 2018 17:43
so it is changing so it will be great to see if it works on your side
as v2 is adding more capabilities
with this dev stuff
tmyngu11
@tmyngu11
Jun 27 2018 17:44
thanks for looking into haha, I have been pulling my hair out the last few days trying to get it to work lol
this is my test contract
tmyngu11
@tmyngu11
Jun 27 2018 17:47
did your test work?
Juan Blanco
@juanfranblanco
Jun 27 2018 17:48
yep
tmyngu11
@tmyngu11
Jun 27 2018 17:48
I looked at other .net examples but could not get them to work with unity
Juan Blanco
@juanfranblanco
Jun 27 2018 17:48
this is why Im creating the net35 dlls for you
yes unity3d is a different beast
2 ticks and ill push some dlls
tmyngu11
@tmyngu11
Jun 27 2018 17:49
thank you so much, I really apprecite it :)
this is current dev version
@tmyngu11 let me know how it goes
tmyngu11
@tmyngu11
Jun 27 2018 18:00
ooh thanks again!!
tmyngu11
@tmyngu11
Jun 27 2018 18:20
for some reason the dll files make my unity crash
Juan Blanco
@juanfranblanco
Jun 27 2018 18:20
well that is the dev version
but thanks that gives me the flag for testing them now
ill upgrade the test simple sample to dev
including your test contract
tmyngu11
@tmyngu11
Jun 27 2018 18:25
sure thing, please be sure to let me know once you get a working version :)
[Function("GiveMeTheArray", "uint256[]")]
    public class GiveMeTheArrayFunction:ContractMessage
    {

    }

    [FunctionOutput]
    public class GiveMeTheArrayOutputDTO
    {
        [Parameter("uint256[]", "result", 1)]
        public List<BigInteger> Result {get; set;}
    }

    public IEnumerator GetArrayUInt256()
    {
        var contractAddress = "0xd0828aeb00e4db6813e2f330318ef94d2bba2f60";
        var url = "http://localhost:8545";
        var getDataCallUnityRequest = new EthCallUnityRequest(url);
        var functionMessage = new GiveMeTheArrayFunction ();
        var callInput = functionMessage.CreateCallInput(contractAddress);

        yield return getDataCallUnityRequest.SendRequest(callInput, Nethereum.RPC.Eth.DTOs.BlockParameter.CreateLatest());
        var result = getDataCallUnityRequest.Result;

        var output = functionMessage.DecodeDTOTypeOutput<GiveMeTheArrayFunction,GiveMeTheArrayOutputDTO>(result);
        Debug.Log (output.Result [0]);
        Debug.Log (output.Result [1]);
    }
tmyngu11
@tmyngu11
Jun 27 2018 19:49
oooh
Juan Blanco
@juanfranblanco
Jun 27 2018 19:51
As you can see is much simpler
new dlls in both the simple sample
and in the other url
tmyngu11
@tmyngu11
Jun 27 2018 20:04
looks like we dont have to write the contractservice script now??\
also how did u call the contract in the getarrayuint256 example?
Juan Blanco
@juanfranblanco
Jun 27 2018 20:20
The description of the contracts is in the messages
tmyngu11
@tmyngu11
Jun 27 2018 20:34
my unity still crashes when I try to make a new contract
Contract contract = new Contract(null, ABI, contractAddress);
tmyngu11
@tmyngu11
Jun 27 2018 20:43
@juanfranblanco
Juan Blanco
@juanfranblanco
Jun 27 2018 20:47
Ok I'll look at it tomorrow