Ethereum Poker Dapp

broken image


tutorials | blockchain

Take your Ethereum Dapp to Galaxy Devices Around the World

Looking for a fun way to pass time and potentially make some crypto, too? Try your luck by playing Jacks or Better video poker. Gambling is one of the areas of decentralized applications (dApps) to have seen the most development since Ethereum made the dApp concept possible. Thousands of such dApps have so far been created, ranging from familiar gambling concepts such as casinos and sports betting to some unique to the world of blockchain gambling.

Pokereum was the first Decentralized poker to be announced on the Ethereum Blockchain. As explained in the previous post, The project had begun development with a draft whitepaper dating back 2013 and was presented to some corporate outfits who are now building similar competing products.

Shuvo Saha

Engineer, Samsung Developer Program

Whether you are making a cryptocurrency exchange or a game on the Ethereum Blockchain, if you want to get more users for your Web Dapp, this article is for you.

More web traffic now comes from smartphones than PCs. So, if you want to get more users for your Dapp, you need to take your application to the 'Galaxies' (that is, Samsung Galaxy devices)! Thankfully, the Samsung Blockchain Platform (SBP) SDK has got you covered for all of your Blockchain needs.

This article explores how to connect to a hardware wallet using SBP SDK and how to leverage that connection to sign your cryptocurrency transaction. You will learn how to use Cucumber Webview provided by SBP SDK to display your Web Dapp and leverage SBP SDK features. You will also explore how to send the signed transaction to a Blockchain network and receive payment. Let's get started!

Initialize the Samsung Blockchain Platform SDK

Before using SBP SDK, make sure to include the required supporting libraries. To learn more about the required libraries and how to add them to the project, you can review the SBP SDK Getting Started guide.

To begin, initialize the SBP SDK for our application. Running the following code segment initializes the SBlockchain object. You need to use this object for all further communication with the SBP SDK.

Connect to a hardware wallet

Many Samsung Galaxy devices, such as the Galaxy Note20 and S20, already have a hardware wallet available: the Samsung Blockchain Keystore. You will connect to it in this demonstration. However, you can adapt the following code to connect to other supported hardware wallets, such as the Ledger Nano X, by simply changing the hardware wallet type.

Once successfully connected to the hardware wallet, you can retrieve the accounts associated with it.

Retrieve Ethereum accounts

Using the SBP's account manager, you can retrieve the list of accounts associated with a hardware wallet.

Ethereum Poker Dapper

In order to get a list of accounts using SBP SDK, you need to specify the wallet ID of the hardware wallet connected, the coin type (cryptocurrency) you want to use (as of writing this article, only Ethereum is supported), and the desired network type (such as MAINNET or ROPSTEN).

Ethereum poker dapper

If the account list is empty, the account manager can generate a new account based on the connected hardware wallet, the specified cryptocurrency, and the network.

After the account is retrieved, you can proceed to loading our Web Dapp using Cucumber WebView.

Initialize Cucumber WebView

The next step is to prepare the Cucumber WebView and enable it to make transactions through the Dapp.

To communicate with the blockchain network, use the CoinService interface of the SBP. The coin service enables us to retrieve the information needed for the transaction, such as nonce and gas prices. After all the information for the transaction has been retrieved, the coin service can help us upload the signed transaction to the blockchain network.

Browser-Based Web Dapps built using web3JS nowadays use Metamask as their web3 provider. When our Dapp is loaded on the dAppWebView, the SBP SDK works as the web3 provider and forwards the web3JS-prepared transaction to a BaseOnSendTransactionListener event handler, which handles the transaction created by our Web Dapp.

After preparing the transaction, a payment intent powered by the SBP SDK can be launched, which provides an interactive UI with the transaction details and a mechanism to select the preferred transaction speed.

Our Cucumber WebView (dAppWebView) is now ready to load our Web Dapp using its URL.

When the marketplace has loaded, the SBP prompts the user to allow the Dapp to connect to our hardware wallet.

The SBP's payment intent UI enables the user to easily purchase items from the marketplace.

Using the payment intent UI, the user can choose the transaction speed and send the transaction to their hardware wallet for signing. Once signing is done, the SBP SDK sends the transaction to the blockchain network for processing.

Bonus: display the transaction ID

In addition to enabling users to sign in and send a transaction with your Dapp, the SBP SDK can also retrieve the transaction ID.

The payment intent returns the transaction Information, which can be parsed using the onActivityResult method, if desired.

Ethereum Poker Dapple

Conclusion

With the SBP SDK, your Dapp is no longer confined to PCs. Both new and existing users can have your Dapp at their fingertips on Samsung Galaxy devices. It's also easy to add support for new cryptocurrencies and hardware wallets to your Dapp; the SBP has you covered. Submit your application to the Samsung Galaxy Store and reach millions of new users today!

Additional resources





broken image