These are chat archives for Nethereum/Nethereum

5th
Jul 2018
Juan Blanco
@juanfranblanco
Jul 05 2018 05:11
thanks
Ivan Selivanovsky
@si1ver_graf_twitter
Jul 05 2018 05:35

Hello. Could you advise, how to parse input field in transaction for erc20 token. i want get the adreses and value token.

now i use:
var value = a.ConvertFromHex(input.Substring(input.Length / 2));

Juan Blanco
@juanfranblanco
Jul 05 2018 05:38
you have GetInput
in a function
on the newer version you will have a extensions to the FunctionMessage
Ivan Selivanovsky
@si1ver_graf_twitter
Jul 05 2018 05:41
thank you
Schalk Dormehl
@sjalq
Jul 05 2018 06:08
Another question I have;
How do I access the events from the Transcation Receipt without having to set up a filter? I can do this from Web3JS via TransactionReceipt.logs[0].args.EventName
Any help would be greatly appreciated.
Juan Blanco
@juanfranblanco
Jul 05 2018 06:15
create an Event and pass the logs
to be decoded
Schalk Dormehl
@sjalq
Jul 05 2018 06:24
I'm not sure I understand. I have an event in my Solidity code, I then call the SendTransactionAndWaitForReceiptAsync methos and await the TX.
The TX .Logs doesnt' look like it contains the arguments to the event I created.
pragma solidity ^0.4.22;

import "./Signer.sol";

contract SignerFactory {
    address[] public signers;

    event SignerAddress(address Signer);

    constructor() public {}

    function produceSigner(address ownerAddress, address recoveryAddress) public returns (Signer signer) {
        Signer s = new Signer(ownerAddress, recoveryAddress);
        signers.push(s);
        emit SignerAddress(s);
        return s;
    }
}
This is the Solidity
var TXReceipt = await SignerFactory.GetFunction("produceSigner").SendTransactionAndWaitForReceiptAsync(
                from: FromAccount,
                gas: new HexBigInteger(4000000),
                value: new HexBigInteger(0),
                functionInput: new object[] {
                    ExpectedControllerAddress,
                    ExpectedRecoveryAddress }
                );
This is how I'm calling it.
Schalk Dormehl
@sjalq
Jul 05 2018 06:30
var SignerAddress = TXReceipt.Logs[0]
Looking through the object above, I cannot find the Signer arg.
What am I missing
Manish Goyal
@immortalinfotech_gitlab
Jul 05 2018 06:59
Hi, I am sending Erc20Token using
standarErc20Service.TransferAsync(fromAddress, toAddress, _amount.Value, gasLimit)
But I need to send Gasprice as well
So that it will not perform on default gas price
but i am not able to find how to send gas price in this function. Plz help .
Juan Blanco
@juanfranblanco
Jul 05 2018 08:26
@sjalq the logs do not include this
as such you need to create an event
or use
Event.GetLogsForEvent<yourEventType>()
i am pseudocoding
btw
use the TransferFuction object to populate the values
@immortalinfotech_gitlab
@sjalq just create an event like this..
and use the method to decode the changes
extensions methods will come in the next release but it is not happening yet
Manish Goyal
@immortalinfotech_gitlab
Jul 05 2018 08:46

@juanfranblanco I have already try to use it like

var _amount = new HexBigInteger(unitConversion.ToWei(Amount, 18));
                CallInput callInput = new CallInput();
                callInput.From = AdminAddress;
                callInput.To = toAddress;
                callInput.Value = new HexBigInteger(_amount);
                var gas = web3.TransactionManager.EstimateGasAsync(callInput).GetAwaiter().GetResult();
                var gasPrice = web3.Eth.GasPrice.SendRequestAsync().GetAwaiter().GetResult();
                TransferFunction transferFunction = new TransferFunction();
                transferFunction.AmountToSend = _amount;
                transferFunction.FromAddress = "0x068cE331d093166e95b30035Dcc4B9bEeE3D0A30";
                transferFunction.Gas = gasLimit;
                transferFunction.GasPrice = gasPrice.Value;
                transferFunction.To = "0xbf0522f34f2215741dC599f1Ad8c55E91037b4C8";
                transferFunction.Value = _amount;

                var transactionHash = standarErc20Service.TransferAsync(transferFunction).GetAwaiter().GetResult();

But it gives me rpc error

