Developing a Faucet for WorldCoin: Backend Work

By Daniel Goldman | The B.C.U. Times | 1 Aug 2019


Since I created WorldCoin, I wanted a way to get it distributed to the general population. Tipping is going to be used to an extent, but I want people to start interacting with the token as much as possible from the very beginning. I thought a faucet "game" might be the best option, as it will draw people to the site and keep them interested in the project. So far I've almost completed the back end for the faucet. The front end is going to need a lot more work.

Developing the smart contract in Solidity wasn't too difficult. The language is similar to a number of programming languages I've used in the past. The most difficult part was deciding exactly what I wanted my faucet to do. 

Drip Rate

Initially, I set a constant drip rate, which is a little problematic, because people like to get a random amount because it makes them feel like they might get more, even though if they play enough, they'll end up with the same average amount over the long run, or at least they'll tend towards it. The drip rate was set to 2 WRLD. I decided to allow a person to grab a drop every five minutes. If the person was referred by another user, that user would also get 1 WRLD.

But during the process of writing this article, I decided to change things. Now the minimum amount that a user will get is 2 WRLD. The maximum they can get is a lot more. It's now equal how many seconds have passed since the last time someone received a drop. That means on slow days, people can get more, which means they'll become more active. This process should balance out activity. Referrers will get half the amount that the user receives, and the drop size will be visible on the website when done.

Interest

I didn't want it to just drip WRLD continuously without anything interesting. So, the first thing I wanted to do was create a system for accruing interest. Essentially, I wanted users to be able to stake their WRLD and get more as a reward for staking it. It's not proof of stake because new tokens aren't being created, but instead they're being paid out of the funds held by the contract. I set the base interest rate at 5%. But I wanted people to be able to do more to get a higher interest rate. The one weird thing is that contracts aren't applications that continue to run. Code is only run when a user is interacting with the contract, so it's difficult to automate tasks. So I had to hook interest into the drip routine. Basically, interest is only given when someone uses the faucet. But that also means that the more often a person uses the faucet, the more the interest is compounded.

Boosting

5% isn't all that much, especially with some economic games (ponzi games really) giving 100% in interest per month. So I wanted to give a way for users to boost their interest rates. They can pay the contract a certain number of TRX, and boost their interest rate. The interest rate goes up as the amount given to boost approaches the total boosted funds. More specifically, the potential boost starts at 100 percentage points, and is reduced by how many times greater the boost total is than the given contribution. So if the boost total is 1,000 TRX and someone contributed 500 of that, you have 100 percentage points, 1 percentage point or 99%. If they had instead only contributed 250 TRX, then they would only receive a 98% boost, as 1000 is two times greater than 250. If the percentage boost would be below 0% then no boost is given.

This arrangement creates a competition. As more people join the platform and send TRX to boost their interest rates, users will have to contribute more and more to get a boost. In a way, this system is a fancy ICO. The issuing wallet that I hold will get the TRX, but not in return for the actual tokens, but instead in return for boost in interest on the tokens that are currently staked.

Prize Fund

The final idea was a prize fund, which exists in some other Tron based economic games. The main issue with the last one I saw, which was from Tron Builder, is that the prize fund is depleted completely when the prize is won, so there's no real incentive to try to get it. I decided to use a rather odd method for deciding when a prize is given. It's given to whoever grabs it, when it's available. So when is it available? 

At first I thought about using a timer like in other games, where the person has to be the last user to get a drop, within a given amount of time, but that's not really going to work in this game. So instead, I went with this weird system.

351665157-39bc8dd4e19efa40861302b9d87e984c346e051e578b6049651de6a9935bab24.png

Basically it's a "you're the nth customer today" kind of deal, at least at its core. If a person is the 1,000th person to get a drop since the last time the fund was given out, they can get the prize. Well, sort of. It's a little too easy and boring to always try to be the 1,000th person, so instead I reduce that value by twice the number of seconds since the last drip. So if there's a slowdown in the number of people using the faucet, someone can get te prize pool more quickly. 

The Prize

So how much is the prize? Originally each time someone used the faucet, I was going to have it so that 9 WRLD would be added to the fund, and 1 to the reserve. Now the prize pool will be increased by 2/3 of however large the drop size is, and the reserve will increase by 1/3 of the drop size. Also, when a person boosts their interest with TRX, 8 WLRD are entered into the prize pool and 2 into the reserve, for every TRX paid. Clearly the size of the fund can vary a lot depending on a lot of factors. 

Final Thoughts

Overall, developing the back end contract wasn't all that difficult. I think the hard part will be figuring out how to use TronLink and Tronweb to integrate the contract into a website. I'm also not confident in actually pushing the contract to the blockchain. I really check it on the Tron testnet, but I honestly can't see any glitch in the code. I've looked it over numerous times, and will likely have someone else look it over, and maybe test it, before running it. So far I think the hardest part has just been designing features.


You can find the contract source code, or at least the current draft of it, at my github repository.

How do you rate this article?


0

0

Daniel Goldman
Daniel Goldman

I’m a polymath and a rōnin scholar. That is to say that I enjoy studying many different topics. Find more at http://danielgoldman.us


The B.C.U. Times
The B.C.U. Times

The B.C.U. Times - blog about promoting the blockchain and cryptoasset user experience and ecosystem.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.