These are chat archives for Nethereum/Nethereum

10th
Apr 2018
Psilon
@Pzixel
Apr 10 2018 08:54
@juanfranblanco I figured out what happened
I had following modifier on my function:
    modifier restricted {
        require(manager == msg.sender);
        _;
    }
however, I was deploying this contract through UI with different sender
and for some reason it was just hanging instead of throw some error like "ModifierViolatedException"
Juan Blanco
@juanfranblanco
Apr 10 2018 08:56
well it would not have thrown
as such
Psilon
@Pzixel
Apr 10 2018 08:56
Unfortunately(
Juan Blanco
@juanfranblanco
Apr 10 2018 08:56
in Nethereum you would only get in the receipt a status 0
same as web3js
your transaction will be submitted / mined / failed
and status change
on the receipt
that is the normal workflow
for all the clients (on top of the clients ;) )
Psilon
@Pzixel
Apr 10 2018 08:59
But i wasn't getting recipt
it was just hanging:)
Juan Blanco
@juanfranblanco
Apr 10 2018 08:59
ah.. that is strange
parity should send you a receipt
why don't you try with another client
here are some preconfigured ones
Psilon
@Pzixel
Apr 10 2018 09:00
because I found out that it's because I badly deployed this contract, if I deploy it correctly Nethereum handles it correctly
Juan Blanco
@juanfranblanco
Apr 10 2018 09:00
we have moved them to a simple reop
TarrahArshad
@TarrahArshad
Apr 10 2018 09:00
@juanfranblanco can i compile contract in visual studio code ?
Juan Blanco
@juanfranblanco
Apr 10 2018 09:01
yes you can
TarrahArshad
@TarrahArshad
Apr 10 2018 09:01
@juanfranblanco how to ?
Juan Blanco
@juanfranblanco
Apr 10 2018 09:01
install this extension
TarrahArshad
@TarrahArshad
Apr 10 2018 09:01
@juanfranblanco contact can access another contract ?
Psilon
@Pzixel
Apr 10 2018 09:02
So I just complain a bit about spent time because I didn't get right error message, but right now when I finally figured out what's happening I can move on. I just wanted to share my expirience if someone else would have same issue
Juan Blanco
@juanfranblanco
Apr 10 2018 09:02
you can code generate your c# services there too
Psilon
@Pzixel
Apr 10 2018 09:02

you can code generate your c# services there too

wow, and I wasn't aware of it. Cool, great job

TarrahArshad
@TarrahArshad
Apr 10 2018 09:02
@juanfranblanco can u explain ?
Juan Blanco
@juanfranblanco
Apr 10 2018 09:02
also we are changing it slightly the code generation to support cqs and
vb and f#
that is the current docs
TarrahArshad
@TarrahArshad
Apr 10 2018 09:04
@juanfranblanco in this extension i can write solitary js ex remix code ?
Juan Blanco
@juanfranblanco
Apr 10 2018 09:04
you can write solidity smart contracts
similarly to vscode
sorry to remix :)
TarrahArshad
@TarrahArshad
Apr 10 2018 09:05
@juanfranblanco good
can i access contract from another contract ? for example contract for presale and crowdsale and token contract
Juan Blanco
@juanfranblanco
Apr 10 2018 09:05
yes
you can
use the import
also you have autocomplete
on those
note if you are using zeppelin smart contracts
TarrahArshad
@TarrahArshad
Apr 10 2018 09:06
@juanfranblanco i will make refund method for my client i will make list investement database and if contract presale is true so client can refund
Juan Blanco
@juanfranblanco
Apr 10 2018 09:07
you need to configure your dependencies folder
to your node modules if using shortcuts
@Pzixel thanks for sharing btw :)
@TarrahArshad ok, although I cannot give you advise on your contract implementation without going into detail
Psilon
@Pzixel
Apr 10 2018 09:09
@juanfranblanco I'm going to use your console app as part of my extension for VS (non code one :) ). I have some expirience so it would be possible to automatically generate and reference all cs files during common msbuild
Thank you too for sharing, it's a big leap
TarrahArshad
@TarrahArshad
Apr 10 2018 09:10
@juanfranblanco what u need detail ?
Token contract
Presale contract ( user send ETH and payable send to him token ) refund method is for client refund eth sent and return token
Crowdsale contract
Juan Blanco
@juanfranblanco
Apr 10 2018 09:16
@Pzixel There is already an extension for Visual Studio
Psilon
@Pzixel
Apr 10 2018 09:16
It doesn't work for 2017
Juan Blanco
@juanfranblanco
Apr 10 2018 09:16
which I believe is going to be upgraded soon
Psilon
@Pzixel
Apr 10 2018 09:16
and it's not OSS
Juan Blanco
@juanfranblanco
Apr 10 2018 09:16
well I don't know if it will be open sourced or not
I will ask
Psilon
@Pzixel
Apr 10 2018 09:17
thank you
Juan Blanco
@juanfranblanco
Apr 10 2018 09:17
and yes the idea is that all the code generators will be plugged into visual studio fat and vs code :)
and stand alone
but the console is getting upgraded
currently everything is moving into a single source in .net
and for the ui eto forms
which can generate also wpf to integrate into visual studio
Psilon
@Pzixel
Apr 10 2018 09:19
Sorry but I don't see how WPF fits here
Juan Blanco
@juanfranblanco
Apr 10 2018 09:19
for the UI in Visual Studio Fat
Psilon
@Pzixel
Apr 10 2018 09:19
what kind of UI?
You mean generate form for sending requests?
Juan Blanco
@juanfranblanco
Apr 10 2018 09:20
the ui for the code generator
which yes will genarate many things including ui :)
Psilon
@Pzixel
Apr 10 2018 09:20

