These are chat archives for Nethereum/Nethereum

12th
Feb 2018
bluuman
@bluuman
Feb 12 2018 04:44
Does nethereum support .net core?
I'm trying to reference Nethereum from my dotnetcore project, but i get this warning:
warning NU1701: Package 'Nethereum.Portable 2.2.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
I don't have net framework install, I'm on linux. How is that going to work?
bluuman
@bluuman
Feb 12 2018 05:14
It works... Just "dotnet add package Nethereum"
but why does it work
so easy
bluuman
@bluuman
Feb 12 2018 05:25
maybe not so easy, when i try to use Account.LoadFromKeyStore I get:
Could not load file or assembly 'BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942'. The system cannot find the file specified.
dotnet add package BouncyCastle.Crypto:
error: Package 'BouncyCastle.Crypto' is incompatible with 'all' frameworks in project
bluuman
@bluuman
Feb 12 2018 05:30
ok, found BouncyCastle.NetCore package on nuget, installed and now it's working fine
Juan Blanco
@juanfranblanco
Feb 12 2018 09:04
@bluuman just add Nethereum.Web3 for .net core
instead of nethereum.portable
that is the "main" entry package, portable is for backwards compatibility
@amaldevom_twitter
Juan Blanco
@juanfranblanco
Feb 12 2018 09:09
to complete the documentation
it is in progress
Brianenno2
@Brianenno2
Feb 12 2018 09:13
Thanks Juan Blanco,
"CallAsync<string>" is doing the job.
I didn't understand very well how to use the DTO. I will investigate a little very soon.
Bye!
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:44
any body here?
When I Write datas into Ethereum. there is a Error:Nethereum.JsonRpc.Client.RpcClientUnknownException:“Error occurred when trying to send rpc requests(s)” Who can help me?thans very much!
Juan Blanco
@juanfranblanco
Feb 12 2018 09:46
have you started your testnet ?
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:47
yes
I did
and I can got my Balance
Juan Blanco
@juanfranblanco
Feb 12 2018 09:48
post a snippet of what you are doing
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:48
wait a second
      Web3 web3 = new Web3(FoxConfig.Server);
