These are chat archives for Nethereum/Nethereum

5th
Dec 2017
sinsonfrancis
@sinsonfrancis
Dec 05 2017 06:44 UTC
how to connect with Azure blockchain consortium from Nethrerum
I have tried like var web3 = new Geth.Web3Geth(account, "http://------.southeastasia.cloudapp.azure.com:8545");
it throws some error
Juan Blanco
@juanfranblanco
Dec 05 2017 07:25 UTC
What is the error?
var accountPrivateKey = "0x4bb78cb57aa7b5c59c0e5e436d7226bdd79b08ce27318b4ad1871bbd0216de04";
            var accountAddress = "0x37c54BEA49F967D123875D9FDde04B0FD657DEA5";

            var account = new Account(accountPrivateKey);
            var rpcAddress = "http://juann45fg.northeurope.cloudapp.azure.com:8545";
            var web3 = new Web3(account, rpcAddress);
            var balance = await web3.Eth.GetBalance.SendRequestAsync(accountAddress);
This is an example of how I connect using an Account which has already been funded using the faucet
sinsonfrancis
@sinsonfrancis
Dec 05 2017 08:15 UTC
var senderAddress = "0x5B836357186BC19E2B4D37e2301DE4B72f5165AA";
var password = "*123";
var abi = @"[{'constant':false,'inputs':[{'name':'val','type':'int256'}],'name':'multiply','outputs':[{'name':'d','type':'int256'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'inputs':[{'name':'multiplier','type':'int256'}],'payable':false,'stateMutability':'nonpayable','type':'constructor'}]";
var byteCode =
"0x6060604052341561000f57600080fd5b6040516020806100f283398101604052808051906020019091905050806000819055505060b1806100416000396000f300606060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631df4f144146044575b600080fd5b3415604e57600080fd5b606260048080359060200190919050506078565b6040518082815260200191505060405180910390f35b60008054820290509190505600a165627a7a723058200dfd1138ee1b70e240253d56f9253b3c82bc9f1058e3cb18c2cf7a86691d60b60029";
        var multiplier = 7;

        try
        {
            //a managed account uses personal_sendTransanction with the given password, this way we don't need to unlock the account for a certain period of time
            var account = new ManagedAccount(senderAddress, password);

            //using the specific geth web3 library to allow us manage the mining.
            var web3 = new Geth.Web3Geth(account, "http://-------.southeastasia.cloudapp.azure.com:8545");


            // start mining
            await web3.Miner.Start.SendRequestAsync(6);

            var receipt =
                await web3.Eth.DeployContract.SendRequestAndWaitForReceiptAsync(abi, byteCode, senderAddress, new Hex.HexTypes.HexBigInteger(900000), null, multiplier);

            var mineResult = await web3.Miner.Stop.SendRequestAsync();
            Assert.IsTrue(mineResult);
In this, the code is not running from the await web3.Miner.Start.SendRequestAsync(6);
its not even catching
Juan Blanco
@juanfranblanco
Dec 05 2017 08:46 UTC
right
There are couple of misunderstandings
  1. The nodes in Azure are already mining, so you don't need to control the mining procedure
(2.) The account you are using is a ManagedAccount, I don't know if the node you are connecting has "personal" permissions, so it is best to use your private key instead to sing the transactions before hand
(3.) If you want to create a new account you can simply do the following
  var ecKey = Nethereum.Signer.EthECKey.GenerateKey();
            var address = ecKey.GetPublicAddress();
            var privateKey = ecKey.GetPrivateKey();
(4.) Now using the address you should be able to fund it going to your url
(excluding the 8545 port, just use 80) in the browser
Juan Blanco
@juanfranblanco
Dec 05 2017 08:53 UTC
image.png
(5.) Now that you have some Ether
Go back to the original code I sent you
You mainly need Ether to execute transactions
var accountPrivateKey = "This is your new private key";
            var accountAddress = "This is your address already funded";

            var account = new Account(accountPrivateKey);
            var rpcAddress = "http://juann45fg.northeurope.cloudapp.azure.com:8545";
            var web3 = new Web3(account, rpcAddress);
            var balance = await web3.Eth.GetBalance.SendRequestAsync(accountAddress);
Ramon Lopez
@lopezmramon
Dec 05 2017 14:09 UTC
Hey!
Juan, are you available for a quick question?
Edson Alcalá
@EdsonAlcala
Dec 05 2017 14:11 UTC
@lopezmramon what do you need?
Ramon Lopez
@lopezmramon
Dec 05 2017 14:11 UTC
I'm trying to implement a "funds send" feature in Unity but I'm very lost atm
I have a wallet that I load, I can see the balance, I already can create wallets too. But sending from an address to another is eluding me
If you can please point me to some resource that could help, I'd be very grateful.
Ramon Lopez
@lopezmramon
Dec 05 2017 14:33 UTC
I'll be around in case someone has any pointers. Thank you.
этот товарищ
@etot_tovarisch_twitter
Dec 05 2017 14:40 UTC
Hi! From today I'm having a problem with sending contract transactions. I'm getting "insufficient funds for gas * price + value" error. Trying to increasing gas limit step by step I'm finally getting "Exceeds block gas limit" error. How can I resolve that?
image.png
Juan Blanco
@juanfranblanco
Dec 05 2017 17:08 UTC
@etot_tovarisch_twitter the first error is indicating you dont have enough ether to send the transaction
and yes there is a limit for a gas block
you can increase that on genenis
Devedse
@devedse
Dec 05 2017 17:28 UTC
Hey guys, another question, I want to have all transaction receipts for a certain block. How would I get this?
Obtaining the transactions itself isn't a problem, but I would like to see if they failed or worked
Edson Alcalá
@EdsonAlcala
Dec 05 2017 17:54 UTC
@devedse what do you mean if a transaction failed or worked?
wouldn't be that something related with code, like using require and assert to validate state ?
Juan Blanco
@juanfranblanco
Dec 05 2017 18:04 UTC
@devedse one way is to get all the transaction hashes
each receipt now contains the status field, which tells you if it was successful or not
"now" as in a recent change in Ethereum
other option will be to validate something like a log
in the receipt for specific values
people sometimes put an error log
Devedse
@devedse
Dec 05 2017 21:37 UTC
I obtained them by doing the GetTransactionReceipt function :)