These are chat archives for Nethereum/Nethereum

11th
Apr 2018
Juan Blanco
@juanfranblanco
Apr 11 2018 06:16
codegenerationv1.gif
a preview of the new code generator is in vscode
it supports vb.net and f#
note f# the files are not in order of dependency in the projects DTOs should be before of CQS
Juan Blanco
@juanfranblanco
Apr 11 2018 07:13
@TarrahArshad you cannot set the gas usage, that depends on what your smart contract do
every step in smart contract counts towards the gas, also storage, etc
if you want to use less gas, you need to optimise your contract for low gas usage
TarrahArshad
@TarrahArshad
Apr 11 2018 07:15
@juanfranblanco can u tell me how to i migration presale or crowdsale ? and whats is deferen between both ?
Psilon
@Pzixel
Apr 11 2018 08:37
@juanfranblanco great job!
I only have one question: can you provide this functionality as nuget package?
I mean some kind of await new MyCodeGenerator(GenerationType.CSharp).GenerateAsync(abiString, binString);
Juan Blanco
@juanfranblanco
Apr 11 2018 08:38
Yes it will be a nuget too
it is in .net
Psilon
@Pzixel
Apr 11 2018 08:39
I mean we currently have console app which is hard to integrate with
Juan Blanco
@juanfranblanco
Apr 11 2018 08:39
but the idea is to create a visual studio extension with the UI
Psilon
@Pzixel
Apr 11 2018 08:39
and some VSCode extension tool that it's completely impossible to integrate with
so I'm looking forward 3rd solution that can do it
Juan Blanco
@juanfranblanco
Apr 11 2018 08:39
the console app
Psilon
@Pzixel
Apr 11 2018 08:40
Console app seems to be a bit outdates. Another reason: I wasn't able to compile I'm not sure why
Juan Blanco
@juanfranblanco
Apr 11 2018 08:40
and vscode are not the solution :)
sorry my computer is going to a hault
cannot type fast enough
Luis Silva
@varsnotwars
Apr 11 2018 08:41

Hi, I have a solidity contract that has an event that takes a custom enum as an argument. I created a DTO but I'm unable to create a filter. The code is as follows:

Solidity:

   // custom enum:
    enum UpdatedEventType {
        Added,
        Subtracted
    }
    // event taking indexed enum as argument
    event Updated(UpdatedEventType indexed updateType,
        uint indexed amount,
        address indexed sender,
        uint result
        );

c#:

    public enum UpdatedEventType {
        Added,
        Subtracted
    }
    public class UpdatedEvent
    {
        [Parameter("UpdatedEventType","updateType", 1, true)]
        public UpdatedEventType UpdateType { get; set; }

        [Parameter("uint", "amount", 2, true)]
        public uint Amount { get; set; }

        [Parameter("address", "sender", 3, true)]
        public string Address { get; set; }

        [Parameter("address", "result", 4, false)]
        public uint Result { get; set; }
    }

// tried creating the filter like so:
var filter = await updatedEvent.CreateFilterAsync<UpdatedEventType>(UpdatedEventType.Added);
// also tried:
var filter = await updatedEvent.CreateFilterAsync(UpdatedEventType.Added);

I get this exception:
Invalid value for type 'Nethereum.ABI.Encoders.IntTypeEncoder': Added (NethereumExample.Models.UpdatedEventType)

I feel like I need to mark each c# enum value or something. Any help appreciated. Thanks