var newAccount = await web3.Personal.NewAccount.SendRequestAsync("123");
var accounts = await web3.Personal.ListAccounts.SendRequestAsync();
return "New account : " + newAccount + " all accounts: " + string.Join(",", accounts);
here it is
Juan Blanco
@juanfranblanco
Feb 12 2018 09:50
what server you are connecting
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:50
ropsten test net
Juan Blanco
@juanfranblanco
Feb 12 2018 09:50
infura?
you won't get accounts from infura
it is a public noce
node
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:50
no .is ropsten
yes
ropsten.infura.io
Juan Blanco
@juanfranblanco
Feb 12 2018 09:51
right
those are your personal accounts in geth / parity
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:51
and I can use it to get Blacnce
Juan Blanco
@juanfranblanco
Feb 12 2018 09:51
yes because all balances are stored on chain
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:51
yes. I have got a Account in rposten net
Juan Blanco
@juanfranblanco
Feb 12 2018 09:51
but they don't store "your" accounts
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:52
but I can get my Balance of my account
Juan Blanco
@juanfranblanco
Feb 12 2018 09:52
because that is stored in the blockchain
your personal accounts is another thing
ie.. containing your private keys
mainly listing what you have in the keystore in your local node
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:53
so what should I do?
Juan Blanco
@juanfranblanco
Feb 12 2018 09:53
well i don't know what you are trying to do
but if you know your accounts
you have them already
so mainly don't use that method
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:53
I want create a new Account in my Dapp
Juan Blanco
@juanfranblanco
Feb 12 2018 09:54
check this out
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:54
and I had an account,and migrated my contract in ropsten.
I want use these contact ..
Juan Blanco
@juanfranblanco
Feb 12 2018 09:56
well you need to have your account in ropsten
you can generate one
but needs to be funded
using the faucet
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:56
I had one
Juan Blanco
@juanfranblanco
Feb 12 2018 09:56
well then you are fine
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:57
But I got the Error
Nethereum.JsonRpc.Client.RpcClientUnknownException:“Error occurred when trying to send rpc requests(s)
Juan Blanco
@juanfranblanco
Feb 12 2018 09:57
That method is not available in infura
you cannot list accounts
in infura
zhuolaoshi
@zhuolaoshi
Feb 12 2018 09:57
When I use my contracr
contract
Accounts in Web3 Nethereum ...
if I had q Accounts ,I should add it ?
OH ,thanks . I think I got it
l-vitall
@l-vitall
Feb 12 2018 10:27
Hi, is there an ability to generate public keys without private key in NEthereum? I mean the case like ExtPubKey pubKey = privateKey.Neuter() in Bitcoin where pubKey can be used to generate other public keys that are derived from the same private key. The private key can be safely stored offline in this case. I checked the HdWallet project and its tests but it seems that there is no this functionality yet. If so then is it planned to support it in future?
Juan Blanco
@juanfranblanco
Feb 12 2018 10:53
You need a public key at least, but rather pointless if you cannot derived the private key
l-vitall
@l-vitall
Feb 12 2018 11:01
It is useful for case when we can set an external public key on the web site and to use it to derive a new public key (address) for each new customer purchase. Customer then sends ether to such address to pay for purchase. And after he paid we can generate transaction offline to transfer his payment to our main address. There is low risk to compromise our private key in this scenario, isn't it?
Juan Blanco
@juanfranblanco
Feb 12 2018 11:26
well using an hd wallet you can generate all beforehand
and queue them per customer?
you still will need the private key to sign it offline
l-vitall
@l-vitall
Feb 12 2018 11:45
yes, this scenario is also correct, just it has a bit more actions: to pregenerate public keys, to import them to system, to assign not used of them to each exact deal and to mark it as used, to watch that there are always enough of not used public keys in database
Juan Blanco
@juanfranblanco
Feb 12 2018 12:47
yes true, but if you share your seed, your seed can be a vector attack
better to keep it offline
you will still need to keep track of what keys you have used
regardless
l-vitall
@l-vitall
Feb 12 2018 13:15

you will still need to keep track of what keys you have used
regardless

In the simple case we can generate the public key dynamically by something like DealId, so there is no need ta care about which keys are already used

if you share your seed, your seed can be a vector attack

I'll investigate it, thanks

She Jong Shon
@kkagill
Feb 12 2018 16:13

@juanfranblanco how do I pass in user's selected metamask account to From field in TransactionInput?

var tInput = new TransactionInput
            {
                From = ?
                Gas = new HexBigInteger(3000000),
                Value = new HexBigInteger(222)
            };

I could do this using web3 javascript by calling getCoinbase method. Any equivalent in nethereum?

