🎉 Middleman: In Beta Today
Web3 should be really exciting for consumers: banking for the unbanked: financial tools that don’t discriminate, a right to vote and shape product roadmaps, freedom from lock-in, and real transparency into how systems work. But right now to use a web3 app, you need to be savvy and technical enough to find and setup a wallet, buy crypto and trade the tokens you bought for the tokens you need, and somehow securely manage private keys and seed phrases. This is a lot to ask.
The same way that you don’t need to understand how a car works to drive it, you don’t need to understand how Advil works to take it, and you don’t need to understand how SMTP works to use Gmail, you shouldn’t need to understand how blockchain works in order to use a dapp. I think blockchains will hit their tipping point when users don’t even know that they are using one.
To this end, I think we are going to see several abstraction tools emerge to help developers abstract away crypto for non-technical users. One that already exists today is Infura, which is an API for developers to connect to an Ethereum node in the cloud if a user doesn’t happen to run one locally. Infura now serves 6 billion requests a day and is included in over 15K pieces of code on Github.
Today I’m releasing another abstraction tool to help developers onboard non-technical users: meet Middleman.
Middleman lets developers spin up and connect to a virtual wallet in the case that a user doesn’t already have one. The Middleman API can do anything a web3 wallet can do, the only difference is that the wallet is hosted remotely and not in the user’s browser.
Here is an example of how you would use Middleman to check if a user has a wallet installed and otherwise create one on their behalf:
import 'web3.js' void async function() { // check if the user already has a wallet if (typeof web3 !== 'undefined') { let web3 = new Web3(web3.currentProvider) } else { // create a wallet with Middleman let wallet = await createWallet('user_id') web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io")) } } async function createWallet(userId) { let wallet = await fetch('https://api.middleman.cx/wallets', { method: 'POST', headers: { 'X-Auth-Key': 'MY-AUTH-KEY' }, data: { 'user_id': 'current_user_id_001' } }) return wallet.json(); }
And then here is how you would use that wallet to send a transaction on behalf of a user:
let transaction = { "to": "0x8d3e809fbd258083a5ba004a527159da535c8aba", "value": 0.1, "gas": 2000000 } async function signTransaction(address, transaction) { let signedTransaction = await fetch(`https://api.middleman.cx/wallets/address/${address}/signTransaction`, { method: 'POST', headers: { 'X-Auth-Key': 'MY-AUTH-KEY' }, data: { transaction } }) return signedTransaction.json(); } web3.sendSignedTransaction(signTransaction(address, transaction))
Middleman is in beta today. I can't wait for you to try it out, and if you do, let me know if there are features you’d like to see: I'm [email protected].
API docs are here: docs.middleman.cx
To get started go here: middleman.cx
And if you want to try out the API without firing up a command line, you can login to the developer portal and take Middleman for a spin.
🎉 Enjoy! Excited to hear what you think.