Juan Blanco
@juanfranblanco
Apr 11 2018 08:41
Ignore the console app..
Psilon
@Pzixel
Apr 11 2018 08:42
Ok. VSCode generates wrappers really great. When can I expect to be shareable via nuget? I'd like to integrate it in my current pipeline
It should be done automatically via CI and VSCode extension doesn't fit, unfortunately
Juan Blanco
@juanfranblanco
Apr 11 2018 08:42
there are two versions of the code generator a javascript one
and the .net one :)
and yes they will be packaged
and there is also a ui for them too which is pluggable
for extra generators
also cross platform (windows, linux, mac)
but simple :)
so it can be plugged into visual studio as wpf
@varsnotwars UpdatedEventType should be an uint256
[Parameter("UpdatedEventType","updateType", 1, true)]
UpdatedEventType to uint256
check your abi
also your uint should be an uint256
@Pzixel I will find out this week about the other extension
Psilon
@Pzixel
Apr 11 2018 08:48
@juanfranblanco thank you. I hope WPF and other UI things would be optional
Juan Blanco
@juanfranblanco
Apr 11 2018 08:48
well as things will get more interesting
the ui will be required
if you look at to optimise smart contracts
there are specific senarios that you want to use certain types
but limit it them to a smaller type when using .net
so as things grow and more complex business logic, the ui capability is good
or complex generators :)
Psilon
@Pzixel
Apr 11 2018 09:01
UI is great
but I'm looking toward some automatic solution that can be just integrated into msbuild
as custom task
Juan Blanco
@juanfranblanco
Apr 11 2018 09:02
sure.. for the base cotntract layer
unit tests integrations etc
ui
apis
xamarin
etc
blazor
might need more settigns
unity3d
Psilon
@Pzixel
Apr 11 2018 09:11
So it there will be some ContractGenerator.Core and all these things will be based on it, then I'm satisfied and waiting for it be released
Luis Silva
@varsnotwars
Apr 11 2018 09:24
@juanfranblanco , I made the suggested changes and I'm still receiving the same exception. I checked the abi and the type for the enum param is uint8, which I also tried:
{\"indexed\":true,\"name\":\"updateType\",\"type\":\"uint8\"
Juan Blanco
@juanfranblanco
Apr 11 2018 09:45
ah of course
then use uint8
[Event("Updated")]
public class UpdatedEventDTO
{
[Parameter("uint8", "updateType", 1, true )]
public byte UpdateType {get; set;}
[Parameter("uint256", "amount", 2, true )]
public BigInteger Amount {get; set;}
[Parameter("address", "sender", 3, true )]
public string Sender {get; set;}
[Parameter("uint256", "result", 4, false )]
public BigInteger Result {get; set;}
}
this is the generated one
TarrahArshad
@TarrahArshad
Apr 11 2018 11:51
@juanfranblanco we can pass wallet address from csv file to contract ?
Devedse
@devedse
Apr 11 2018 19:07

@devedse you need to use the same Web3 instance or Nonce Service

@juanfranblanco, sorry for the late answer, but in regards to my nonce problem I do in fact only create one web3 instance

Could there be another cause for the error where the nonce is incorrect? (E.g. I was using Ganachi when doing these tests)
@juanfranblanco, I got another question, (I'm not sure if I already asked this but I couldn't find it).
I saw that contracts can be libraries. And that when deploying a library you need to basically replace the address in the created bytecode. (See here: http://solidity.readthedocs.io/en/v0.4.21/contracts.html#libraries)
Devedse
@devedse
Apr 11 2018 19:13
And then specifically this part: As the compiler cannot know where the library will be deployed at, these addresses have to be filled into the final bytecode by a linker (see Using the Commandline Compiler for how to use the commandline compiler for linking). If the addresses are not given as arguments to the compiler, the compiled hex code will contain placeholders of the form Set__ (where Set is the name of the library). The address can be filled manually by replacing all those 40 symbols by the hex encoding of the address of the library contract.
How does that work in conjunction with Nethereum?
CryptoAlphaOne
@CryptoAlphaOne
Apr 11 2018 20:30
@juanfranblanco has sent me an email, when I can look, I am grateful.
Juan Blanco
@juanfranblanco
Apr 11 2018 22:26
@devedse you will have to replace it yourself on the code
there is not a shortcut for this
(at the moment)
so from a generated deployment
public class MyContractNameDeployment:ContractDeploymentMessage
    {

        public static string BYTECODE = "6060604052341561000f576000...";

       public MyContractNameDeployment():base(BYTECODE) { }

        public MyContractNameDeployment(string byteCode):base(byteCode) { }

        [Parameter("uint256", "_initialAmount", 1)]
        public BigInteger InitialAmount {get; set;}
        [Parameter("string", "_tokenName", 2)]
        public string TokenName {get; set;}
        [Parameter("uint8", "_decimalUnits", 3)]
        public byte DecimalUnits {get; set;}
        [Parameter("string", "_tokenSymbol", 4)]
        public string TokenSymbol {get; set;}
    }
Juan Blanco
@juanfranblanco
Apr 11 2018 22:32
you can get the BYTECODE, replace with the Libraries and deploy
but sure there is a need for simple way to find the Set_Name