Learn how to distribute tokens from Uniswap

Toshiaki Takase
Iroiro Social Token🎨
4 min readFeb 18, 2021


This article will introduce the implementation method on how to distribute tokens, referring to the $UNI token distribution case study conducted by Uniswap. And also show how Iroiro is using the same method with Wallet Address distributor and URL distributor.

Extracted to distribution targets

Uniswap distributed its own governance token called $UNI on September 16, 2020. The token distribution targets at that time were extracted as of 0:00:00 September 1, 2020 (GMT).

The query for the extraction is available on Github here.

This shows that Uniswap has distributed tokens to wallet addresses that have performed specific on-chain actions.

$UNI Token distribution

So how did they distribute the tokens?

They have published their code on Github under the name Merkle Distributor, so let’s have a look at it.

Simply transferring the token to the target wallet address would cost too much gas. However, it would be too costly to include all the wallet addresses to be distributed in the token distribution contract and verify the wallet addresses.

Therefore, the Merkle Proof method was used to verify that the wallet address is the one to be distributed. These functions deal with the verification of Merkle trees (hash trees).

Source: https://en.wikipedia.org/wiki/Merkle_tree

The pre-extracted wallet address is hashed using the Merkle tree, and the final Merkle Root is derived.

In addition, the Merkle proof verifies that the root of the Merkle tree is obtained by using the hash value of the leaf element and other leaves.

In the case of Uniswap, the Merkle tree of a hash of address is not simply generated, but “index” and “amount” (token distribution amount) are used as the value of leaf with the address. In Uniswap, it is called Balance Tree.

The resulting Merkle tree can be found here.
=> https://mrkl.uniswap.org/

Using the generated Merkle Tree, Uniswap uses the Merkle Proof library published by Openzeppelin to check if the address is eligible for token distribution.

Similar Examples

A music streaming service called Audius has distributed a token called $AUDIO. In this case, they used Uniswap’s Merkle Distributor to create a Merkle Tree for token distribution.

This Uniswap repo (https://github.com/Uniswap/merkle-distributor) contains the contract that we vendored in this repo. It also contains scripts to convert a json object of { walletAddress: tokenAmount } into the merkle object. In order to generate that object:

Iroiro’s token distribution method

Iroiro is currently offering Wallet Address Distributor and URL Distributor. Both of these are implemented using Uniswap’s Merkle Distributor.

The Wallet Address Distributor allows people who want to distribute tokens to a list of addresses. A Merkle Tree will then be generated and a contract will be created to claim the tokens associated with it.

For example, if you upload a list of addresses like this, a Merkle tree will be generated.

Address List
Merkle tree generated with above Address List

This result will be saved on IPFS.
=> https://gateway.pinata.cloud/ipfs/QmR6oHSLTeTMVdyYWmNZyYLUEYMe6HHQxhBLZajWdSK2MJ

Based on the information in the Merkle tree, the user can send a claim request to the contract.

URL Distributor uses UUIDs to generate unique URLs. So we can generate a Merkle tree using this list of UUIDs instead of addresses and claim it as well.

We are going to continue to implement the new token distribution methods. If you have any suggestions, please feel free to contact me on SNS or Github.


Toshiaki Takase Github, Twitter, Linkedin
Tsukasa Noguchi Github, Twitter, Linkedin


Website: https://app.iroiro.social/
Website Rinkeby: https://rinkeby.iroiro.social/
Polygon (Matic): https://matic.iroiro.social/
xDai: https://xdai.iroiro.social/
Twitter: https://twitter.com/IroiroTokens
Github: https://github.com/iroiro/iroiro
Discord: https://discord.gg/fhmPyp7U8c