These are chat archives for Nethereum/Nethereum

25th
Aug 2018
carlo perconti
@cryptoFT_gitlab
Aug 25 2018 04:56
Why are all the transaction function accepting a "from address" string but actually cannot process anyway if the Account is not the one signing the request ? I believe it will make more sense to have an Account parameter...., am I missing something ?
Truong Dang Nghia
@DangNghia123_twitter
Aug 25 2018 05:38
hi i want to send ether from smart contract to multip addresses
i following that code https://ethereum.stackexchange.com/questions/56043/easy-send-ether-to-multi-address
but when i deloyed on remix with enviroment: injected web3 ( metamask)
i be refused by that
Capture.JPG
how can i fill that field?
that is array
carlo perconti
@cryptoFT_gitlab
Aug 25 2018 06:19
@DangNghia123_twitter you need to type something like ["address1","address",......] I think
Stuart Corrans
@nonnb
Aug 25 2018 06:20

Hi - just started using Nethereum and must admit I'm already a massive fan - thanks for all the hard work!

Question - I've been able to decode the inputs to a contract transaction given the ABI as follows:

        var myFunction = contract.GetFunction("MyFunction");
        var myFunctionTxn = await contract.Eth.Transactions.GetTransactionByHash
            .SendRequestAsync(myTxnHash);
        var inputs = myFunction.DecodeInput(myFunctionTxn.Input);

However, now I would like to do the same (i.e. retrieve a transaction hash and then decode the constructor inputs) for the constructor itself. I can see the types of the inputs from this, but unfortunately not the values.

var ctor = contract.ContractBuilder.ContractABI.Constructor;

Is there an equivalent for DecodeInput for constructors?

p0isoN
@p0isoNz_twitter
Aug 25 2018 07:16
@EnigmaticUnreal_twitter I was using the default gas price of 2. Let me try 5
Juan Blanco
@juanfranblanco
Aug 25 2018 07:45
@nonnb there is an extension to decode the input of using the ConstructorDeployment
@cryptoFT_gitlab there are scenarios that you don't use an account.
Neither a managed or Nethereum account.
Juan Blanco
@juanfranblanco
Aug 25 2018 08:06
This is part of the standard rpc. Nethereum does default to this already if exists in some scenarios
The Account parameter is passed when instantiating Web3
Schalk Dormehl
@sjalq
Aug 25 2018 08:09
Hey folks,
I wrote a bunch of tests against TestRPC and was using the "revert" error that the RPC returned to check that certain actions failed.
It seems like those errors are not returned by Infura.
Can someone please point me in the right direction to intercepting the errors please?
PS I'm using Nethereum
Juan Blanco
@juanfranblanco
Aug 25 2018 08:11
@Cdpopham if you are looking to pass an authentication header (username, password) you can use this overload https://github.com/Nethereum/Nethereum/blob/05e97108c1c07e692d032786ac04b4730fe7dba7/src/Nethereum.Web3/Web3.cs#L33
@Cdpopham enums to ints, there is support already to have enums in c# as long as their interest value matches
Juan Blanco
@juanfranblanco
Aug 25 2018 08:17
@sjalq if trying to sign for multiple locations with the same account you need something external to track your nonces due to multitasking
You can create a custom NonceService and assign it to the TransactionManager of the Account.
@deancasey make sure you put "" in version, this is an issue with the linter
Stuart Corrans
@nonnb
Aug 25 2018 08:19
@juanfranblanco Many thanks! - I was also able to get it decoded using your code here and then decoding into a matching DTO. (by providing the byte code, not the abi)
Juan Blanco
@juanfranblanco
Aug 25 2018 08:24
@Nufflee @Dave-Whiffin on my latest release of the code generator some TS files are included, those need to be removed as a quick workaround after npm install. This is TS complaining about the definitions contained in the folder
I'll release a new version with those removed when I return.
Wednesday :)
Juan Blanco
@juanfranblanco
Aug 25 2018 08:30
@chitin4 until we write .net specific docs the best help for ENS is their docs.
@EnigmaticUnreal_twitter that desktop sample will go or move somewhere else.
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 08:32
@juanfranblanco Hey
could you help me out a little?
Me and @p0isoNz_twitter have an issue
var transferfuction =
                            new TransferFunction {
                                AmountToSend = Web3.Convert.ToWei(amount),
                                To = toAddress,
                                FromAddress = w3.TransactionManager.Account.Address,
                                Gas = gas,
                                GasPrice = new HexBigInteger(GasPrice)
                            };
                        //if (Gas != null) transferfuction.Gas = new HexBigInteger(Gas.Value);
                        //transferfuction.Gas = gas;
                        //if (GasPrice != null) transferfuction.GasPrice = new HexBigInteger(GasPrice);
                        var handler = w3.Eth.GetContractHandler(ContractAddress);
                        var transactionHash = await handler.SendRequestAsync(transferfuction);
                        MessageBox.Show(transactionHash);
