Is an equivalent of Solidity’s
msg.sender available when developing ESCs in Rust ?
Is an equivalent of Solidity’s
hi @guix I think nope. We need to put the eth address to check manually.
What do you mean ? Using a
msgSender argument in a secret contract method and calling from the frontend
computeTask(fn, args, gasLimit, gasPx, sender, scAddr) where
msgSender is in
If so, or even if in the ESCs we would use the 5th argument
sender there would be no guarantee at all that the sender is who he claims to be.
Is there an example somewhere ?
@guix i think a user would have to sign a message using web3.eth.sign and then you would have to verify the signature in the secret contract. It looks like parity has a crate call ethkey that might be able to help with verifying a signature in rust (https://docs.rs/ethkey/0.2.5/ethkey/struct.EthAccount.html#method.verify). I haven’t tested it myself yet, so i don’t know if that’s the right library to use
Did you resolve it?
No, I didn’t solve it. Since we call
computeTask(fn, args, gasLimit, gasPx, sender, scAddr) from the frontend (or tests), I guess there should just be a very simple way way to get
sender it inside of the secret contracts.
Flagging this question for @adi @victor or @fredfortier – the question is how to check within the secret contract from which Ethereum address the task is originating. I guess in our millionaire’s example we draw this information from the add_millionaire function only.
For example, in the millionaire’s problem walkthrough, for example, address is submitted via add_millionaire public-facing function in secret contract.
add_millionaire— Allows us to add/register a new millionaire with an Ethereum address (
H160) and net worth (
I think @guix you are asking if there is a way to reference the sender address aside from what is submitted as part of a public facing function in the secret contract?
( just for ease of reference, here are some existing demonstrative examples of rust-based secret contracts. )
Yah, at the moment, I thought that we need to pass the ETH address from the UI then in the
lib.rs will use it as the same way which millionare demo did.
Just want to let everyone know we’re looking into this today. Thanks for your patience!
Hi @ainsley, that’s it
hi @ainsley, do we have any updates on this one?
Not yet – if we don’t have a better suggestion by tomorrow, we’ll suggest going with the workaround for now (passing the address in to a specific function, as illustrated in the ERC-20 token example)
hi @ainsley so do we have any better solution? Or temporarily we will workarount as the ERC-20 token example?
Our guidance is to use this workaround (as in the ERC-20 example) for the time being.
A better solution to this is on our list of todo’s but we have a few other deadlines to hit first.
Sorry, I still don’t get it, even with the ERC-20 example. I don’t really understand the verify method, an explanation line by line could be useful for me. Also, a mocha test or some UI code for this ERC-20 impl could be useful, in particular how you would build from them the last parameter