the ui for the code generator

does it require UI? I Mean you just get contract and generate some C# code, it's 1-1 corespondence, isn't it?

Juan Blanco
@juanfranblanco
Apr 10 2018 09:20
depending on your configuration
if you are working standalone
or extra features
namespaces
languages
Psilon
@Pzixel
Apr 10 2018 09:21
it may be configured via project file:)
Juan Blanco
@juanfranblanco
Apr 10 2018 09:21
specific changes
sure
Psilon
@Pzixel
Apr 10 2018 09:21
well ok
It's better to see how it works because having any opinion
so good luck
Juan Blanco
@juanfranblanco
Apr 10 2018 09:22
you can do that too :)
in the current generator in vscode
Psilon
@Pzixel
Apr 10 2018 09:22
I'm going to manually use your generator from console until you clarify when extension may be available for VS2017
Juan Blanco
@juanfranblanco
Apr 10 2018 09:23
you can configure this already using a specific file
and that will be the same for vscode
sure.. try this one too
Psilon
@Pzixel
Apr 10 2018 09:24
Well, one more question
it is the newer
or really use vscode
and select the json file
and f1 generate code
TarrahArshad
@TarrahArshad
Apr 10 2018 09:25
@juanfranblanco after install extension when i choise start debuge i see json launch
Juan Blanco
@juanfranblanco
Apr 10 2018 09:25
it is a single file as opposed to messages
but you have more power with messages IMHO
@TarrahArshad you cannot debug
i need to integrate the debugger (s)
Truffle just released one
press F5
to compile
or F1
and type solidity..
and find the option
Psilon
@Pzixel
Apr 10 2018 09:27

I have following contract:

event ItemCreated(uint indexed itemId, address result);

function newItem(uint id, uint price) public restricted {
    Item item = new Item(id, price, manager);
    items.push(item);
    emit ItemCreated(id, item);
}

and corresponding C# Code:

var filterEvent = await itemCreatedEvent.CreateFilterAsync(item.NumericId);

await getAddressFunction.SendTransactionAndWaitForReceiptAsync(_ethereumSettings.AccountAddress, new HexBigInteger(4300000),
                                                               new HexBigInteger(0), functionInput: new object[]
                                                                   {item.NumericId, (ulong) Math.Round(item.Price * 100)});
var result = await itemCreatedEvent.GetFilterChanges<MultipliedEvent>(filterEvent);

        private class MultipliedEvent
        {
            [Parameter("uint", "id", 1, true)]
            [UsedImplicitly]
            public ulong Id{ get; set; }

            [Parameter("address", "result", 2)]
            public string Result { get; [UsedImplicitly] set; }
        }

But I don't get an event. Should I use some kind of loop here until event occures or I'm doing something wrong?

Juan Blanco
@juanfranblanco
Apr 10 2018 09:27
@Pzixel
Psilon
@Pzixel
Apr 10 2018 09:27
I moved my question farther to make your text more consistent
try this workbook
[UsedImplicitly]
what is that :)
Psilon
@Pzixel
Apr 10 2018 09:29
R# attributes
for static analysis

try this workbook

I wrote this code using workbooks :)

