Web + Money

Ariel Barmat
Sep 18, 2017 · 5 min read

As part of my work at PopChest exploring new ways to help content creators using blockchain technologies I set up an experimental Revenue Share smart contract to automatically distribute funds among different beneficiaries in a trustless and transparent way.

It basically works by adding a number of members to the contract indicating their corresponding shares of participation, once the contract is deployed all the payments sent to it will increase the balance ready to be claimed by each of the beneficiaries in the proportion they own.

Use cases

A contract that split payments to multiple parties can be used in different scenarios, a group of artists that want to set in advance how their proceeds will be distributed, affiliate programs where each party configures the fees and all the payments are sent to the contract, etc. As an added benefit it also gives every party a way to audit all the transactions going in and out.

Considering costs when programming

When you have programmable money and a distributed network that operates based on incentives you have a whole new dimension of decisions to make, it's not only about function, speed and security but also on who pays for what and the friction related to that.

One of the design decisions while building the contract was when to distribute the funds received. The problem is that every transaction that updates the state in Ethereum pay some fees to the network and that means as a developer that you can decide who pays this cost depending on what code is executed and when. I decided to avoid distributing payments as soon as they arrive to the contract, that would mean extra gas costs to the sender, I wanted to keep the payment part as standard as possible. Instead, as a beneficiary you send a claim transaction when you are ready to withdraw your balance which will calculate your take and send it to your account.

Another consideration about costs was that whenever you wanted to create a new Revenue Share contract with your own terms you had to deploy the whole code over and over. To avoid that, the contract is deployed once using a Factory Contract which provide a function to create a Revenue Share contract with the client's parameters.

Building something for humans

Then it was time to build a user interface to make the process of managing your contract easily, that means deploying a new contract, watching for changes in the balance and allowing the withdrawal of funds.

Image for post
Image for post

Some challenges and friction points when building for decentralization:

  • Wallet: A vital component to participate on any app using a blockchain is the wallet. It holds the private keys to sign transactions on your behalf. This wallet can live in your browser, your mobile phone, a hardware wallet, even a piece of paper. Some services generate their own wallet when you visit them for the first time and store it encrypted on the local storage of the web browser. The empowerment of users having the choice of managing their own wallets and funds is a big change which require a great responsibility from each user on how to use and secure their keys. For convenience this app is currently using Metamask which provides a wallet as a browser extension which you can use across different sites.

As we get more DApps in the open we will develop some standards and best practice on how to provide predictable and easy-to-use applications combining centralized with decentralized elements.


Take a look at the contract code and the DApp code on GitHub.

You can play with the contract running on the Ropsten testnet at https://smart.popchest.com

Send feedback and questions!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store