Juan Blanco
@juanfranblanco
Jul 05 2018 08:50
@immortalinfotech_gitlab if you use the transferfunction it will be automatically estimated for you
btw the above is doing it in a "raw" way not using the Service
but it is the same
Manish Goyal
@immortalinfotech_gitlab
Jul 05 2018 09:03
@juanfranblanco Thanks It worked.
Stefan Naegeli
@snaegeli
Jul 05 2018 12:51
I've sent a request to deploy a contract but provided a too low gas price. Now my transaction has been pending for hours. How can I resend the transaction with a higher gas price using Nethereum?
mainly use a ContractDeploymentObject and change the price using the same nonce
for the transaction input
Juan Blanco
@juanfranblanco
Jul 05 2018 13:27
or create a new transaction input using the same data
nonce
and new price
(just realised that the extensions are not released yet for contractdeployment
)
check this ^^
Jonathan Sheely
@jsheely
Jul 05 2018 13:50
If I'm reading this correctly. None of the methods get the current gas price. They all use the default value correct?
Unless you manually call Web3.Eth.GasPrice.SendRequestAsync() and manually add that value to the TransactionInput?
Juan Blanco
@juanfranblanco
Jul 05 2018 13:57
sorry yes
Juan Blanco
@juanfranblanco
Jul 05 2018 14:03
I might use that instead of the default in the transaction manager
Jonathan Sheely
@jsheely
Jul 05 2018 14:08
So I wrote a little function in Web3.js to do a one off transaction update. But I think this would be a useful utility function to replay a transaction with a higher gasPrice/gas.
Ivan Selivanovsky
@si1ver_graf_twitter
Jul 05 2018 14:08
image.png
@juanfranblanco Tell me please,how i can to use get input?
Jonathan Sheely
@jsheely
Jul 05 2018 14:12

So something like

ReplayTransaction(transactionHash, gasPrice, gas) {
    var oldTransaciton = getTransaction(transactionHash);
    var transactionInput = new TransactionInput { 
        nonce = oldTransaciton.nonce,
        gasPrice = gasPrice ?? oldTransaciton.gasPrice,
        gas = gas ?? oldTransaciton.gas
        Data = oldTransaciton.Input
    }
    return client.Eth.Transaction.sendTransactionAsync(transactionInput);
}

This is just pseudo code but you get the idea. All the data should be available in the previous transaction to be able to replay it.

Juan Blanco
@juanfranblanco
Jul 05 2018 14:12
create a function and call decodeInput
cool Jonathan true
Stefan Naegeli
@snaegeli
Jul 05 2018 14:13
Hi @juanfranblanco ! Thanks for the help. So if I understand you correctly I can simply create an instance of DeployContract and call the SendRequestAsync method with the overload containing the nonce and supply the previous nonce (and a higher gas price)
Juan Blanco
@juanfranblanco
Jul 05 2018 14:14
yep
Stefan Naegeli
@snaegeli
Jul 05 2018 14:14
will i receive the same transaction hash back? or a new one?
Juan Blanco
@juanfranblanco
Jul 05 2018 14:14
or what Jonathan says
but not out of the box at the moment
i might add that to the transaction manager
Stefan Naegeli
@snaegeli
Jul 05 2018 14:15
cool thanks @jsheely
Jonathan Sheely
@jsheely
Jul 05 2018 14:15
This is how I did it for real in web3.js
web3.eth.getTransaction('{transactionHash}').then(transaction => {
    console.log(transaction);
    if (transaction != null) {
        return web3.eth.accounts.signTransaction({
            nonce: transaction.nonce,
            to: transaction.to,
            data: transaction.input,
            gas: transaction.gas * 2
        }, '{privateKey}').then(signedTransaction => {
            return web3.eth.sendSignedTransaction(signedTransaction.rawTransaction).then(sentTransaction => {
                console.log(sentTransaction);
            });
        });
    }
    console.log('Transaction not found');
})
Juan Blanco
@juanfranblanco
Jul 05 2018 14:16
@snaegeli different transaction hash but same contract address (top of my head)
Stefan Naegeli
@snaegeli
Jul 05 2018 14:17
ok thanks! will try that now
Jonathan Sheely
@jsheely
Jul 05 2018 14:18
I believe it'll be the same transaction hash actually if you replay it.
Here is an example of one I wrote where I zero'd out the action. Where I replaced the input data with nothing so I "cancelled the transaction". And it has the same transaction hash. https://etherscan.io/tx/0xbfa4e6651b87927beccb3acbeff3bcb85fd81f162b8d1bbeaec887bb3e364760
Juan Blanco
@juanfranblanco
Jul 05 2018 14:24
hmm it is the sha3 of the signedTransaction
so having a different price will affect the signature
which is hashed too
hash then signed (i meant)
Jonathan Sheely
@jsheely
Jul 05 2018 14:28
Was not my experience in web3.js, And I changed To, gasPrice and input data.
But I could be wrong. I wasn't paying that much attention to the transaction hashes. Just happens that one I had in my code is still on the blockchain. /shrug
I actually looked at my logs and the other ones I ran are not showing up. So no idea
Juan Blanco
@juanfranblanco
Jul 05 2018 14:32
looking at the yellow paper
Jonathan Sheely
@jsheely
Jul 05 2018 14:33
You're probably right on the data. I'm just trying to figure out then how mine are showing up. I kept a scratch pad of a few of the transaction hashes. And basically out of the 10 I have. 3 are still on the blockchain with the same hash as what I updated it with
Juan Blanco
@juanfranblanco
Jul 05 2018 14:36
"contract adress" == The address of the new account is defined as being the
rightmost 160 bits of the Keccak hash of the RLP encoding
of the structure containing only the sender and the account
nonce.
Jonathan Sheely
@jsheely
Jul 05 2018 14:37
Makes sense then. Since the nonce is the same.
Juan Blanco
@juanfranblanco
Jul 05 2018 14:37
(edit, formulas are not very good to copy and paste)
Jonathan Sheely
@jsheely
Jul 05 2018 14:37
haha
Stefan Naegeli
@snaegeli
Jul 05 2018 14:39
ok so if I understand correctly that is also the reason why the contract already has an address even though it has not yet been mined
Jonathan Sheely
@jsheely
Jul 05 2018 14:39
Right, well sorta. You make up the address basically. It can be anything. It's the hash of the transaction that creates the address that matters
Juan Blanco
@juanfranblanco
Jul 05 2018 14:40
well you can calculate the contract address that way, but normally you will get it in the transaction receipt
calculating the transansction hash is the keccak signature stuff
Jonathan Sheely
@jsheely
Jul 05 2018 14:40
I use this service any time I want to quickly just make up an address https://vanity-eth.tk/
Juan Blanco
@juanfranblanco
Jul 05 2018 14:41
right but that is different
Jonathan Sheely
@jsheely
Jul 05 2018 14:41
Used for testing when I don't really care about the private key
Yep
Juan Blanco
@juanfranblanco
Jul 05 2018 14:41
that is an address / private key
not an account for a contract
Stefan Naegeli
@snaegeli
Jul 05 2018 14:41
yeah I was just wondering because I store the contract address on my local db once I get the receipt. So I am wondering if I can do that even before the transaction has been mined.
Juan Blanco
@juanfranblanco
Jul 05 2018 14:42
yes that way
Jonathan Sheely
@jsheely
Jul 05 2018 14:42
Agreed. You can do that.
Juan Blanco
@juanfranblanco
Jul 05 2018 14:44
ill add a todo if not already for that :)
Nethereum/Nethereum#281
Stefan Naegeli
@snaegeli
Jul 05 2018 14:49
Cool. Does that mean you would expose it on the API earlier than on the receipt?
Juan Blanco
@juanfranblanco
Jul 05 2018 14:49
well it will be done on demand
if wanted
but yes
Ivan Selivanovsky
@si1ver_graf_twitter
Jul 05 2018 14:55

