Ethermint Supports Web3 Personal API
Authored by Colin Schwarz
Background
ChainSafe is happy to announce that we have completed another deliverable from our current grant from the ICF to bring Ethermint into production as a full Cosmos chain. We wanted to take this opportunity to explain our work on the Web3 Personal API and why implementing it in Ethermint is so important to maintain feature parity with Geth. If you would like more context on Ethermint before diving in, check out this article.
Our Work
In Ethereum, the personal API manages private keys in the keystore. We needed to implement this functionality on Ethermint so that Ethereum keys and signing would all be compatible. To do this, our team implemented the following functionality in Ethermint:
-
personal_importRawKey
-
personal_listAccounts
-
personal_lockAccount
-
personal_newAccount
-
personal_unlockAccount
-
personal_sendTransaction
-
personal_sign
-
personal_ecRecover
For the full specification that we were targeting, see the Geth Personal Namespace documentation.
You can also check the personal namespace methods on the Ethermint JSON-RPC docs.
Challenges and Lessons
Since the Cosmos SDK's keyring doesn't explicitly support locking and unlocking of keys the way Ethereum does, a workaround had to be implemented. Unlocking a key is done by exporting it from the Cosmos keyring via decrypting the file and storing it in memory. Locking the key deletes it from memory, leaving it only as an encrypted file on-disk. This work around is quite effective, the only functionality that is missing is unlocking a key for a certain duration of time. Although this is a fairly minor feature, we would still like to see it implemented in a fully productionized Ethermint Zone.
A long term solution could be to work with the core SDK team and propose an ADR to implement these changes on the Keyring.
Why it is Important
While some of the personal API functionality is already available from the Cosmos keys implementation, such as adding a new account and signing transactions, the personal API provides compatibility with the Ethereum Web3 API. This milestone also introduces additional features that are not available on other Cosmos chains such as locking and unlocking accounts.
Final Deliverables
The final pre-testnet deliverables of the grant will be upgrading Ethermint to the Cosmos SDK v0.40 (stargate release) and integrating IBC, the protocol for interoperability between chains. Beyond these, the remaining deliverables are launching a community focused initial testnet, launching an incentivized testnet, the "Game of Ethermint Zones", and productionizing Ethermint into a full Cosmos Zone.
The team is working full speed ahead and looks forward to tackling these goals to bring a fully productionized Ethermint to the public!
Get Involved
If you are interested in getting involved and contributing to the project, check out our Github. If you are already building or intend to start building your project on Ethermint, become a validator, or collaborate with the project in any other way, please get in contact with one of our Ethermint team members on Chainsafe's Discord, Cosmos's Discord under #Ethermint channel or email info@chainsafe.io. We would love to know more about you, your team and your project!
In order to make sure we stay connected with our community, we are planning on hosting our first community calls in the upcoming weeks to discuss the project, dig deeper into the current development, give periodic updates on the future roadmap and answer questions. Be on the lookout for upcoming announcements by following the Ethermint, ChainSafe and [Cosmos](https://twitter.com/cosmos) twitter and the Cosmos and Chainsafe blogs.