It throws insufficent funds for gas*price + value
when i have 0.2 ETH in my account
Juan Blanco
@juanfranblanco
Aug 25 2018 08:34
@spied001 you can set the gas price in all the function messages, deployment messages or in the transaction input. Note that the transaction manager does get the gas price for you if not set on the transaction input now.
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 08:37
Tried multiple ways of sending
can send tokens on the same account with other clients
sorry missed this out
                    ulong GasPrice = (ulong)5000000000;
                    var gas = new HexBigInteger(BigInteger.Parse("100000"));
Juan Blanco
@juanfranblanco
Aug 25 2018 08:40
Have you let Nethereum estimate and set the gas price itself?
What is the value of the gas price and gas you set?
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 08:41

Have you let Nethereum estimate and set the gas price itself?

how do i do that

                    ulong GasPrice = (ulong)5000000000;
                    var gas = new HexBigInteger(BigInteger.Parse("100000"));
This is the gas price
and gas
Juan Blanco
@juanfranblanco
Aug 25 2018 08:42
And what is the amount you are sending (Ether amount)
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 08:42
its a token transfer
sorry for not making that clear
Juan Blanco
@juanfranblanco
Aug 25 2018 08:45
AmountToSend is the Ether not the token btw
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 08:45
0.o
Value?
or?
(Ether in Wei, just in case ;) )
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 08:48
so how do i do a token transfer?
Where do i put the token amount?
            basemodel.GasPrice = gas_price;

            Ensure.ArgumentNotNullOrEmpty(addressTo, "Address To");
            Ensure.ArgumentNotNullOrEmpty(url, "Url");
            Ensure.ArgumentNotNull(account, "Account");
            Ensure.ArgumentNotNull(amount, "Token Amount");

            var transferfuction =
                new TransferFunction
                {
                    TokenAmount = Web3.Convert.ToWei(amount),
                    To = addressTo,
                    FromAddress = web3.TransactionManager.Account.Address
                };

            if (basemodel.Gas != null) transferfuction.Gas = new HexBigInteger(basemodel.Gas.Value);
            if (basemodel.GasPrice != null) transferfuction.GasPrice = new HexBigInteger(basemodel.GasPrice.Value);

            var handler = web3.Eth.GetContractHandler("EC20");
            var transactionHash = await handler.SendRequestAsync(transferfuction);
Juan Blanco
@juanfranblanco
Aug 25 2018 08:49
@sjalq revert messages are not returned
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 08:49
I dont have TokenAmount
TokenAmount = Web3.Convert.ToWei(amount),
Juan Blanco
@juanfranblanco
Aug 25 2018 08:50
They will in the future (I assume) but geth or parity don't handle this.
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 08:51
Am I using the wrong TransferFunction maybe?
Juan Blanco
@juanfranblanco
Aug 25 2018 08:51
Interesting as that might bloat the transaction receipts.
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 08:52
what class should it be under?
p0isoN
@p0isoNz_twitter
Aug 25 2018 08:56
@juanfranblanco same issue as Abdullah
Was also using amounttosend as no TokenAmount exists
Juan Blanco
@juanfranblanco
Aug 25 2018 08:59
@nonnb yeah the extension on the transaction does call that code :) glad you are sorted
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 09:09
@p0isoNz_twitter check pms - i think i fixed it
Juan Blanco
@juanfranblanco
Aug 25 2018 09:35
@AbsenceAbdullah_twitter all your messages came at once sorry. Yes you need to use tokens the
"token amount"
You can set the values for gas / gas price in the function
If wanted, automatically will be estimated call get gas price for you
What I gathered is that you were using the wrong field
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 09:45
Np
figured out you could just do this
var tokenService = new StandardTokenService(w3, ContractAddress);
                        var transactionHash = await tokenService.TransferAsync(account.Address, toAddress, amount, new HexBigInteger(90000));
