Getting Started with aelf by Playing BingoGame

Getting Started with aelf by Playing BingoGame

By aelf_blockchain | aelf Blockchain | 27 Jul 2020


Welcome to aelf blockchain developing journey! This is the first of a series of articles for technical support of the aelf blockchain project. These articles can help you get started quickly and build your first dapp (or decentralized application or d-application ) on the aelf blockchain.

To help you have a rough idea of how dApps on the aelf blockchain work, instead of diving headlong into the coding or more complicated stuff about the aelf blockchain, we will start with a demo dApp the aelf team has specially developed.

Bingo Game is a betting dApp with pretty simple rules: you place a bet (you can place a “big” or “small” bet with a specified amount), and the dApp will tell you whether you have won or lost. If you have already installed Bingo Game, then let’s get started!

Welcome to aelf blockchain developing journey! This is the first of a series of articles for technical support of the aelf blockchain project. These articles can help you get started quickly and build your first dapp (or decentralized application or d-application ) on the aelf blockchain.

To help you have a rough idea of how dApps on the aelf blockchain work, instead of diving headlong into the coding or more complicated stuff about the aelf blockchain, we will start with a demo dApp the aelf team has specially developed.

Bingo Game is a betting dApp with pretty simple rules: you place a bet (you can place a “big” or “small” bet with a specified amount), and the dApp will tell you whether you have won or lost. If you have already installed Bingo Game, then let’s get started!

Image for post

When you first open this dapp, you will see three sections on the home page. On the top, there is the Prize Pool, where all the money players have lost is deposited. Now move down to Bet Type, here you can select either Big or Small. Move further down and we’ll see Bet Amount, where you can type in any amount of money to place a bet. In the Demo, the money is called AEUSD, a type of stable test token issued by the aelf blockchain. Finally, tap the Bet button below and your bet is made. It’s that simple!

But before all that, you need to create a new account first. Tap MY at the bottom right and the app will guide you to log in or register. Tap Register, enter a username and a valid password, then tap Register.

Image for post

Now, here comes the MOST important step: you MUST back up your account QR code, because it is the ONLY way to log into your account, otherwise you will lose your account and money FOREVER. So, make sure you save the QR-code on your phone: click ‘save to album’ and then tap Done on the top right.

Another important thing is setting a transaction password, just like all the other crypto wallets.

Once you have completed registration, you will be directed to the main page. If you can see “Please bet” below the Prize Pool, it means you have logged in.

Image for post

Before you place a bet, check your balance first, you can find it in the Bet Amount. For example, I have 48 AEUSD now. So I select Small, type in 2 AEUSD for the bet, and then click Bet. When you see the “Bet success” popup, switch to the “My bet” page and tap “WAITING FOR DRAW”. If you are quick enough, you’ll see the information about the bet you’ve just made. Now you have to wait for a while to see whether you have won or lost. If the information suddenly disappears, it means the bet has a result, which we call Bingo.

Image for post

Now switch to the ‘Lottery’ page. For me, this time I won 2 AEUSD. Some of the other information is also displayed here, including the Tx ID. You can also see the results of the previous bets I’ve made. Now switch back to the main page by tapping index on the bottom left, and you can see you now have 50 AEUSD, which means if you win a bet, you can get back your staked amount (2 AEUSD in this case) and win the same amount of AEUSD (another 2 AEUSD). But if you lose, you will not get your stake back, and your balance will be 46 AEUSD. By the way, you may notice that My last bet in Prize Pool says I betted 2 AEUSD and selected small.

Image for post  

So what’s the logic of this game? In fact, this dApp can generate a random number between 0 and 255. If this number is between 0 and 126, it means “small”; if between 129 and 255, then it’s “big”, if it’s 127 or 128, it’s “medium”. If your bet type is the same as that of the random number, you win; if not, you lose. And if the random number is 127 or 128, you also lose.

Now that we are clear about the logic of the game, let’s place multiple bets in quick succession. First, I bet 2.5 AEUSD, then right after it says ‘Bet Success’, I place another 4.5 AEUSD, then another 5.5 AEUSD. Let’s see what happens now. Switch to My Bet and you’ll see these 3 bets forming a queue in WAITING FOR DRAW. After a while, they will disappear one by one. Now you can check the new betting results in Lottery: won 2.5 AEUSD, lost 4.5 AEUSD and 5.5 AEUSD. Bad luck then!

 

After playing this Demo, you may have two questions:

1: Why do I have to wait for a while for betting results, instead of getting them instantly?

This is because the dApp is based on blockchain. When you bet a certain amount, you are actually sending a transaction to the blockchain, or to a smart contract on the blockchain. Your transaction has to be processed by the smart contract and verified by other blockchain nodes, which takes some time, before sending you the betting results. Of course, it’s much more complex than that.

2: Why do we choose a Bingo Game app as a Demo?

This is because Bingo Game is a dApp based on the ‘real random number’ generation technique, which was developed by the aelf team from scratch. The real random number is completely different from the pseudo-random number, which is commonly seen in most programming languages. Real random numbers correspond to the natural random phenomena, and are therefore unpredictable and undesignable. As a result, real random numbers have a great potential in the areas where TRUST is needed, for example, voting, lottery, charity, etc.

Image for postImage for post

Finally, let’s log out the account and see how to log into your account again. Tap ‘My’ at the bottom right and you’ll see your username and balance on the top, tap logout. there will be a popup telling you to back up anything related to your account. If you have already done so, then just log out. After logout, you’ll be redirected to the main page, go to the My page again, tap login, and you will find you need to scan a QR code. If you have the QR code printed out, then just scan it. Or you can tap album at the top right and select the account QR-code in your Photos. Then enter the login password, tap confirm, wait for a few seconds, then enter the transaction password, tap confirm, and you are good to go!

All right, this is all from us for now. In the next article, I will briefly introduce the aelf blockchain projects to help you lay a solid foundation for building decentralized applications later on.

If you are interested in developing dApps on the aelf blockchain, please contact @Itsu_Ace on Telegram.

 


aelf_blockchain
aelf_blockchain

Decentralized Cloud Computing Blockchain Network


aelf Blockchain
aelf Blockchain

aelf's official blog on Publish0x - Follow for announcements, partnerships, project updates and more!

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.