These are chat archives for Nethereum/Nethereum

9th
Apr 2018
Psilon
@Pzixel
Apr 09 2018 09:19
Hello guys
I have a problem that I want to pass GUID to my smart contract
I have following code
var myEvent = contract.GetEvent("myEvent");
string guid = Guid.NewGuid().ToString();
var filterEvent = await myEvent.CreateFilterAsync(guid);
with fails with 'Invalid params: Invalid variadic value type: invalid length 192, expected a 0x-prefixed, padded, hex-encoded hash with length 64.'

where my event is just:

event myEvent(string indexed eventId, address result);

what's wrong?
yanevkurse
@yanevkursee_twitter
Apr 09 2018 13:15
hi guys. tell me please how can I decode eth json with the help of nethereum? thanks for answer
David Burela
@DavidBurela
Apr 09 2018 14:46

@juanfranblanco using Nethereum within Unity on a customer project.
Plan is to just use the Nethereum.HDWallet and have it generate a 12 word phrase that the player can use.
The documentation doesn't have an example of Nethereum.HDWallet generating a random phrase for you http://nethereum.readthedocs.io/en/latest/Nethereum.Workbooks/docs/nethereum-hdwallet-infura-transfer/

and when I look through Nethereum.HDWallet/wallet.cs I can't see any obvious way to do it.

Is there another class I should be looking at, to generate a 12 word Mnemonic

Juan Blanco
@juanfranblanco
Apr 09 2018 14:53
@DavidBurela use Wordlist.English, WordCount.Twelve in the constructor
as an example
David Burela
@DavidBurela
Apr 09 2018 14:53
champion
Juan Blanco
@juanfranblanco
Apr 09 2018 14:53
It comes from NBitcoin
David Burela
@DavidBurela
Apr 09 2018 14:54
ah that's why.
I searched through the entire GitHub.com/nethereum organisation trying to figure out where the Mnemonic class came from. didn't realise it came from NBitcoin
Juan Blanco
@juanfranblanco
Apr 09 2018 14:54
Yes it is the same :)
Nbitcoins comes from another implementation (just to make it more fun) but they made portable / .net core compatible
and refactor it :)
But I may have to in the Unity3d scenario port it again to make it AOT compatible
David Burela
@DavidBurela
Apr 09 2018 15:01
I should really say thank you by submitting a pull request to the HD wallet doco page with that info you just gave me. I'll see if I get a chance at the end of this week http://nethereum.readthedocs.io/en/latest/Nethereum.Workbooks/docs/nethereum-hdwallet-infura-transfer/
Juan Blanco
@juanfranblanco
Apr 09 2018 15:01
@DavidBurela Also make sure you put a password
as all the words are public and whilst rather hard to create a dictionary attack
still is an option
Thanks @DavidBurela feel free :)
or if you want to pull any workbooks
that is where the source is ^^
Juan Blanco
@juanfranblanco
Apr 09 2018 16:36
this is awesome
Psilon
@Pzixel
Apr 09 2018 17:00
Still don't understand what am I doing wrong
Juan Blanco
@juanfranblanco
Apr 09 2018 17:00
hi
Psilon
@Pzixel
Apr 09 2018 17:00
I have following code:
var abi = new ABIDeserialiser().DeserialiseContract(_ethereumSettings.FactoryAbi);
var function = abi.Functions.Single(f => f.Name == "myFunc");
var transactionInput = new TransactionInput
{
    From = _ethereumSettings.AccountAddress,
    Gas = new HexBigInteger(4300000),
    Data = new FunctionCallEncoder().EncodeRequest(function.Sha3Signature, function.InputParameters, myparams)
};