Juan Blanco
@juanfranblanco
Apr 10 2018 09:30
ah yeah
Psilon
@Pzixel
Apr 10 2018 09:30
You mean that I have to use GetAllChanges instead of GetFilterChanges?
Juan Blanco
@juanfranblanco
Apr 10 2018 09:30
yes i got distracted with Resharper :)
mainly you have declared your filter afterwards
so you will get only
Psilon
@Pzixel
Apr 10 2018 09:31
It's a decorative attribute that doesn't imply any runtime behaviour)
Juan Blanco
@juanfranblanco
Apr 10 2018 09:31
any changes after this
so you could to test it
Psilon
@Pzixel
Apr 10 2018 09:31
In example filter was declared before actual call
so I should move it below?
Juan Blanco
@juanfranblanco
Apr 10 2018 09:32
shoot yeah
sorry i was blind
that should work
if you don't get any result it might have not completed succesfully
Psilon
@Pzixel
Apr 10 2018 09:33
I see these values in Parity)
Juan Blanco
@juanfranblanco
Apr 10 2018 09:33
check your transaction receipt
and see if you have any logs
Psilon
@Pzixel
Apr 10 2018 09:33
image.png
This is what parity shows
Juan Blanco
@juanfranblanco
Apr 10 2018 09:34
yes still might have failed
Psilon
@Pzixel
Apr 10 2018 09:34
I called it with two entities and it raised two events
Juan Blanco
@juanfranblanco
Apr 10 2018 09:34
on your receipt
can you see any logs
ahhhh
you have typed it
right you need to put "uint256" instead of "uint"
on the attribute
Psilon
@Pzixel
Apr 10 2018 09:35
but they are just aliases?
Juan Blanco
@juanfranblanco
Apr 10 2018 09:35
[Parameter("uint", "id", 1, true)]
yes but the abi
needs uint256
Psilon
@Pzixel
Apr 10 2018 09:38
I changed it but still no events
my receipt:
{
  "transactionHash": "0x4f90af64567628cb5bb2e539907ee551ac3e109178d7fcd89880f26bc9cb79ea",
  "transactionIndex": "0x0",
  "blockHash": "0x865cb21b00ff7293cffad886bbbd2b8645eab4634021f3b21cfd97de33b856d4",
  "blockNumber": "0x2fff",
  "cumulativeGasUsed": "0x15992c",
  "gasUsed": "0x15992c",
  "contractAddress": null,
  "status": null,
  "logs": [
    {
      "address": "0x2af6d62e16109121d2c889974ad70ee87ec9ba04",
      "blockHash": "0x865cb21b00ff7293cffad886bbbd2b8645eab4634021f3b21cfd97de33b856d4",
      "blockNumber": "0x2fff",
      "data": "0x0000000000000000000000003e2faccdd3ae90d666c3ffa93a6ffe535491e39a",
      "logIndex": "0x0",
      "topics": [
        "0xcf45e6447126ff77207fdbe3d88e41af5e0a657ebb26696b8879d1b0d62c948b",
        "0x0000000000000000000000000000000000000000000000000061006100979cdb"
      ],
      "transactionHash": "0x4f90af64567628cb5bb2e539907ee551ac3e109178d7fcd89880f26bc9cb79ea",
      "transactionIndex": "0x0",
      "transactionLogIndex": "0x0",
      "type": "mined"
    }
  ]
}
Juan Blanco
@juanfranblanco
Apr 10 2018 09:40
ah you get some logs
it should have returned it
Psilon
@Pzixel
Apr 10 2018 09:40
image.png
Unfortunately, it doesn't
Juan Blanco
@juanfranblanco
Apr 10 2018 09:42
2 seconds
Psilon
@Pzixel
Apr 10 2018 09:46
There is some difference in parameter name on C# and Solidity sides, but it's because I badly reformatted this code. So it's not the case
Juan Blanco
@juanfranblanco
Apr 10 2018 10:18
my version
working on geth.. 2 ticks and ill test it in parity
TarrahArshad
@TarrahArshad
Apr 10 2018 10:24
@juanfranblanco i get this error always
security/enforce-explicit-visibility: No visibility specified explicitly for BaseOwnToken function.
Juan Blanco
@juanfranblanco
Apr 10 2018 10:26
@Pzixel working in parity too
just wanted to validate something broke parity
well mainly parity was broken
@TarrahArshad add public
TarrahArshad
@TarrahArshad
Apr 10 2018 11:09
@juanfranblanco where i can find full document about solitory coding syntax ?
Juan Blanco
@juanfranblanco
Apr 10 2018 11:09
solidity**
TarrahArshad
@TarrahArshad
Apr 10 2018 11:09
for contract language
sure just correcting you the name so it is easier for you
TarrahArshad
@TarrahArshad
Apr 10 2018 11:11
@juanfranblanco ERC20 is developer by developer on Ethereum or other developer can develop ?
Juan Blanco
@juanfranblanco
Apr 10 2018 11:11
any one can develop anything
but the Standard Token ERC20 is a standard interface that tokens adhere to
TarrahArshad
@TarrahArshad
Apr 10 2018 11:12
@juanfranblanco i can develop ex: ERC30 ?
Juan Blanco
@juanfranblanco
Apr 10 2018 11:12
well it would not be an ERC as it won't be an approved standard
TarrahArshad
@TarrahArshad
Apr 10 2018 11:13
@juanfranblanco ok
Juan Blanco
@juanfranblanco
Apr 10 2018 11:13
but you can develop your own smart contract that complies to ERC20
and have extra functionality
it is important that you comply to an standard
as it can be used by any third party without changing anything
for example with Netherum you know that you can use any token like that
you just change your address
TarrahArshad
@TarrahArshad
Apr 10 2018 11:14
@juanfranblanco i developed my token smart contract i need presale contract how to i developer this and access old token contract for buy token ?
Juan Blanco
@juanfranblanco
Apr 10 2018 11:14
no idea, that is a very specific case
but I think I pointed you out to the crowdsale contract
before, that is a start
TarrahArshad
@TarrahArshad
Apr 10 2018 11:16
@juanfranblanco when we use Mint event ?
and i need know how to migration coins
@juanfranblanco presale and crowdsale is only step control with one old token , right ?
only policy and method for sell token or refund , ... ? right ?
Psilon
@Pzixel
Apr 10 2018 11:18
@juanfranblanco I have written following version:
private static async Task<ItemCreatedEvent> GetChanges(Event itemCreatedEvent, HexBigInteger filterEvent)
{
    for (int i = 0; i < 10; i++)
    {
        var result = await itemCreatedEvent.GetFilterChanges<ItemCreatedEvent>(filterEvent);
        if (result.Count > 0)
            return result.Single().Event;
        await Task.Delay(1000);
    }

    throw new InvalidOperationException("Event wasn't raised");
}
it works fine
it seems that there could be some network delay or something
Juan Blanco
@juanfranblanco
Apr 10 2018 11:35
hmm I did not see that problem
it is not a problem on mine
but I do recommend not creating filters
but just getting a log range
also the response performance should be the same
mist might be using ipc
Psilon
@Pzixel
Apr 10 2018 11:39
sorry, but I didn't get your idea. Can you elaborate, please? AFAIK raise event is the only way to get exact information that my message has been written to blockchain with following address
Juan Blanco
@juanfranblanco
Apr 10 2018 11:39
have not checked it for a while :)
no
you can get them from the transaction receipt
you can get them using GetAllChanges without any filters
TarrahArshad
@TarrahArshad
Apr 10 2018 11:39
@juanfranblanco we can transfer ether in smart contract methods ?
Juan Blanco
@juanfranblanco
Apr 10 2018 11:40
if it is marked a payeable yes
TarrahArshad
@TarrahArshad
Apr 10 2018 11:41
@juanfranblanco can u tell syntaxy for call transfer ether ?
@juanfranblanco for example i have method name refund i will user allow refund all balance tokens , i need know how to transfer ether to him
sorry guys but I need to get somethings done
TarrahArshad
@TarrahArshad
Apr 10 2018 11:43
@juanfranblanco when u can back ?
Psilon
@Pzixel
Apr 10 2018 11:44

