These are chat archives for Nethereum/Nethereum

6th
Mar 2018
Andres G. Aragoneses
@knocte
Mar 06 2018 06:17
@juanfranblanco how's the logging going? :sweat_smile:
as I was blocked (until I get that neth release) I added LTC support to my wallet in the meantime :laughing:
Juan Blanco
@juanfranblanco
Mar 06 2018 07:34
i will push it today :)
@knocte
with or without logging, I am looking for a good abstraction which does not force Nethereum to go netstandard2.0
jhernandezgroupbme
@jhernandezgroupbme
Mar 06 2018 08:44
@anegg0 muchas gracias
Andres G. Aragoneses
@knocte
Mar 06 2018 08:46
I still need 4.5.2 support :grimacing:
Rob Aboud
@RobAboud
Mar 06 2018 09:40
hey guys i have deployed a contract with truffle, would it be possible to interact with this contract via an ASP.NET webpage with Nethereum? I'm guessing I need to copy my ABI or something but I'm just not sure I'm going about this the right way
Juan Blanco
@juanfranblanco
Mar 06 2018 09:40
@RobAboud yes
Rob Aboud
@RobAboud
Mar 06 2018 09:41
great, thanks
for a quick intro
Rob Aboud
@RobAboud
Mar 06 2018 09:41
awesome thank you :smile:
Juan Blanco
@juanfranblanco
Mar 06 2018 09:42
also note that signing transactions etc should be offline
ie the user controls the signing process
if you don't manage their keys which it will only be a good scenario in an enterprise setting
i guess :)
Rob Aboud
@RobAboud
Mar 06 2018 09:45
hope my understanding isn't wrong there
Juan Blanco
@juanfranblanco
Mar 06 2018 09:46
well if you are the one who is going to sign the transaction
no*
Rob Aboud
@RobAboud
Mar 06 2018 09:46
great yeah that's the plan. cheers!
Juan Blanco
@juanfranblanco
Mar 06 2018 09:47
this can help you too
just replace the logic with your transaction hash upload
Rob Aboud
@RobAboud
Mar 06 2018 09:49
you are a legend thank you so much man this looks perfect
as you may not want to use a string but a byte[] for the hash
and no bother :)
Rob Aboud
@RobAboud
Mar 06 2018 11:31
theres no reason Nethereum couldnt interact with the Rinkeby test net right? I have my geth hooked up to it but i cant seem to make any transactions with nethereum yet... probably not interacting with geth properly or something else
Juan Blanco
@juanfranblanco
Mar 06 2018 11:32
shouldn't be any problem at all
try the infura url for rinkeby
that might help using another node
Rob Aboud
@RobAboud
Mar 06 2018 11:33
good idea
Do I need to initialise both my password and my privateKey? I had assumed just the password would be enough
Juan Blanco
@juanfranblanco
Mar 06 2018 11:36
if you connect to infura
you need your private key
they don't store your private key (decentralised)
Rob Aboud
@RobAboud
Mar 06 2018 11:37
gotcha, but locally it should have worked with just the password right?
Juan Blanco
@juanfranblanco
Mar 06 2018 11:37
yes
you will use your ManagedAccount then
with the address and Password
instead of an account
Rob Aboud
@RobAboud
Mar 06 2018 11:38
ah i see, thanks :smile:
Juan Blanco
@juanfranblanco
Mar 06 2018 11:39
geth will use the password to unencrypt the storage file and retrieve the private key
Rob Aboud
@RobAboud
Mar 06 2018 11:42
gotcha :+1:
Rob Aboud
@RobAboud
Mar 06 2018 14:09
using Nethereum.Web3;
var web3 = new Web3.Web3(new Account(privateKey), "https://rinkeby.infura.io");
does that syntax look right to you guys? I'm getting "the type name 'Web3' does not exist in the type 'Web3'"
Nikolay Postoyko
@dotnicht
Mar 06 2018 14:15
new Web3(
Rob Aboud
@RobAboud
Mar 06 2018 14:17
wooops, cheers :smile:
old baker
@oldbaker
Mar 06 2018 17:25
@juanfranblanco Please help write service for the foollowing project https://github.com/zeppelinos/labs/tree/master/upgradeability_with_vtable
old baker
@oldbaker
Mar 06 2018 17:31
I specifically need help with delegated proxy contracts as we discussed earlier
Juan Blanco
@juanfranblanco
Mar 06 2018 17:33
so what exactly is your problem
or you dont understand
old baker
@oldbaker
Mar 06 2018 17:42

For ex, if this were a contract that was proxied

  var contract = web3.Eth.GetContract(abi, contractAddress);

  var multiplyFunction = contract.GetFunction("multiply");

..then the abi and contractAddress here are not the public facing contract (which is the delegated proxy contract, for eg: following)

contract DelegateProxy {
/*
* @dev Performs a delegatecall and returns whatever the delegatecall returned (entire context execution will return!)
* @param _dst Destination address to perform the delegatecall
* @param _calldata Calldata for the delegatecall
*/
function delegatedFwd(address _dst, bytes _calldata) internal {
     assembly {
        let result := delegatecall(sub(gas, 10000), _dst, add(_calldata, 0x20), mload(_calldata), 0, 0)
        let size := returndatasize

        let ptr := mload(0x40)
        returndatacopy(ptr, 0, size)

        // revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas.
        // if the call returned error data, forward it
        switch result
        case 0 { revert(ptr, size) }
        default { return(ptr, size) }
        }
    }
}
Juan Blanco
@juanfranblanco
Mar 06 2018 17:43
I know
so what is your problem
old baker
@oldbaker
Mar 06 2018 17:44
So then how do i send tx to the second contract with an intention of multiplying?
Juan Blanco
@juanfranblanco
Mar 06 2018 17:44
address _dst, bytes _calldata
old baker
@oldbaker
Mar 06 2018 17:44
how do i get calldata?
Juan Blanco
@juanfranblanco
Mar 06 2018 17:45
GetData
from the function
you will need to convert it to a byte[]
HexToByteArray() extension
old baker
@oldbaker
Mar 06 2018 17:48
An example would be really helpful, how to multiply by 7?
Thanks a lot though really!
Juan Blanco
@juanfranblanco
Mar 06 2018 17:48
?
use any of the samples for the multiply by 7
but instead of calling the transaction
use GetData(7)

Ok step by step:
old baker
@oldbaker
Mar 06 2018 17:50
transactionHash = await multiplyFunction.GetData(senderAddress, 7);
Juan Blanco
@juanfranblanco
Mar 06 2018 17:50
(1) You are going to need two contracts
(2) First the Proxy contract (with abi)
3) Second the Delegated Contract (with abi)
(4) Delegated is the Multiply contract
so do as usual web3.GetContract(abi, address); (address is not particularly necessary here)
(5) contract.GetFuntion("multiply");
(6) var data = function.GetData(7);
now you have the data...
convert the data to a byte array
and the rest is the normal stuff
old baker
@oldbaker
Mar 06 2018 17:53
thanks a lot
Juan Blanco
@juanfranblanco
Mar 06 2018 17:54
on that note, I need to make this simpler for CQS messages :)
old baker
@oldbaker
Mar 06 2018 17:54
How to access anonymous payable?
Juan Blanco
@juanfranblanco
Mar 06 2018 17:54
in that scenario as a proxy?
old baker
@oldbaker
Mar 06 2018 17:55
yes
like you know a standard erc20 wanting to be upgradeable
Juan Blanco
@juanfranblanco
Mar 06 2018 17:55
i haven't tested that
old baker
@oldbaker
Mar 06 2018 17:56
erc20 crowdsale i mean, some kind of anon function that is payable
Juan Blanco
@juanfranblanco
Mar 06 2018 17:56
yeah
that proxy is just for smart contract data
there is no value send
old baker
@oldbaker
Mar 06 2018 17:56
value is not forwarded??!!
Juan Blanco
@juanfranblanco
Mar 06 2018 17:57
no Ether value is not forwarded
old baker
@oldbaker
Mar 06 2018 17:58
Hmm, interesting
TIL delegatecall does not forward eth , ty
So any suggestions beyond writing additional functions to handle the eth?
Also, what if the proxied contract is just anonymous, not payable, how to do it in that case?
Juan Blanco
@juanfranblanco
Mar 06 2018 18:02
ah sorry
i thought it was call, delegate preserves the msg.sender and value
but for an anonymous catch all
old baker
@oldbaker
Mar 06 2018 18:04
what does that mean :)
Juan Blanco
@juanfranblanco
Mar 06 2018 18:04
you may get away with no data
old baker
@oldbaker
Mar 06 2018 18:04
how do i "catch them all" :P
Juan Blanco
@juanfranblanco
Mar 06 2018 18:04
as the call will be done to the generic catch all function
mainly the anonymous function
does that
any function not matched
so if you dont' have any data
the function that will be used will be that
old baker
@oldbaker
Mar 06 2018 18:05
yes but how do i write that tx, using functions i have "get" from the proxied contract
Juan Blanco
@juanfranblanco
Mar 06 2018 18:06
well test it :)
then as a normal function (not anonymous) and passing some data as before
then as payeable
old baker
@oldbaker
Mar 06 2018 18:07
thanks a lot for your help Juan!
Juan Blanco
@juanfranblanco
Mar 06 2018 18:07
and finally as anonymous (no data)
the data defines the function and parameters
so without data the call "might" be made to the anonymous , haven't checked that lately (or that i can remember) with delegates
(as payeable) just pass some Ether value
you may need to mark the proxy payeable to not fail
old baker
@oldbaker
Mar 06 2018 18:11
hmm makes sense
Juan Blanco
@juanfranblanco
Mar 06 2018 18:12
the question has moved to every scenario of call delegation
ill create a TODO for all those samples
(but not today ;) )
old baker
@oldbaker
Mar 06 2018 18:13
Thanks a lot for your work!
Juan Blanco
@juanfranblanco
Mar 06 2018 18:14
thanks :)
Juan Blanco
@juanfranblanco
Mar 06 2018 20:25
@knocte just published (it may not be listed yet)