string s = await web3.Personal.SignAndSendTransaction.SendRequestAsync(transactionInput, _ethereumSettings.AccountPassword);
TransactionReceipt transactionReceipt = await PollForReceiptAsync(web3, s);
hello
I'm trying to call ethereum smart contract
Juan Blanco
@juanfranblanco
Apr 09 2018 17:01
?
Psilon
@Pzixel
Apr 09 2018 17:01
this code executes without errors but my smart contract still empty
what could be wrong?
Juan Blanco
@juanfranblanco
Apr 09 2018 17:01
why are you doing it this way
although interesting
Psilon
@Pzixel
Apr 09 2018 17:02
because I have to specify account password because if I call it via SendTransactionAndWaitForReceiptAsync which doesn't allow to specify password it fails with Request has been rejected because of queue limit.
and the only way I found is performing requests from web3.Personal
Juan Blanco
@juanfranblanco
Apr 09 2018 17:03
an account password?
Psilon
@Pzixel
Apr 09 2018 17:03
yes
Juan Blanco
@juanfranblanco
Apr 09 2018 17:04
just use ManagedAccount
var web3 = new Web3(new ManagedAccount(addresss, password));
Psilon
@Pzixel
Apr 09 2018 17:04
ok, thank you for advice
however, shouldn't it be already working as it is, although be ugly?
Juan Blanco
@juanfranblanco
Apr 09 2018 17:05
then dont encode the requests and all that
it is not ugly :)
just there is not neadd
need
the problem with that is that when you want to change to a private key
which most probably you will or a different way to manage your accounts
you are are going to be dependent on that implementation
Psilon
@Pzixel
Apr 09 2018 17:08
hmm, ok
it's quite high level for an application that doesn't work at all)
Now it says gas is low :D
Juan Blanco
@juanfranblanco
Apr 09 2018 17:09
you have not supplied enough gas
Psilon
@Pzixel
Apr 09 2018 17:09
and I don't see any overload for SendTransactionAndWaitForReceiptAsync that takes both arguments and Gas
sorry if I'm officious
i'm really trying hard to learn nethereum)
Psilon
@Pzixel
Apr 09 2018 17:11
ahh right
my bad
Juan Blanco
@juanfranblanco
Apr 09 2018 17:12
no problem
check this out
Psilon
@Pzixel
Apr 09 2018 17:13
Now it's better - it just hangs instead of silently reporting that everything is ok
Juan Blanco
@juanfranblanco
Apr 09 2018 17:13
and you could try this
as all the code generation is moving to support work around that
Hanging
Are you mining?
What testchain are you suing?
Psilon
@Pzixel
Apr 09 2018 17:15
I have three parity nodes that are working fine via UI
now i'm trying to automate some interaction
Juan Blanco
@juanfranblanco
Apr 09 2018 17:16
are they POA?
(Proof of Authority)
Psilon
@Pzixel
Apr 09 2018 17:18
yep
Juan Blanco
@juanfranblanco
Apr 09 2018 17:18
so they should have mined instantly
and no hanging
mainly waiting for the receipt
are you running in a console?
are you calling an async method and not waiting / getting the result? (Easy mistake on the console)
Psilon
@Pzixel
Apr 09 2018 17:20
public async Task<string> StoreMyObjectAndGetAddressAsync(MyObject myObject)
{
    var web3 = new Web3(new ManagedAccount(_ethereumSettings.AccountAddress, _ethereumSettings.AccountPassword), _ethereumSettings.ParityConnectionString);
    var contract = web3.Eth.GetContract(_ethereumSettings.FactoryAbi, _ethereumSettings.FactoryContractAddress);
    var function = contract.GetFunction("newObject");
    var objectCreatedEvent = contract.GetEvent("ObjectCreated");
    object guid = Guid.NewGuid().ToByteArray();
    var filterEvent = await myObjectCreatedEvent.CreateFilterAsync();

    await function.SendTransactionAndWaitForReceiptAsync(_ethereumSettings.AccountAddress, new HexBigInteger(4300000), new HexBigInteger(4300000), functionInput: new[]
                                                                       {myObject.NumericId, (ulong) Math.Round(myObject.Price * 100), guid});
    // hanged
    ...
it's console so deadlock because of ConfigureAwait isn't a case
Juan Blanco
@juanfranblanco
Apr 09 2018 17:24
oh I meant on StoreMyObjectAndGetAddressAsync(object).Result
from the Main() on Console
Psilon
@Pzixel
Apr 09 2018 17:26
No, it's not the case
there is async Main
Juan Blanco
@juanfranblanco
Apr 09 2018 17:26
ah 7.1
sometimes it does not work I found out
Psilon
@Pzixel
Apr 09 2018 17:27
Yep, but others async are working fine
so I don't believe it's a problem
Juan Blanco
@juanfranblanco
Apr 09 2018 17:27
yes true
Psilon
@Pzixel
Apr 09 2018 17:28
I actually do
var task = Task.Run(() => listener.RunAsync(cancellationTokenSource.Token));

AssemblyLoadContext.Default.Unloading += _ =>
{
    logger.Information("Got stop message. Waiting current task to end...");
    cancellationTokenSource.Cancel();
};

Console.CancelKeyPress += (_, ccea) =>
{
    logger.Information("Got stop message. Waiting current task to end...");
    cancellationTokenSource.Cancel();
    ccea.Cancel = true;
};

await task;
so it should work correctly
because I'm not doing anything blocking here
Juan Blanco
@juanfranblanco
Apr 09 2018 17:29
you are not passing much Ether either
so i cannot see anything
Juan Blanco
@juanfranblanco
Apr 09 2018 17:44
@Pzixel i can only recommend you to simplify
further
Psilon
@Pzixel
Apr 09 2018 17:46
Okay
thank you for help
Guilherme Gustavo Gohr
@Momentanius
Apr 09 2018 18:31

Is there any working tutorial that teaches how to implement Smart Contracts using Visual Studio 2017? I can't find one that works (The ones I find didn't work properly), maybe you guys can give me a hand :)

Thanks!

Psilon
@Pzixel
Apr 09 2018 18:44
@Momentanius I've wrote an extension that allows to create and build solidity projects
however microsoft has broken some of my dependencies so it't doesn't compile anymore
But I can share built vsix that adds support into VS
Or you can try to build it yourself: https://github.com/Pzixel/Solidity
Guilherme Gustavo Gohr
@Momentanius
Apr 09 2018 18:50
Neat! I'll give it a go.
Psilon
@Pzixel
Apr 09 2018 18:53
As I said it may not compile becasue MS deleted on of required packages from nuget (Microsoft.VSSDK.BuildTools)
it I'l be glad if you fix ;)
Guilherme Gustavo Gohr
@Momentanius
Apr 09 2018 19:01
We'll try to fix it here in my company, but I can't promise anything. If I can do it, I'll inform you. Thanks again, Zhuk!
Psilon
@Pzixel
Apr 09 2018 19:08
np)
Psilon
@Pzixel
Apr 09 2018 19:17
@Momentanius hmm, I just fixed this bug so you can now just clone the latest repo version and start using it
there is a readme that helps to begin with
Guilherme Gustavo Gohr
@Momentanius
Apr 09 2018 19:30
Oh, so I'll download it again, then. Thanks again!
Psilon
@Pzixel
Apr 09 2018 19:31
I'm going to configure appveyor so you can download prebuilt artifacts. :)
however feel free to do it yourself:D
You have to have installled extensibility workload in order to be able to compile the project
Psilon
@Pzixel
Apr 09 2018 21:05
Here we are