These are chat archives for Nethereum/Nethereum

3rd
May 2018
Steven
@code-sergeant
May 03 2018 00:05
Hey all, anyone active right now?
Pari Hoxha
@phoxha
May 03 2018 01:15
Can someone please guide me how to do token functions? Send, receive, balance etc.
Pari Hoxha
@phoxha
May 03 2018 01:25
Any code samples?
you can run the workbook there using Xamarin
or you can try the windows simple wallet
or the avalonia simple wallet
that helps too
nibirc
@nibirc
May 03 2018 06:47
While using the following command: var encoded = web3.OfflineTransactionSigning.SignTransaction(PK, To, 10, txCount.Value); I am getting this error: 'Web3' does not contain a definition for 'OfflineTransactionSigning' and no extension method 'OfflineTransactionSigning' accepting a first argument of type 'Web3' could be found
danielcostaext
@danielcostaext
May 03 2018 07:50

Hello everyone, I'm starting on the blockchain world and I have a question which I dont know if might seem stupid or not.

Here in our company we have kind of a pilot which has the goal of making a .NET app (MVC5) communicate with a private ethereum network (handling of user keys is not an issue). Is it possible to make and validate transactions from our .NET app to the private network using Nethereum?

Juan Blanco
@juanfranblanco
May 03 2018 10:04
@nibirc it is static now use Web3.OfflineTransactionSigner
also you have a full sample connecting to Rinkeby
so you should not have any issues connecting there
I am still confused how was that happening to you
@danielcostaext yes it is possible
an example will be the Faucet
or in the cloud serverless
danielcostaext
@danielcostaext
May 03 2018 10:08
@juanfranblanco , Thank you very much for the answer!!!! I'll take a look on the links u sent! Thank you!!!
Pari Hoxha
@phoxha
May 03 2018 12:00
@Pzixel , thanks. I already created the token.
thanks @juanfranblanco, thats what I needed.
ProVR Games
@provrgames_twitter
May 03 2018 13:27
hi i have a code snippet to send tokens to another address. it works fine with default 20 gasprice. but when i set gasprice, it provides a tx number but doesnt execute at all. it is ignored.
i will send the code now
ProVR Games
@provrgames_twitter
May 03 2018 13:39
// account with private key
var account = new Account("0xXXXXX...");
        var web3 = new Web3(account);

        var senderAddress = "0xXXXXX...";
        var receiverAddress = "0xXXXX";
        var contractAddress = "0xXXXX....";

        var transactionMessage = new TransferFunction()
        {
            FromAddress = senderAddress,
            To = receiverAddress,
            TokenAmount = 1000000
        };

        var transferHandler = web3.Eth.GetContractTransactionHandler<TransferFunction>();
        var transactionHash = await transferHandler.SendRequestAsync(transactionMessage, contractAddress);
the above code works by default 20 gasprice
but when i add these before sendrequestasync, it is ignored
web3.TransactionManager.DefaultGasPrice = new BigInteger(10);
web3.TransactionManager.DefaultGas = new BigInteger(70000);
or
transactionMessage.Gas = 70000;
transactionMessage.GasPrice = 4;
how can i send the token with my custom gasprice?
your help is greatly appreciated. i am stuck here
Psilon
@Pzixel
May 03 2018 14:08
@juanfranblanco hello again
Can I pass null value to the contract?
Or I can only pass an empty string?
Juan Blanco
@juanfranblanco
May 03 2018 14:10
transactionMessage.GasPrice = 4 ? or 10?
i think that might be the issue as you need to convert that from Gwei to wei
@Pzixel it will be the 0x00000000000000000
ProVR Games
@provrgames_twitter
May 03 2018 14:11
hi juan, how should i set it for example if i want 5 gasprice
instead of 20
Juan Blanco
@juanfranblanco
May 03 2018 14:12
Web3.Convert.ToWei(value, unit)
Psilon
@Pzixel
May 03 2018 14:12

@Pzixel it will be the 0x00000000000000000

If I pass an empty string it doesn't encode it as 0x00000000000000000, isn't it?

