These are chat archives for Nethereum/Nethereum

31st
Jul 2018
p0isoN
@p0isoNz_twitter
Jul 31 2018 02:34
Immediately
tmyngu11
@tmyngu11
Jul 31 2018 05:25

How would i send payable eth along with a transaction?
I have this code

    //////////////////////// Breed Function /////////////////////////
    public TransactionInput BreedWithAuto(string addressFrom, BigInteger _matronId, BigInteger _sireId, HexBigInteger valueAmount, HexBigInteger gas = null)
    {
        var function = contract.GetFunction("breedWithAuto");
        var transInput = function.CreateTransactionInput(addressFrom, gas, valueAmount, _matronId, _sireId);
        return transInput;
    }

and I call it like so

TransactionInput t = ninjaCore.BreedWithAuto(wallet, _matronId, _sireId, valueAmount);
SendTransaction(t.To, t.Data);

but when I try to test it, it always sets the eth to send as 0. the parameters are correct so I am wondering if theres a different approach to doing this

25yuanzijian
@25yuanzijian
Jul 31 2018 06:03
How to send a personal_sendTransaction message with a password?
Enigmatic
@EnigmaticUnreal_twitter
Jul 31 2018 07:53

@25yuanzijian - Please refer to https://nethereum.readthedocs.io/en/latest/accounts/

The section "Working with a Managed Account in Web3" will help you. :)

var senderAddress = "0x12890d2cce102216644c59daE5baed380d84830c";
var password = "password";

var account = new ManagedAccount(senderAddress, password);
var web3 = new Web3.Web3(account);

Then you should be able to do something like this

await web3.TransactionManager.SendTransactionAsync(account.Address, addressTo, new HexBigInteger(20));

@tmyngu11 - Interesting... I guess you're using Unity. I tried running this on my side but in winforms, looked alright (my contract required me to send msg.value > 0 else will revert).

        Dim callfunc = tokencontract.GetFunction("payabletest")
        Dim transInput = callfunc.CreateTransactionInput(account.Address, gas, value, 123)
        Dim transactionHash = Await callfunc.SendTransactionAndWaitForReceiptAsync(transInput)

With:

    function payabletest(uint256 test) payable returns (bool) {
        require(msg.value > 0);
        testupdate = test;
        return true;
    }
Hmm. Does the value shows up right on the transactionInput object?
image.png
I do usually use paramobjects without issues on winforms, but not sure if you could do the same in unity.
Dim transactionHash = Await callfunc.SendTransactionAndWaitForReceiptAsync(account.Address, gas, value, Nothing, 123)
Juan Blanco
@juanfranblanco
Jul 31 2018 08:27
@sjalq when the block including the txn is mined
Zeshan Virk
@zeshanvirk
Jul 31 2018 11:00
How can i get erc20 token Transactions using nEthereum?
Juan Blanco
@juanfranblanco
Jul 31 2018 13:21
you will want to check for even Trasfer event
tmyngu11
@tmyngu11
Jul 31 2018 14:50
@juanfranblanco The correct value shows up when i do this
TransactionInput t = ninjaCore.BreedWithAuto(wallet, _matronId, _sireId, f);
Debug.Log(t.Value.Value.ToString());
SendTransaction(t.To, t.Data);
tmyngu11
@tmyngu11
Jul 31 2018 14:59
the value is 2000000000000000 when i decode from hex->bigint, which whould be right. but when I try to do the transaction the amount shows up as 0 and really high gas because it requires the amount to be at least 0.002 eth
Enigmatic
@EnigmaticUnreal_twitter
Jul 31 2018 15:05
How are you calling your SendTransaction function? @tmyngu11
tmyngu11
@tmyngu11
Jul 31 2018 15:08
@EnigmaticUnreal_twitter I posted the code in the chat
The value should be in wei right?
Enigmatic
@EnigmaticUnreal_twitter
Jul 31 2018 15:12

I meant, what's inside the SendTransaction function. :) I tried scrolling up to see how it looks like, but maybe I missed it.

Yes value should be in wei. Did you also specify a gas value? Noticed that gas defaults to null in your example. Need to test this but was wondering if it'll cause problems.

Ah if I set gas value to nothing I'd get something different. Hmm.
tmyngu11
@tmyngu11
Jul 31 2018 15:17
@EnigmaticUnreal_twitter I'm using Nethereum with Unity, The SendTransaction function is part of the Javascript Interop. https://github.com/Nethereum/Nethereum.Flappy
Enigmatic
@EnigmaticUnreal_twitter
Jul 31 2018 15:18
Ah cool. Darn. I should work more on Unity so I could try to help you out. :(
tmyngu11
@tmyngu11
Jul 31 2018 15:19
I'll try to specify a gas value, I assumed it would generate by itself. it did for other functions that didnt require a payable amount
Thanks for your help anyways :)
userid2018
@userid2018
Jul 31 2018 15:56
Hello, I need to capture all transaction submitted to a specific contract. What is the best approach to do it in Nethereum
Enigmatic
@EnigmaticUnreal_twitter
Jul 31 2018 19:19
@userid2018 - Hey there. :) You could raise an event on the contract and capture it using filters (under section "events and filters", https://nethereum.readthedocs.io/en/stable/contracts/calling-transactions-events/).
Alternatively... You could use a filter and listen for changes (web3.Eth.Filters), get the sent data and parse it according to its abi - I am still experimenting with this. But better just to use events and DTOs, so you could track actual state changes.
userid2018
@userid2018
Jul 31 2018 19:26
@EnigmaticUnreal_twitter I had followed the link you suggested. but the event is not raised at all. how do I verify if i am bound to event correctly
userid2018
@userid2018
Jul 31 2018 20:23
I followed this example http://nethereum.readthedocs.io/en/stable/contracts/calling-transactions-events/ . in this case contract is transaction is send by the same application which reads the event. in my case transaction sender application is a different application and my event reader application is different. Event reader application has to continously monitor the testnet and process events raised by smart contracts. is there a sample which can point to direction on how to recieve events