These are chat archives for Nethereum/Nethereum

23rd
Jun 2017
Juan Blanco
@juanfranblanco
Jun 23 2017 08:39
@jacobthebrown to use the geth compile solidity, you need to have solidity install and in your path
the best thing is to use something like vscode to compile your solidity, and even better truffle as it supports things like libraries
Juan Blanco
@juanfranblanco
Jun 23 2017 08:45
@molaie your enum type will be a uint8
contract StateContract{
    enum state{
        start,
        processing,
        complete
    }

    state currentState;

    function setState(state newState){
        currentState = newState;
    }

    function getState() returns (state){
        return currentState;
    }
}
this is a sample, and the abi
[{"constant":false,"inputs":[],"name":"getState","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newState","type":"uint8"}],"name":"setState","outputs":[],"payable":false,"type":"function"}]
so as per your code, just pass the right state
0 indexed
Diogo Costa
@diogocosta123
Jun 23 2017 14:55

Hi Juan. I have a .NET Core console App that I intend to use as wallet. I've managed to connect to the geth client and can gather data from the accounts, but for some reason cannot get the transaction to work. I'm running this as an Async Task called from main().

  public async static Task<bool> TransAsync()
        {
            Console.WriteLine("Retreiving account info...");
            string senderAddress = "0x5c2e7d33a8971ee2d7bf726ea1d70153044ffdd8";
            string senderPassword = "password";
            var managedAccount = new ManagedAccount(senderAddress, senderPassword);
            var web3 = new Nethereum.Web3.Web3(managedAccount);

            var transactionPolling = new TransactionReceiptPollingService(web3);

            var currentBalance = await web3.Eth.GetBalance.SendRequestAsync(senderAddress);

            Console.WriteLine("John balance: " + web3.Convert.FromWei(currentBalance));

            await web3.TransactionManager.SendTransactionAsync(managedAccount.Address, receiverAddress, new HexBigInteger(100));

            var newBalance = await web3.Eth.GetBalance.SendRequestAsync(senderAddress);
            Console.WriteLine("New balance: " + web3.Convert.FromWei(newBalance));

            return true;
        }

Also I don't really understand the final parameter on SendTransactionAsync. Can you help me out?

Juan Blanco
@juanfranblanco
Jun 23 2017 14:57
you need to wait for the transaction to be "committed" on chain
Diogo Costa
@diogocosta123
Jun 23 2017 14:58
I'm using a private chain and I've waited for a while. How long does it take?
Juan Blanco
@juanfranblanco
Jun 23 2017 14:58
are you mining?
Diogo Costa
@diogocosta123
Jun 23 2017 14:58
yes.
Juan Blanco
@juanfranblanco
Jun 23 2017 14:58
can you see the transaction in queue?
if you are using geth
just type "eth" on the console and you will see the pending transactions
await web3.TransactionManager.SendTransactionAsync(managedAccount.Address, receiverAddress, new HexBigInteger(100));
the last parameter will the amount you are sending
Diogo Costa
@diogocosta123
Jun 23 2017 15:00
ok. Let me try
Juan Blanco
@juanfranblanco
Jun 23 2017 15:00
hence on the sample you wait for the transaction receipt
mainly wait to be mined
Diogo Costa
@diogocosta123
Jun 23 2017 15:06
Sorry, I'm quite new to this. I can't seem to find the pending transactions on geth
Juan Blanco
@juanfranblanco
Jun 23 2017 15:07
on the console
sorry when you launch geth
if you run it with the console option
and very low verbosity
you can interact via the cli
Diogo Costa
@diogocosta123
Jun 23 2017 15:12
yeah. found it
Is it transaction supposed to take this long? If I run them through get it is mined usually within 1 sec.
Juan Blanco
@juanfranblanco
Jun 23 2017 15:16
not really on a fresh chain it takes around 1 second
i am guessing that it taking more than 12 seconds
also it may be building your DAG
if you have not done it before
that will take a while
Diogo Costa
@diogocosta123
Jun 23 2017 15:18
Ok. I'll wait a while and give it a couple more tries. I'll get back you if I need more help. Thanks a lot!
Juan Blanco
@juanfranblanco
Jun 23 2017 15:19
oh if it is buiding your DAG let it finished
Diogo Costa
@diogocosta123
Jun 23 2017 15:20
What do you mean by DAG?
Diogo Costa
@diogocosta123
Jun 23 2017 15:22
Yes. This could be the problem. Thanks!
if are mining for the first time, it will need to build the DAG and will take a while
Diogo Costa
@diogocosta123
Jun 23 2017 15:25
Got it. Yes. It's my first time.
Jacob Brown
@jacobthebrown
Jun 23 2017 17:47
Hey Juan, whenever I deploy a smart contract, the bytecode inside the smart contract when I look on etherscan "0x"
var abi = @"[{""constant"":false,""inputs"":[{""name"":""val"",""type"":""int256""}],""name"":""multiply"",""outputs"":[{""name"":""d"",""type"":""int256""}],""type"":""function""},{""inputs"":[{""name"":""multiplier"",""type"":""int256""}],""type"":""constructor""}]";
var byteCode = "0x606060405260e060020a60003504631df4f1448114601a575b005b600054600435026060908152602090f3";
var senderAddress = "0x49576934832e0735cb364e7880adebc35caeee28";

var deployingTask = DeployContract(senderAddress, byteCode, abi, 10);

...
...
...

public static async Task<string> DeployContract(string senderAddress, string byteCode, string abi, params object[] constructorParamaters)
{
    ...
    var transactionHash = await web3.Eth.DeployContract.SendRequestAsync(abi, byteCode, senderAddress, constructorParamaters);
    ...
}
Jacob Brown
@jacobthebrown
Jun 23 2017 17:53
When I deploy using Remix, it works fine though? So I don't know what I'm doing wrong.
Juan Blanco
@juanfranblanco
Jun 23 2017 18:15
you may have ran out of gas
when the contract deployed is 0x it mainly have an error deploying (normally it has ran out of gas)
Jacob Brown
@jacobthebrown
Jun 23 2017 18:16
Ahh
How do you send gas in a deploy contract.SendRequestAsync though?
Juan Blanco
@juanfranblanco
Jun 23 2017 18:25
it is one of the parameters
Jacob Brown
@jacobthebrown
Jun 23 2017 18:29
Thanks!
why u no have documentation
Juan Blanco
@juanfranblanco
Jun 23 2017 18:33
i have the videos
and the docs?
in read the docs?
Jacob Brown
@jacobthebrown
Jun 23 2017 18:33
Ahh I mean for methods.
Juan Blanco
@juanfranblanco
Jun 23 2017 18:33
comments you mean?
Jacob Brown
@jacobthebrown
Jun 23 2017 18:33
Sure
Juan Blanco
@juanfranblanco
Jun 23 2017 18:33
anti pattern of comments
methods should be descriptive
Jacob Brown
@jacobthebrown
Jun 23 2017 18:34
Well for example
"Gas"
What does gas mean, it could be gas price or gas limit or anything.
mainly it matches the names of the rpc calls
but overall yes, I understand is a learning exercise and should be simplified.. the videos explain a bit the gas usage
and the parameters for deployment
Juan Blanco
@juanfranblanco
Jun 23 2017 18:42
hence i am working on docs..
Jacob Brown
@jacobthebrown
Jun 23 2017 18:42
np
thanks for all that you do