These are chat archives for Nethereum/Nethereum

12th
Oct 2018
Sergio Piedrahita
@spied001
Oct 12 2018 00:00
does anyone happen to know why the bytecode generated by truffle and visual studio code is different?
the same contract compiled by truffle and visual studio code ends up with different bytecode
Lyon.Nee
@LyonNee
Oct 12 2018 05:45

function resetPlayer(
address _addr,
PlayStatus _status,
address[] _inferiors,
address _superior,
uint256 _cur_round) public onlyOwner
{
players[_addr].is_exist = true;
players[_addr].status = _status;
players[_addr].inferiors = _inferiors;
players[_addr].superior = _superior;
players[_addr].cur_round = _cur_round;
}

How do I call this function with a.net program and pass in an enum parameter

And I also need to pass in an array type parameter
Lyon.Nee
@LyonNee
Oct 12 2018 10:29
My problem has been solved
Dave Whiffin
@Dave-Whiffin
Oct 12 2018 10:29

@LyonNee - I would recommend using the Solidity extension in Visual Studio Code to code generate a service for you which is specific to the contract. It does the scaffolding for you and you can inspect the code it generates to get a fuller understanding. It saves a massive amount of time.

I have created a solidity contract with a function with the same signature as yours. Then, using the Visual Studio Code Solidity extension, I compiled it and then created a csharp project. I also created a test console app to deploy the contract and call the function. You can download this test project from:

https://www.dropbox.com/s/kba9oxyatmr63dj/2018_10_12_LyonNee.zip?dl=1

The test console includes hard coded references to the Nethereum test chain which are simple to change. It also runs against a pre release version of Nethereum (3.0.0-rc1).

Below is a snippet of the generated code for your resetPlayer function. Notice that the enum parameter is a byte and the address array accepts a list of strings.

public partial class ResetPlayerFunction:ResetPlayerFunctionBase{}

    [Function("resetPlayer")]
    public class ResetPlayerFunctionBase:FunctionMessage
    {
        [Parameter("address", "_addr", 1)]
        public virtual string Addr {get; set;}
        [Parameter("uint8", "_status", 2)]
        public virtual byte Status {get; set;}
        [Parameter("address[]", "_inferiors", 3)]
        public virtual List<string> Inferiors {get; set;}
        [Parameter("address", "_superior", 4)]
        public virtual string Superior {get; set;}
        [Parameter("uint256", "_cur_round", 5)]
        public virtual BigInteger Cur_round {get; set;}
    }
nitindigixhub
@nitindigixhub
Oct 12 2018 11:58
Hello Guys, We are trying to use Nethereum for our .net MVC project
but at the moment in the first step of pulling the git source code we have found issue the solution is not opening showing files are missing
can anybody here help me how to get it working
Juan Blanco
@juanfranblanco
Oct 12 2018 12:30
@nitindigixhub the best thing is to use the nugets
Although no files should are missing
@spied001 that is the swarm address, a small change will change the address
Michael Ilchuk
@Ilchuk-Mihail
Oct 12 2018 14:02
@juanfranblanco Hi. Is it possible from seed restore mnemonic words?
or from seed and password restore master key ?
Juan Blanco
@juanfranblanco
Oct 12 2018 15:18
the seed is the hash of the mnemonic words, so from seed to mnemonic it will be rather hard. But from seed and password you create the private key, so yeah
turtlewen
@turtlewen
Oct 12 2018 15:51
@Dave-Whiffin
public class newSystemRequestData
{
public string systemID { get; set; }
public string requesterName { get; set; }
public string requestDescription { get; set; }
public string requestDate { get; set; }
public string requestTime { get; set; }
}
i got an object to deserialize into that is decorated
but i cant i put the parameter
because it comes out error
@juanfranblanco can u help me have a look??
because i cannot get any value from smart contract
turtlewen
@turtlewen
Oct 12 2018 15:59

var setFunction = contract.GetFunction("setSystemRequest");
var getCountFunction = contract.GetFunction("getSystemRequestCount");

        int count = await getCountFunction.CallAsync<int>();
        string ID = "S" + count.ToString();

        systemID.Text = ID;

this is my code to get the total count from smart contract function, but it return out nothing

turtlewen
@turtlewen
Oct 12 2018 16:49
this is the result i get it : System.Threading.Tasks.Task`1[System.String]
Sergio Piedrahita
@spied001
Oct 12 2018 16:51
@juanfranblanco something weird is happening, when I compile and deploy the contracts on the private chain using truffle I am able to interact with the contracts with the current c# code that I have. This same code fails to interact with the contracts if I deploy the contracts through code (calling web3.Eth.DeployContract.SendRequestAsync(contractAbi, contractByteCode, contractOwnerAddress))
Sergio Piedrahita
@spied001
Oct 12 2018 16:59
@juanfranblanco the code fails when it tries to calculate the gas, the exception it throws is gas required exceeds allowance or always failing transaction. This same code works fine when the contracts are compiled and deployed through truffle
@juanfranblanco when I deploy the contracts through code I am able to see the transactions being mined, and I also check the status of the transaction receipt after the contract is deployed and it is fine, also I check if there were any errors through the hasErrors() method but no errors
Michael Ilchuk
@Ilchuk-Mihail
Oct 12 2018 17:24

@juanfranblanco

the seed is the hash of the mnemonic words, so from seed to mnemonic it will be rather hard. But from seed and password you create the private key, so yeah
But how ? If I create/recover master key -> I use ExtKey(seed)

There no implementation with passphrase
Michael Ilchuk
@Ilchuk-Mihail
Oct 12 2018 17:31
I try to implement similar functionality https://rawgit.com/aenima86/NEMkrs/master/index.htm
Dave Whiffin
@Dave-Whiffin
Oct 12 2018 18:18
@turtlewen Your example "newSystemRequestData" DTO doesn't have any attributes on it. This is how the parameters are mapped to the contract. Check the "ResetPlayerFunction" example I posted earlier . For each property on your DTO you need to an attribute that describes the solidity data type and the parameter order.
turtlewen
@turtlewen
Oct 12 2018 18:21
@Dave-Whiffin
image.png
it come out red line
i tried to put the parameter things
turtlewen
@turtlewen
Oct 12 2018 18:38
image.png
the parameter error is namespace not find
@Dave-Whiffin even single return int value from smart contract also need DTO ??or only struct ??
temporarily my dto come out problem of redline in parameter
Dave Whiffin
@Dave-Whiffin
Oct 12 2018 18:48
@turtlewen I am away from work this weekend so I can’t reply until Monday. However, try downloading the sample project below. Have a look through and see how the code works together. It uses a pre release version of Nethereum but you can update to this version if you click the pre release check box in visual studio. https://www.dropbox.com/s/kba9oxyatmr63dj/2018_10_12_LyonNee.zip?dl=1
magik-chorne
@magik-chorne
Oct 12 2018 20:02
does anyone know of an example of sending a FunctionMessage asynchronously? I imagine its something akin to SendTransactionAndWaitForReceiptAsync but the one I assumed I should use (web3.TransactionManager.SendTransactionAndWaitForReceiptAsync ) asks for transaction input instead of functionmessage. im also essentially wondering if im doing it wrong.....