-
The base AutoSwap app
-
The MetaMask initial sign-in prompt, asks to install a plugin.
-
The plugin then requests its own permissions.
-
The AutoSwap app can then be used
-
Currencies selected
-
The Plugin is able to provide a rudimentary confirmation to the user. This is very human readable thanks to Agoric's Zoe.
-
The confirmation can then be confirmed via the Wallet app, also a MetaMask dapp.
-
The Agoric assets visible in MetaMask's internal wallet.
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:
- Using the Dapp's logic to construct an offer
- Prompting to approve the transaction by a secure browser popup which clearly explains the enforced constructed terms
- 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.
Log in or sign up for Devpost to join the conversation.