web3.eth.getCoinbase(function(err, account) {
    App.account = account;
Juan Blanco
@juanfranblanco
Feb 12 2018 16:14
well get coinbase, it is intercepted by metamask by selecting your correct account
current*
of metamask
you obviously don't need that in Nethereum
as you don't have anything controlling your account
so just input your account
She Jong Shon
@kkagill
Feb 12 2018 16:17
so when a user clicks on a button, it will call below method via web api
public async Task<bool> PlaceBet(BigInteger matchId, uint hts, uint ats, uint bettingPrice)
        {
            var fPlaceBet = contract.GetFunction("placeBet");
            object[] fInput = new object[] { matchId, hts, ats, bettingPrice };

            var tInput = new TransactionInput
            {
                From = 
                Gas = new HexBigInteger(3000000),
                Value = new HexBigInteger(222)
            };

            var transactionHash = await fPlaceBet.SendTransactionAsync(tInput, fInput);
            var result = await fPlaceBet.CallAsync<bool>();

            return result;
        }
Juan Blanco
@juanfranblanco
Feb 12 2018 16:17
??
who is managing the account
and the private keys
She Jong Shon
@kkagill
Feb 12 2018 16:25

there's a button in frontend which is clicked by any user using metamask

<button type="button" data-dismiss="modal" onclick="App.sellProduct(); return false;">Submit</button>

and in javascript

sellProduct: function() {
    // retrieve details of the product 
    var _description = $("#description").val();

    App.contracts.Product.deployed().then(function(instance) {
      return instance.sellProduct(_description {
        from: App.account,
        gas: 500000
      });
    }).then(function(result) {

    }).catch(function(err) {
      console.error(err);
    });
  },
the user's metamask account address is passed to contract via getCoinbase (App.account)
or does the user need to manaully pass in his account address in nethereum?
She Jong Shon
@kkagill
Feb 12 2018 16:55

or can this be achieved by using

var accounts = await web3.Eth.Accounts.SendRequestAsync();

?

Juan Blanco
@juanfranblanco
Feb 12 2018 17:11
I don't see how you are using a SPA with Nethereum
She Jong Shon
@kkagill
Feb 12 2018 17:12
yeah i'm using angular4 and .netcore2.0 as web api using nethereum
Juan Blanco
@juanfranblanco
Feb 12 2018 17:12
If you are creating a mobile / desktop and connecting to a public / local node use Nethereum or in future wasm
But how are you signing the transactions
She Jong Shon
@kkagill
Feb 12 2018 17:13
sry what do you mean by that
is it the wrong usecase to use nethereum with spa?
She Jong Shon
@kkagill
Feb 12 2018 17:28
above javascript code was used to ask if there's any equivalent code in nethereum. I'm not using above javascript code in my angular fyi
She Jong Shon
@kkagill
Feb 12 2018 17:52

so for example, this is the site I'm trying to achieve in a similar way. When you place a bet (any user), it opens up metamask and sends transaction. I've done a similar dapp using truffle and I'm now doing this using nethereum. So isn't the below javascript code

App.contracts.Product.deployed().then(function(instance) {
      return instance.sellProduct(_description {
        from: App.account,
        value: 222,
        gas: 3000000
      });
    }).then(function(result) {

equivalent to nethereum's

var tInput = new TransactionInput
            {
                From = 
                Gas = new HexBigInteger(3000000),
                Value = new HexBigInteger(222)
            };

var transactionHash = await fPlaceBet.SendTransactionAsync(tInput, fInput);
var result = await fPlaceBet.CallAsync<bool>();

when sending transaction?

If that's the case, javascript's example from: App.account, is assigned via web3.eth.getCoinbase(function(err, account) { App.account = account; }, but in nethereum I don't know how to do this.

Juan Blanco
@juanfranblanco
Feb 12 2018 18:11
Yes but you still to sign the transaction
Check the accounts doc it might help you
doreegekku
@doreegekku
Feb 12 2018 19:53

@juanfranblanco Thanks, that seemed to work well. Hopefully final question, If I have multiple data outputs from my solidity function, I need to use DecodeDTOTypeOutput with a class that has all those data types right? I'm currently getting the error:

ArgumentException: Generic Type should have a Function Ouput Attribute

When I attempt that. Not sure if I'm on the right track here.

KinGGuN73
@KinGGuN73
Feb 12 2018 20:34
Hi, Im wondering , how to convert HexBigInteger to integer ?
KinGGuN73
@KinGGuN73
Feb 12 2018 22:00
Because I need to do a lot of transactions (I use sendRawTransaction) and "web3.Eth.Transactions.GetTransactionCount.SendRequestAsync(Address)" is to slow to refresh to get the nonce ,so my program don't work,
So I want to convert the returned HexBigInteger to Integer and then increment it manualy at each payement, how can I do this ? Thats why Im asking how to convert HexBigInteger to integer ? Please help me