you can get them from the transaction receipt

really? I was sure it just provide some logs if something went wrong

Juan Blanco
@juanfranblanco
Apr 10 2018 11:45
no it is an event
it is info
Psilon
@Pzixel
Apr 10 2018 11:45

you can get them using GetAllChanges without any filters

This behaviour doesn't correlate with filtering, it just isn't raised immediately but in some random moment in the future

Juan Blanco
@juanfranblanco
Apr 10 2018 11:46
what i mean without a filter id
if you want to get logs from Infura for example
there are no filterids
see the sample I send you before
Salazar, F. 🎖
@_Salazar_F_twitter
Apr 10 2018 12:04
@juanfranblanco I loved your tools for the .NET platform, but I'm not able to implement Smart Contracts with Nethereum. Is there any tutorial (other than the conventional ones) that you can tell me? Thank you!
Juan Blanco
@juanfranblanco
Apr 10 2018 12:39
@_Salazar_F_twitter what problem you have
have you tried just using the code generator and consume the service?
have you ran this workbook?
have you watched the videos? (even if a bit old, most of the concepts are valid)
have you looked at this sample
sorry have you ran these extra workbooks? https://github.com/Nethereum/Nethereum.Workbooks/tree/master/docs
sorry sample
Juan Blanco
@juanfranblanco
Apr 10 2018 12:45
the best thing is to post a sample of what you are doing and it gets fixed from there
also here is a new sample for the issue that was before https://gist.github.com/juanfranblanco/5c89d1b0fd9c6008542d887a3a81fe9a
which it wasnt an issue
if you want to use the messaging pattern as above I can publish the code generator for it
feel free to ask any question :)
Salazar, F. 🎖
@_Salazar_F_twitter
Apr 10 2018 12:50
@juanfranblanco Thanks for your attention! I am using "Solidity" with "Visual Studio 2015" to create contract. I have performed all the steps mention in this link https://medium.com/@ConsenSys/solidity-integration-with-visual-studio-8bdab2ff8a74 , apart from this I am executing below command on geth prompt (geth --testnet).
I have an error: "compile failed with error message: TypeError: Cannot convert undefined or null to object
caught a single contract"
Juan Blanco
@juanfranblanco
Apr 10 2018 12:51
oohh I am not responsible for that
Guilherme Gustavo Gohr
@Momentanius
Apr 10 2018 12:51
^ I've been trying to do the same thing, and I'm getting the same error, which is a shame.
Juan Blanco
@juanfranblanco
Apr 10 2018 12:51
that is the "old" extension I believe it is getting updated at the moment
if you are just interested in Ethereum try the vscode one
Guilherme Gustavo Gohr
@Momentanius
Apr 10 2018 12:52
Yeah, it's only available on VS2015
if you get that one
once you compile you can code generate your services
or do something simple as
Guilherme Gustavo Gohr
@Momentanius
Apr 10 2018 12:54
What I don't understand is: Every single tutorial say it works if you use VS2015, but it doesn't when I try, and every thread with the error I'm getting is currently open without any kind of answer :(
TarrahArshad
@TarrahArshad
Apr 10 2018 12:54
@juanfranblanco how much gas we need for transfer token ?
Juan Blanco
@juanfranblanco
Apr 10 2018 12:54
code generation ^
@TarrahArshad you can estimate
@Momentanius that is a very specific extension for blockapps
Guilherme Gustavo Gohr
@Momentanius
Apr 10 2018 12:55
Hey @juanfranblanco , if I use VSCode, can I integrate my work with Visual Studio later?
Juan Blanco
@juanfranblanco
Apr 10 2018 12:55
and includes its own compiler which it might be a bit updated
of course
it is the same
TarrahArshad
@TarrahArshad
Apr 10 2018 12:55
@juanfranblanco what is estemate ?
Juan Blanco
@juanfranblanco
Apr 10 2018 12:55
you can compile using remix too
or truffle
Guilherme Gustavo Gohr
@Momentanius
Apr 10 2018 12:56
Okay! I'll try using VSCode then.
Thanks!
:smile:
TarrahArshad
@TarrahArshad
Apr 10 2018 12:57
@juanfranblanco Gas Price or Max total ETH ?
@juanfranblanco now i see gas 2 GWEI and max total is 0.002816
@juanfranblanco and on real network and test is deferen , right ?
Psilon
@Pzixel
Apr 10 2018 13:17
@Momentanius did you try to install my extension? I compiled solidity files with it today several times and it worked like a charm
however, I don't have C# code generation as VSCode extension does so it's probably better fit for you
it also require installed solc in your system (solidity compiler)
Juan Blanco
@juanfranblanco
Apr 10 2018 13:27
@TarrahArshad you need gas
an amount of gas which your contract will use depending
on storage and complexity
then your gas price, is what you will pay for the gas usage
TarrahArshad
@TarrahArshad
Apr 10 2018 13:29
@juanfranblanco for old token i will create new contract for transfer token with lower gas , i can do ?
token used 4 gas but i will use 2 in new contract . its possible ?