Inspiration

The MetaMask and Agoric teams are both working in the blockchain ecosystem. We have a strong relationship given past projects based on a shared common interest in robust, programmable security models. MetaMask's lava-moat is a tool that uses Agoric's SecureJS to secure the dependency graph of a Javascript application (such as the MetaMask wallet).

We got together during this hackathon to create this core integration of Agoric's SecureJS blockchain platform with the MetaMask wallet to enable developers to create seamless, secure Dapps.

What it does

An Agoric blockchain user first browses an enabled Dapp website. The Dapp can use MetaMask to fetch wallet balances and exchange digital assets connected to the Agoric Cosmos zone by:

  1. Using the Dapp's logic to construct an offer
  2. Prompting to approve the transaction by a secure browser popup which clearly explains the enforced constructed terms
  3. If approved, executing the exchange via Zoe, Agoric's offer safety server

How we built it

We built a plugin for the new, plugin-enabled Metamask browser extension. The plugin provides a secure, in-process bridge from the running Dapp browser code and a locally-installed Agoric blockchain client.

We modified the Agoric sample autoswap (i.e. uniswap-like) Dapp and the Agoric sample wallet to use the MetaMask plugin's newly-provided in-browser APIs to fetch balances, conduct the exchange and query transactions.

All code written was in Javascript.

Challenges we ran into

The Metamask plugin system is in beta, and the Agoric chain is currently in testnet. Both are currently moving targets.

We had stretch goals of using generic RPC mechanisms to communicate with the Agoric chain, but instead hand-wrote each bridge function. This caused several bugs that were hard to find and fix, which should have been systematically easier.

Accomplishments that we're proud of

  • This is the first time MetaMask has been able to run a blockchain other than Ethereum.
  • This is Agoric's first non-internal wallet integration.
  • We're able to have some of the most comprehensible blockchain transactions ever on MetaMask, thanks to Agoric's Zoe.

What we learned

JavaScript across the stack definitely made this easier.

Agoric re-learned some Ethereum lessons about isolating wallet functionality from data access on their RPC servers.

We learned a lot about each other's projects and how they work.

What's next for Agoric in MetaMask in Agoric

Probably a total rewrite. The plugin system, along with much of Agoric's blockchain, are fairly early in development, but this early experiment has really helped us frame our future efforts around how to secure and optimize for this kind of interaction.

Built With

Share this project:

Updates