Juan Blanco
@juanfranblanco
May 03 2018 14:12
no that will be string.empty to utf8
ProVR Games
@provrgames_twitter
May 03 2018 14:12
if i neglect gas and gasprice they become null when i debug
Juan Blanco
@juanfranblanco
May 03 2018 14:12
which will later on will be string.empty
@provrgames_twitter yes
and default values will be used
ProVR Games
@provrgames_twitter
May 03 2018 14:13
so i should try like this:
transactionMessage.GasPrice = Web3.Convert.ToWei(5, unit);
what about unit part?
Juan Blanco
@juanfranblanco
May 03 2018 14:14
I am guessing that your 5 means 5 gwei
so that will be Gwei
ProVR Games
@provrgames_twitter
May 03 2018 14:14
yes i want 5 gwei.
Juan Blanco
@juanfranblanco
May 03 2018 14:14
so you need to convert your gwei to wei
ProVR Games
@provrgames_twitter
May 03 2018 14:15
do i need something for gas setting?
transactionMessage.Gas = 70000;
Juan Blanco
@juanfranblanco
May 03 2018 14:15
the gas will be estimated for you automatically
although you can override it
ProVR Games
@provrgames_twitter
May 03 2018 14:15
yes i want to override it to be sure on tx completes
Juan Blanco
@juanfranblanco
May 03 2018 14:16
well then set it yourself as you do
ProVR Games
@provrgames_twitter
May 03 2018 14:16
ok thx Juan and Pzixel for your comments.
i am very new to nethereum. already like it. very easy to use. just these nuances, i should handle
i will be informing about my efforts again. thx
Psilon
@Pzixel
May 03 2018 14:17
@juanfranblanco so nethereum doesn't allow to pass nonexisting string?
I think i'm ok with empty string as well but I just wonder
Juan Blanco
@juanfranblanco
May 03 2018 14:20
i think we had this conversation before
solidity has default values
Psilon
@Pzixel
May 03 2018 14:21
Well, now it just fails with nullref or something on client side
Juan Blanco
@juanfranblanco
May 03 2018 14:21
of course
i could create a string empty on the fly
and pass it to the smart contract
but is that right?
Psilon
@Pzixel
May 03 2018 14:31
I'm not sure
I just enlightened this a bit for your information
Juan Blanco
@juanfranblanco
May 03 2018 14:34
yeah thanks :) default values are strange
string null is okish but 0 default
is very strange for an end user perspective
i assume once is understood using a pre validation request will do the necessary assignment of the values
ProVR Games
@provrgames_twitter
May 03 2018 14:38
this worked perfectly :+1:
transactionMessage.Gas = 50000;
transactionMessage.GasPrice = Web3.Convert.ToWei(5, UnitConversion.EthUnit.Gwei);
i have another minor issue i guess about token amounts
this is transfer function
        var transactionMessage = new TransferFunction()
        {
            FromAddress = senderAddress,
            To = receiverAddress,
            TokenAmount = 1000000000000000000000
        };
i have token amount 200 with decimal 18 in the contract
if i want to send all i need 200 x 10^18 digits right?
and it doesnt fit to biginteger
what should i do?
ProVR Games
@provrgames_twitter
May 03 2018 14:43
i mean this. if i write tokenAmount = 1000000000000000000 , only 1 token is sent because of decimal 18. if i want to send lets say 10000 tokens, biginteger doesnt hold it.
Enigmatic
@EnigmaticUnreal_twitter
May 03 2018 14:55
Something like this perhaps?
BigInteger tokenQuantity;
BigInteger.TryParse("100000000000000000000000", out tokenQuantity);
Juan Blanco
@juanfranblanco
May 03 2018 14:58
if it is 18 decimals that is the Ether <-> Wei
so you could do something Web3.Convert.ToWei(200);
and yes string.Parse
Psilon
@Pzixel
May 03 2018 15:01
@juanfranblanco I have a question:
System.Exception : Invalid value for type 'Nethereum.ABI.Encoders.IntTypeEncoder': 0
   at Nethereum.ABI.Encoders.IntTypeEncoder.Encode(Object value)
   at Nethereum.ABI.ABIType.Encode(Object value)
   at Nethereum.ABI.FunctionEncoding.ParametersEncoder.EncodeParameters(Parameter[] parameters, Object[] values)
   at Nethereum.ABI.FunctionEncoding.FunctionCallEncoder.EncodeRequest(String sha3Signature, Parameter[] parameters, Object[] values)
   at Nethereum.Contracts.FunctionBuilder.GetData(Object[] functionInput)
   at Nethereum.Contracts.FunctionBuilder.CreateCallInput(Object[] functionInput)
   at Nethereum.Contracts.Function.CreateCallInput(Object[] functionInput)
   at Nethereum.Contracts.Function.CallAsync[TReturn](Object[] functionInput)
