Fetch turns arbitrarily complex smart contract transactions into one-click experiences for users. Instead of mind-numbing sequences of steps to make a trade for example, Fetch gives users a simple one-click experience to make that same trade. Here’s a bit about why it’s so powerful and the technology we’ve built to make it possible.

Fetch can turn sequence of smart contract interactions into a one-click transaction. For example purposes, we’ll look at a trade using a 0x Relayer to give us something concrete to wrap our heads around. This technology can be applied to any other smart contract protocol.

In addition to trading, Fetch could be used to lend assets on Dharma, deposit funds to earn interest on Compound or use any other smart contract protocol with one-click.

First, What is a Transaction?

For a user, a trade isn’t multiple smart contract transactions, it’s just a trade — a buy or sell. So wrapping ETH, approving allowances, selecting orders from the order book, etc…This is just work along the way. Work better abstracted for the user so they can accomplish what they originally set out to do, make a trade.

Make Things Simple

It isn’t meaningful to a user to “approve an allowance”. It barely makes sense. As an API call in a sequence of steps, sure. As something a person has to learn and manage, please no.

How Fetch Works

Fetch is a wallet that manages your keys in a private, secure manner and makes signing transactions as simple as entering a password. The simplicity for the user abstracts complex processing under the hood.

Best Case Transaction Planning

To complete a larger transaction, like a 0x trade, Fetch must first predict the sequence of smart contract interactions required to successfully complete it. In the simplest form this can include steps like:

Wrap ETH — for simplicity let’s assume you have enough already

— for simplicity let’s assume you have enough already Approve WETH Allowance

Approve ZRX Allowance

Select Order(s) from the Book — depending on the state of the order book you may require partial fills. So this is 1 to n possible transactions depending on the trade and state of the order book.

— depending on the state of the order book you may require partial fills. So this is 1 to n possible transactions depending on the trade and state of the order book. Unwrap WETH — if user choose to do so.

To complete this happy path, Fetch first checks the state of the order book and determines the possible orders on the book that would need to be taken to complete this trade. Next, each transaction to complete each step is created with nonces managed to increment appropriately for each.

You can imagine it looking something like this:

Happy Path

What Happens When Things Go Wrong?

Above is the simple case, the case where everything goes as planned. But remember an order book is a living beast that can change quickly in volatile markets. So it is possible that you’re not able to complete the trade because the orders no longer exist on the book to make the trade.

When this happens, we want to unwind the transactions for the user so they return to their initial state. Making things simple means doing a ton of hard work it seems.

So, in addition to the happy path of transactions created first, we need to create off ramps of transactions for the reverse flow when the trade fails. Once again, nonces have to be managed appropriately.

It looks something like this:

(Un)Happy Path

Network Fees

Creating the set of transactions to execute is only the first part. We don’t want our users having to understand the sequence of work to be done and we definitely don’t want them figuring out the current state of the Ethereum network and estimating gas. We need to manage this for them and let them know what to expect.

Do the math for the user

So, we need to dynamically check the network to optimize the amount of gas to allocate to the transactions. There are more edge cases that Fetch manages here but for simplicity, right now let’s assume the user has enough ETH for the network fees.

Transaction Signing

Great, now we have all the transaction possibilities covered and we’ve let the user know what network fees to expect. The last step is for the user to approve and actually sign the transactions to submit them to the chain.

First, it’s important to understand that the transactions are created and signed by the user locally on their device. No keys are ever shared with Fetch (or anybody else)!

After reviewing the details, the user sees a password challenge to confirm and sign the transactions. The user doesn’t have to understand anything about the underlying steps, they are authenticating to make the trade, the thing they wanted to do.

People grok passwords

This is a key step, we’re not only abstracting the complexity of transactions for users, we’re also removing the requirement to learn new concepts of private keys, etc…it’s simple.

There is actually more Fetch does to accomplish one-click transactions — monitoring the chain for progress, managing the cases where things go wrong, notifying the user in-app of progress, updating the user’s portfolio, etc…Let’s leave that for a future post.

What’s Next?

Anything that is smart contract based can be turned into a one-click transaction by Fetch. Even combinations of protocols. Imagine an incredibly efficient flow, maximizing income with no work for the user, all with one-click:

Remove interest bearing tokens from Compound

Execute a trade with that token on a 0x Relayer

Lend the resulting token on Dharma at a higher interest rate

We’re excited at the possibilities!

At Fetch we’re making investing with tokens simple for everyone. Try it out and follow us on twitter @hello_fetch