@juanfranblanco thanks for your help. i have one more question
i get the transaction like
web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(new HexBigInteger(blockNumber));

and than want to parse input parameters.

Nethereum.JsonRpc.Client.IClient client = new Nethereum.JsonRpc.Client.???;
Nethereum.RPC.EthApiService ethApiService = new Nethereum.RPC.EthApiService(client);
Nethereum.Contracts.Contract contr = new Nethereum.Contracts.Contract(ethApiService, abi, contractAddress);
Nethereum.Contracts.Function c = new Nethereum.Contracts.Function(c,???);
c.DecodeInput(input);

Is there an easier way to get the input values?
i dont know where to find some parameters

Juan Blanco
@juanfranblanco
Jul 05 2018 15:08
at the moment thats about it
on the newer version you will be able to to
get the transaction and
use an extension on the FunctionMessage
Ivan Selivanovsky
@si1ver_graf_twitter
Jul 05 2018 15:15
cant find update in nuget(
last version 2.5.1
Juan Blanco
@juanfranblanco
Jul 05 2018 16:26
in the unreleased newer version
sorry
that is what I meant
eximarus
@eximarus
Jul 05 2018 16:35
yo @juanfranblanco any updates on my unity issue yet?
Juan Blanco
@juanfranblanco
Jul 05 2018 16:42
no i have not had time
also you have created a project with all the source
and i was going to test it with dlls (as it is easier)
let me do a quick test on the sample
Juan Blanco
@juanfranblanco
Jul 05 2018 17:12
@eximarus yes it is the tsl2 infura issue but for some reason unity3d does not support it
try myetherwallet https://api.myetherapi.com/eth
it works there, although not ideal
to not be able to switch between them
https://api.myetherapi.com/rop
that is the ropsten endpoint
@eximarus FYI
eximarus
@eximarus
Jul 05 2018 17:34
i see ill try that tyvm
Juan Blanco
@juanfranblanco
Jul 05 2018 18:05
@eximarus it works on Unity 2018.2.0b10
no need to do anything works out of the box tls12
eximarus
@eximarus
Jul 05 2018 18:13
ye i tried it out :D ill use mew for now as that seems to work and maybe switch to infuria when they release 2018.2. again thank you for your help and this amazing library :D
Juan Blanco
@juanfranblanco
Jul 05 2018 18:14
cool :)
TriplejumpGames
@TriplejumpGames
Jul 05 2018 19:10
hey, could someone point me in the direction of how to parse a dynamic array returned from a solidity function?
TarrahArshad
@TarrahArshad
Jul 05 2018 19:55
@juanfranblanco hi how to i can min eth and bitcoin in my c# code ?
TriplejumpGames
@TriplejumpGames
Jul 05 2018 20:59
is it possible to have dynamic array as a parameter of a DTO?
i'm trying to get an inventory array of NFT indexes returned from a solidity contract
TriplejumpGames
@TriplejumpGames
Jul 05 2018 21:42
nevermind, I figured out it needed to be list<>