wtf?:)
It seems that it's because I use enum type in solidity and pass int
if I manually cast it to byte then it works
Juan Blanco
@juanfranblanco
May 03 2018 15:05
check your abi
also check the autogenerators
that might help you
you will get ui soon too ;)
Psilon
@Pzixel
May 03 2018 15:19
I don't use autogen, I'm fine on my own
The primary concern is that I don't have and don't want to use VSCode
Juan Blanco
@juanfranblanco
May 03 2018 15:20
we have ui stuff
ProVR Games
@provrgames_twitter
May 03 2018 15:20
this works great :) i just pass decimals from contract definition. thx.
var transactionMessage = new TransferFunction()
{
FromAddress = senderAddress,
To = receiverAddress,
TokenAmount = Web3.Convert.ToWei(200, 18)
};
Psilon
@Pzixel
May 03 2018 15:20
UI Stuff is bad in integrating into build process
we have already discussed it :)
Juan Blanco
@juanfranblanco
May 03 2018 15:20
we have .net core
stuff too
each on its own
same source
Psilon
@Pzixel
May 03 2018 15:21
Well, I didn't see how can I get solidity files get compiled and wrappers get generated via single msbuild call
Juan Blanco
@juanfranblanco
May 03 2018 15:22
but part of the build process should not skip unit testing
Psilon
@Pzixel
May 03 2018 15:22
If i'm wrong then I just give up and use whatever you say)
Juan Blanco
@juanfranblanco
May 03 2018 15:23
oh you can do that
but.. not everything is perfect
i don't believe in just generate and off you go
like we were talking about.. what do you do with those values
specific rules
data massaging
validation etc
ie.. the business logic
for integration
or simply force a type like int instead of a biginteger
Psilon
@Pzixel
May 03 2018 15:28
Well
Simple code generation is possible
You can then wrap it into something higher level
with business logic and so on
Juan Blanco
@juanfranblanco
May 03 2018 15:29
well that's why the code generation stuff
to make it easier
Psilon
@Pzixel
May 03 2018 15:29
Yes
I'm not against it
I just don't see it run in msbuild pipeline
Juan Blanco
@juanfranblanco
May 03 2018 15:29
me neither
Psilon
@Pzixel
May 03 2018 15:29
I'm writing something simiar by my own
I have some expirience in implementing code generation on Roslyn
So I will try to do it as it fits me
Juan Blanco
@juanfranblanco
May 03 2018 15:30
nice
Psilon
@Pzixel
May 03 2018 15:30
I don't think it becomes a serious project, but I really need it right now
Juan Blanco
@juanfranblanco
May 03 2018 15:30
i thought about roslyn but like you said
fitting in the msbuild is for custom use
check the gif
looks like a charm
I believe :)
Juan Blanco
@juanfranblanco
May 03 2018 15:31
but the issue is languages like f#
that are not part of Roslyn
Psilon
@Pzixel
May 03 2018 15:32
Well, I'm ok with single C#
i know that several libraries attempts to support not only C#
Juan Blanco
@juanfranblanco
May 03 2018 15:32
ha ha cool
Psilon
@Pzixel
May 03 2018 15:32
but stuff like F# and VB.Net too
but I'm not fan of it
Juan Blanco
@juanfranblanco
May 03 2018 15:32
well i am more of the .net side than just c#
even if use c# :)
i like your stuff rather cool
I used to do attribute based code generators a long time ago.. 2002
and actually thought about it for an abstract layer for an end user, but not roslyn
as it has to support f# (vb.net is part roslyn)
Psilon
@Pzixel
May 03 2018 15:35
Well, I think they have to migrate on Roslyn one day
The more tool appear for Roslyn the higher pressure would be
Juan Blanco
@juanfranblanco
May 03 2018 15:36
well idk i think they took a completely different turn
yes true
lets wait and see, I guess it will be hard as there are very different areas
but Roslyn is so nice :)
Psilon
@Pzixel
May 03 2018 15:41
yes, you get this code recompiled on just ctrl+s
wizardry)
Juan Blanco
@juanfranblanco
May 03 2018 15:42
ha ha
Psilon
@Pzixel
May 03 2018 15:43
so I agree, Roslyn is really cool
Juan Blanco
@juanfranblanco
May 03 2018 15:43
yeah very simple to walk through it
too
Psilon
@Pzixel
May 03 2018 15:44
Well, it's not that simple
there is still lack of documentation
however, it's quite intuitive
and you always have a charmant quoter
Juan Blanco
@juanfranblanco
May 03 2018 15:45
well lets rephrase that.. in comparison with others
other compiles, asts etc.. it is so easy
Psilon
@Pzixel
May 03 2018 15:46
Well, yes
Juan Blanco
@juanfranblanco
May 03 2018 15:48
ah that is nice the quoter
Psilon
@Pzixel
May 03 2018 15:50
It's not optimal but it really helps in creating valid generator without debugging
fyi I was writing this generation tool without running debugger because it just can't attach to the msbuild process (it lacks some pdbs I don't have)
so
well
I won't continue
You have already gotten the overall idea
Roslyn is the only way for me :D
Juan Blanco
@juanfranblanco
May 03 2018 15:52
well if you can create a dsl on top of that
totally
Psilon
@Pzixel
May 03 2018 15:53
I'l try to write it down in next several weeks
I'd like to hear your opition when I'm done
Juan Blanco
@juanfranblanco
May 03 2018 15:55
of course :)
jandroalvarez
@jandroalvarez
May 03 2018 16:32
hi!
i'm trying to filter events from a contract
using three topics
however, i'm getting all the time the following error
(wait a minute)
invalid argument 0: hex has invalid length 64 after decoding"
it only happens when I provide the third topic which is a bytes32
Juan Blanco
@juanfranblanco
May 03 2018 16:34
what is your event
is that indexed?
jandroalvarez
@jandroalvarez
May 03 2018 16:35
yes
i'll show you the abi
Juan Blanco
@juanfranblanco
May 03 2018 16:35
cool
jandroalvarez
@jandroalvarez
May 03 2018 16:35
"[{ 'constant': false, 'inputs': [ { 'name': 'thing', 'type': 'address' }, { 'name': 'content', 'type': 'bytes' }, { 'name': 'key', 'type': 'bytes' }, { 'name': 'nonce', 'type': 'bytes32' } ], 'name': 'push', 'outputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'function' }, { 'constant': true, 'inputs': [ { 'name': 'publisher', 'type': 'address' }, { 'name': 'thing', 'type': 'address' } ], 'name': 'getNonce', 'outputs': [ { 'name': 'nonce', 'type': 'bytes32', 'value': '0x0000000000000000000000000000000000000000000000000000000000000000' } ], 'payable': false, 'stateMutability': 'view', 'type': 'function' }, { 'inputs': [], 'payable': false, 'stateMutability': 'nonpayable', 'type': 'constructor' }, { 'anonymous': false, 'inputs': [ { 'indexed': true, 'name': 'publisher', 'type': 'address' }, { 'indexed': true, 'name': 'thing', 'type': 'address' }, { 'indexed': false, 'name': 'content', 'type': 'bytes' }, { 'indexed': false, 'name': 'key', 'type': 'bytes' }, { 'indexed': true, 'name': 'nonce', 'type': 'bytes32' } ], 'name': 'Pushed', 'type': 'event' }]"
the event is Pushed
if i provide publisher and thing, everything works fine
however if i send the nonce
i get the error
the weirdest thing
is that the nonce provided is the same as the nonce received if i only filter by publisher and thing (the other indexed topics)
(i only have one entry on the blockchain for that event and those topics)
i'll show you the custom result
public class PushedResult
{
[Parameter("address", "publisher", 1, true)]
public string Publisher { get; set; }
        [Parameter("address", "thing", 2, true)]
        public string Thing { get; set; }