Juan Blanco
@juanfranblanco
Aug 25 2018 09:49
Yes that uses the transaction function
And does the gas price for you
p0isoN
@p0isoNz_twitter
Aug 25 2018 09:50
Yeah
Juan Blanco
@juanfranblanco
Aug 25 2018 09:51
Although it is not auto estimating for you
Geth is rather good at it now :) before was best to pass your own values
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 09:54
Ahh
Do i need to do anything to the value. Like convert it or something
because i sent 1 MCO
and it sent 0.00000001
Oh wait nvm
its decimals
Enigmatic
@EnigmaticUnreal_twitter
Aug 25 2018 11:26
Thanks for taking time off your vacation to reply us @juanfranblanco <3
Truong Dang Nghia
@DangNghia123_twitter
Aug 25 2018 11:37
hi i want to send ether from smart contract to multip addresses
i following that code https://ethereum.stackexchange.com/questions/56043/easy-send-ether-to-multi-address
but when i deloyed on remix with enviroment: injected web3 ( metamask)
i be refused by that
hi pls anyone help me
Enigmatic
@EnigmaticUnreal_twitter
Aug 25 2018 11:50

@DangNghia123_twitter

Basically the input parameter should be [address1,address2...address100],[value1,value2...value100]

You might be seeing errors because, the code expects to have the full array (100) populated so if you test with only one or two values it'll throw an error, and you'll need to load up the contract with ethers so it'll be able to execute the transfer.

Try to play with the below code to get an idea:

    function multyTx(address[] addrs, uint[] values) public {
        require(msg.sender==owner);
        for(uint256 i=0;i<addrs.length;i++){
            // do something
        }
    }
This uses a dynamic length array so you could also pass in just a few elements. Just be mindful of the number of elements you pass in since each loop will cost gas. Better if you use a require(addrs.length < 100) for example, if you've decided only to loop through 100 addresses.

The parameter input could look a little like this typed on Remix:

["0xf011e41823de7a3de1184038373648755d5d53f1","0xf011e41823de7a3de1184038373648755d5d53f2"],[1,2]

image.png
Truong Dang Nghia
@DangNghia123_twitter
Aug 25 2018 11:57
Capture.JPG
@EnigmaticUnreal_twitter
it thrown an error
this my my fullcode
Enigmatic
@EnigmaticUnreal_twitter
Aug 25 2018 12:01

@DangNghia123_twitter - use dynamic array, the last error happens because it expects an array of 100. And your parameter should look: ["0xf011e41823de7a3de1184038373648755d5d53f1","0xf011e41823de7a3de1184038373648755d5d53f2"],[1,2]

PS: I can't see your code that way. You'll need to use gist. :)

Try this.
Play with it with the Javascript VM to get a better idea of how it works.
I've removed the transfer function. Remember if you want to test the transfer function, you'll need to load up your contract with eth.
Truong Dang Nghia
@DangNghia123_twitter
Aug 25 2018 12:07
@EnigmaticUnreal_twitter thank you very much
it worked
pls tell me how to deloy it on mainnet
Enigmatic
@EnigmaticUnreal_twitter
Aug 25 2018 12:11
You can deploy it via Injected Web3 using Metamask. Would still suggest to play around with it until you're really comfortable, before deploying to mainnet and using it.
image.png
Truong Dang Nghia
@DangNghia123_twitter
Aug 25 2018 12:13
@EnigmaticUnreal_twitter i passed ["0x12eD54a4cfFBbea122F6585B31A957BdDf17f952"],[100000000]
why it send 0 ether to contract and not send to recepient address
Enigmatic
@EnigmaticUnreal_twitter
Aug 25 2018 12:16
That's not how the contract works. How this contract works is, you put ETH in it. Then you tell it to disburse the ETH to the addresses specified with the parameters you enter.
Send some ETH to that contract
And try again.
If it still doesn't works then you might need to publish your contract source code so I can have a look.
(actually your problem isn't relevant to Nethereum - Might be better just to PM me)
Truong Dang Nghia
@DangNghia123_twitter
Aug 25 2018 12:18
thank you
pls check pm
p0isoN
@p0isoNz_twitter
Aug 25 2018 12:52
@juanfranblanco what is your donation address
Abdullah Rangoonwala (Absence)
@AbsenceAbdullah_twitter
Aug 25 2018 16:16
anything like this for Ethereum?
alphasignal
@alphasignal
Aug 25 2018 18:40
Anyone can help with events? I want to subscribe to an event for a contract that I did not create. Is this possible, and will this propagate all event actions that happen on the contact, and will this be asynchronous?