Developers! Answer Questions on the Ethereum Stack Exchange

Devs helping devs build a better blockchain ecosystem for us all

Consensys
ConsenSys Media
6 min readJun 11, 2019

--

Stack Exchange is a network of sites, generally focused around certain topics. Stack Overflow is by far the most popular question and answer site where developers can get in-depth and specific responses to coding challenges. Although mainly used in tech, the discourse on Stack Exchange now covers everything from religion to home brewing.

Stack Overflow by the numbers

At the beginning of this week, there were 6,782 unanswered questions on the Ethereum.StackExchange.

To support the Ethereum developer community, a collection of ConsenSys devs joined forces to answer as many questions as they could during a lunch break.

ConsenSys Paris developers answering questions on Ethereum Stack Exchange

It was a success!

A collection of full-stack developers from Paris, London, Dublin, and a few scattered around the world answered a list of relevant questions over the course of the week.

Here’s a look at some of the questions answered by ConsenSys developers.

What is the correct implementation of ERC777 standard?

Hurb asks:`

Does anyone know how to correctly implement the new ERC777 token standard? I’ve been trying to create an ERC777 contract (see code below) but keep struggling with a couple of things.

According to the standard, recipient addresses must match the ITokenRecipientinterface as returned by an ERC-672 reverse lookup. Any idea how to do this?

There seems to be a fallback interface ITokenFallback that is not mentioned in the standard at all. How does 777 handle fallbacks (e.g. in case foreign tokens are sent to the contract)?

The standard requires the usage of operatorData and userData but doesn’t really say what to do with these values. Is it sufficient to include this data in the events that are defined in the 777 interface?

My ERC777 implementation so far:

I did some research and stumbled upon YogaToken. However, it uses ERC672 and a more complex implementation of authorizedOperators which adds globallyAuthorizedOperators and a doSend() function. It doesn't implement ITokenRecipient, either.

Julien Marchard, Tech Lead @ ConsenSys Paris answered:

1. Matching the ERC777TokensRecipient interface is optional. More specifically, one single ERC1820 registry is deployed on most Ethereum networks, always at the same address: 0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24. The ERC1820 registry contains a mapping from addresses to contract addresses verifying the ERC777TokensRecipientinterface. Those ERC777TokensRecipient contracts contain a tokensToSend and a tokensReceived hook functions.

Every ERC777 transfer occurs in the following way:
Step1: If the sender address is registered in ERC1820 registry the tokensToSend hook function is executed. If the sender address is not registered, this step is skipped.
Step2: The sender and recipient balances are updated.
Step3: If the recipient address is registered in ERC1820 registry the tokensReceived hook function is executed. If the recipient address is not registered, this step is skipped.

2. There’s no fallback interface.

3. It is not specified in the standard, it depends on the implementation. The data field can contain information which will condition the validation/revert of the transaction depending on the business use case. For example, the implementation proposed by ConsenSys uses the data field to inject a certificate containing a signature of an authority verified on-chain thanks to an ecrecover operation.

ConsenSys Ireland developers answering questions on Ethereum Stack Exchange

How to compare hashes in Solidity

Jordi Estapé Canal asks:

How does abi.encodePacked(…) and sha256(..) work in Solidity?

I’m trying to implement a signature in a Solidity contract and I’m having problems when it comes to comparing hashes. I calculate the hash with the following code in solidity:

Where:

and

The main problem I’m having is that by using python sha256 on 0102030405060701 the result I’m getting is 5bc31e3decf480124c79c114744d111ec82b62e466a097c3ced6fe76cbace9a5

What am I doing wrong?

Bruno Martins, Senior Software Engineer at ConsenSys Ireland answered:

You are not using the correct hashing function on the client. Solidity uses keccak256, although similar, not exactly the same as in sha3–256.

web3js handles this by specifically have a soliditySha3 function to avoid confusion ( web3.utils.soliditySha3 ).

You need to check the equivalent for your python lib.

How to run geth without a console.

Руслан Миров asks :

I need run geth on server without console. How to do this? just not add argument console?

And can I attach to geth running without console, when I want to stop geth, or open console.

Oisin Kyne, Full Stack Engineer @ Consensys Ireland answered:

If you append an ‘&’ at the end of your geth <args> & command, it will run the command as a separate process in the background. Then you should be able to connect to it with geth attach from a separate console to stop or modify it.

Bonus, if you’re wondering how many questions are posted on Stack Overflow per day, the answer may astound you.

There are 5,378 questions per day on average over the last two weeks.

Using the API’s /info, monitor questions_per_minute and answers_per_minute reveals:

Every question and answer counts! Head to the Ethereum Stack Exchange to get in the mix with Web3 developers all over the world and sharpen your skills as you build the future.

Disclaimer. The views, information, and opinions expressed are solely those by the author above do not necessarily represent the views of Consensys AG. They are meant for informational purposes only, are not intended to serve as a recommendation or investment advice to buy or sell any securities, crypto assets, or other financial products.

--

--

Consensys
ConsenSys Media

A complete suite of products to create and participate in web3.