        [Parameter("bytes", "content", 3, false)]
        public byte[] Content { get; set; }

        [Parameter("bytes", "key", 4, false)]
        public byte[] Key { get; set; }

        [Parameter("bytes32", "nonce", 5, true)]
        public byte[] Nonce { get; set; }
    }
`public class PushedResult
{
[Parameter("address", "publisher", 1, true)]
public string Publisher { get; set; }
        [Parameter("address", "thing", 2, true)]
        public string Thing { get; set; }

        [Parameter("bytes", "content", 3, false)]
        public byte[] Content { get; set; }

        [Parameter("bytes", "key", 4, false)]
        public byte[] Key { get; set; }

        [Parameter("bytes32", "nonce", 5, true)]
        public byte[] Nonce { get; set; }
    }`
sorry i was trying to show it nicer :(
Juan Blanco
@juanfranblanco
May 03 2018 16:40
ok let me check it
jandroalvarez
@jandroalvarez
May 03 2018 16:41
here is the byte[] as hexadecimal
2F-CF-35-4B-BB-8C-F7-F3-38-A3-B5-B7-A0-68-04-3A-2C-91-14-0B-6F-BD-03-AE-32-F7-B1-D6-ED-DF-12-4A
Juan Blanco
@juanfranblanco
May 03 2018 16:43
you know that the Publisher and Thing will be the hash
s they are indexed
jandroalvarez
@jandroalvarez
May 03 2018 16:44
sorry?
i didnt get it
Juan Blanco
@juanfranblanco
May 03 2018 16:45
oh.. sorry
i did not see the address :D
my bad
is the formatting
ignore it
jandroalvarez
@jandroalvarez
May 03 2018 16:45
ahh ok
forgot :)
Juan Blanco
@juanfranblanco
May 03 2018 16:45
can you save me a second
jandroalvarez
@jandroalvarez
May 03 2018 16:45
await pushed.CreateFilterAsync("0x4481D6d6BF93B4c16994Cf5cf4885c55b8A0777D", "0x928014e42199b7C9f7A37b0a78060D7EA4C23ea0", nonce, BlockParameter.CreateEarliest(), BlockParameter.CreateLatest());
Juan Blanco
@juanfranblanco
May 03 2018 16:46
and copy the solidity event
jandroalvarez
@jandroalvarez
May 03 2018 16:46
this si the called to create filter where everything fails
Juan Blanco
@juanfranblanco
May 03 2018 16:46
so i can recreate the contract
jandroalvarez
@jandroalvarez
May 03 2018 16:46
give me a sec
Juan Blanco
@juanfranblanco
May 03 2018 16:46
oh where does it fail?
on the filter creation?
jandroalvarez
@jandroalvarez
May 03 2018 16:48
yes
sorry i didnt mention
event Pushed(
address indexed identity,
bytes content,
bytes keys,
uint indexed nonce,
address indexed origin
);
ooops it is not the contract
i was looking for it bc i didnt create it
but it seems an old version
i'm digging into the repo
Juan Blanco
@juanfranblanco
May 03 2018 16:50
ok i have to go now ill check it later
jandroalvarez
@jandroalvarez
May 03 2018 16:50
ok i'll leave it here if i find it
otherwise i'll ask a colleague tomorrow (i'm in spain)
and there's no one in the office now
Juan Blanco
@juanfranblanco
May 03 2018 17:06
ok no problem
jandroalvarez
@jandroalvarez
May 03 2018 17:10
i didnt find it :(
i have to leave the office now
i'll ask tomorrow morning and i'll put it here
thanks!
Juan Blanco
@juanfranblanco
May 03 2018 17:47
@jandroalvarez check the latest commit it has a sample