@@ -32,7 +32,7 @@ Web3Auth architecture and implementation. For those who want to skip straight to
3232find it on
3333[ GitHub] ( https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/android/android-playground ) .
3434
35- Here are few screenshots of the application.
35+ Here are a few screenshots of the application.
3636
3737<img
3838 style = { { display: " block" , margin: " 20px auto" }}
@@ -53,7 +53,7 @@ Web3Auth Dashboard.
5353Once, you have set up the Web3Auth Dashboard, and created a new project, it's time to integrate
5454Web3Auth in your Android application. For the implementation, we'll use the
5555[ "web3auth-android-sdk"] ( https://github.com/Web3Auth/web3auth-android-sdk ) SDK. This SDK facilitates
56- integration with Web3Auth. This way you can easily manage embedded wallet in your Android
56+ integration with Web3Auth. This way you can easily manage an embedded wallet in your Android
5757application.
5858
5959### Installation
@@ -141,8 +141,8 @@ class Web3AuthHelperImpl(
141141}
142142```
143143
144- Once we have the created ` Web3AuthHelper ` , next is to initialize the ` Web3Auth ` instance in the Koin
145- module and make it a singleton component.
144+ Once we have the created ` Web3AuthHelper ` , the next is to initialize the ` Web3Auth ` instance in the
145+ Koin module and make it a singleton component.
146146
147147``` kotlin
148148val appModule = module {
@@ -177,13 +177,13 @@ private fun getWeb3AuthHelper(context: Context): Web3AuthHelper {
177177
178178To check whether the user is authenticated, you can use the ` getPrivateKey ` or ` getEd25519PrivKey `
179179method. For a user already authenticated, the result would be a non-empty ` String ` . You can navigate
180- to different views based on the result. If the user is already authenticated, we'll generate prepare
181- the ` Credentials ` , important to interact with blockchain. Along with that, we'll retrieve user info,
182- and navigate them to ` HomeScreen ` . In case of no active session, we'll navigate to ` LoginScreen ` to
183- authenticate again.
180+ to different views based on the result. If the user is already authenticated, we'll generate and
181+ prepare the ` Credentials ` , important to interact with the blockchain. Along with that, we'll
182+ retrieve user info, and navigate them to ` HomeScreen ` . In case of no active session, we'll navigate
183+ to ` LoginScreen ` to authenticate again.
184184[ Learn more about Web3Auth session management] ( /docs/features/session-management ) .
185185
186- Since, we are using the MVVM architecture, we'll create a ` ViewModel ` class to encapsulate the
186+ Since we are using the MVVM architecture, we'll create a ` ViewModel ` class to encapsulate the
187187business logic for Web3Auth and Ethereum chain interaction.
188188
189189``` kotlin
@@ -246,11 +246,11 @@ class MainViewModel(private val web3AuthHelper: Web3AuthHelper) : ViewModel() {
246246
247247### Authentication
248248
249- If the user is not authenticated, we can utilize the ` login ` method to authenticate user. For the
250- Wallet, we will addEmail Passwordless login. We'll create a helper function, ` login ` inside
249+ If the user is not authenticated, we can utilize the ` login ` method to authenticate the user. For
250+ the Wallet, we will add an Email Passwordless login. We'll create a helper function, ` login ` inside
251251` MainViewModel ` . The login method is pretty straightforward in Web3Auth and takes ` LoginParams ` as
252- input. After successfully logging in, we'll generate prepare the ` Credentials ` , important to
253- interact with blockchain. Along with that, we'll retrieve user info, and navigate them to
252+ input. After successfully logging in, we'll generate and prepare the ` Credentials ` , important to
253+ interact with the blockchain. Along with that, we'll retrieve user info, and navigate them to
254254` HomeScreen ` .
255255
256256Learn more about [ Web3Auth LoginParams] ( /docs/sdk/pnp/android/usage#arguments ) .
@@ -288,17 +288,19 @@ class MainViewModel(private val web3AuthHelper: Web3AuthHelper) : ViewModel() {
288288## Set up Blockchain Providers
289289
290290Once we have successfully authenticated the user, the next step would be to fetch the user details,
291- retrieve wallet address and prepare blockchain providers for interactions. For this guide, we are
292- supporting only Ethereum ecosystem, but the general idea can be used for any blockchain ecosystem.
291+ retrieve the wallet address, and prepare blockchain providers for interactions. For this guide, we
292+ are supporting only the Ethereum ecosystem, but the general idea can be used for any blockchain
293+ ecosystem.
293294
294- Given that the project follows MVVM architecture pattern, we'll want to create an UseCase to
295- interact with the Blockchain. This UseCase will help us easily expand the blockchain support while
296- isolate it from the rest of the application.
295+ Given that the project follows MVVM architecture pattern, we'll want to create a UseCase to interact
296+ with the Blockchain. This UseCase will help us easily expand the blockchain support while isolating
297+ it from the rest of the application.
297298
298- For interacting ethereum chains, we'll use the [ web3j] ( https://github.com/hyperledger/web3j ) SDK.
299+ For interacting with Ethereum chains, we'll use the [ web3j] ( https://github.com/hyperledger/web3j )
300+ SDK.
299301
300302To install the web3j SDK, in your module-level ` build.gradle ` or ` settings.gradle ` file, add ` web3j `
301- in your app level dependencies.
303+ in your app- level dependencies.
302304
303305``` groovy
304306dependencies {
@@ -313,8 +315,8 @@ a new class, `EthereumUseCase` interface, which will used as a base class for `E
313315If you wish to support any additional ecosystem, you can create the chain-agnostic UseCase and
314316implement the methods.
315317
316- If you want to learn, how you can integrate different blockchain with Web3Auth, you can checkout our
317- [ Connect Blockchain resources] ( /docs/connect-blockchain/ ) .
318+ If you want to learn, how you can integrate different blockchains with Web3Auth, you can check out
319+ our [ Connect Blockchain resources] ( /docs/connect-blockchain/ ) .
318320
319321``` kotlin
320322interface EthereumUseCase {
@@ -329,8 +331,8 @@ interface EthereumUseCase {
329331
330332Generally, for any blockchain provider, you'll only require the ` getBalance ` , ` sendTransaction ` , and
331333` signMessage ` . The ` getBalance ` and ` approve ` can be used to interact with smart contracts. To
332- interact with smart contracts, we'll require to generate smart contract function wrappers in Java
333- from Solidity ABI files.
334+ interact with smart contracts, we'll be required to generate smart contract function wrappers in
335+ Java from Solidity ABI files.
334336
335337### Smart Contract Wrappers
336338
@@ -369,9 +371,9 @@ interface IERC20 {
369371}
370372```
371373
372- After creating the interface for the ERC-20 token, the next step is to compile the solidity file,
373- and generate the abi and bin files to generate the wrappers. To compile the solidity file, we'll use
374- the [ solc] ( https://docs.soliditylang.org/en/latest/installing-solidity.html ) .
374+ After creating the interface for the ERC-20 token, the next step is to compile the solidity file and
375+ generate the abi and bin files to generate the wrappers. To compile the solidity file, we'll use the
376+ [ solc] ( https://docs.soliditylang.org/en/latest/installing-solidity.html ) .
375377
376378To install the solc we'll require the npm or yarn. If you have the npm already installed, you can
377379use the below command to install the solc package globally.
@@ -395,19 +397,19 @@ web3j generate solidity -b /path/to/Tokne.bin -a /path/to/Token..abi -o /path/to
395397```
396398
397399Once you run the command, it'll create a wrapper ` Token.java ` which extends the ` Contract ` . You can
398- use this class to interact with the smart contracts. Please make sure to compile and regrenerate
399- wrappers if you make any changes in the smart conract .
400+ use this class to interact with the smart contracts. Please make sure to compile and regenerate
401+ wrappers if you make any changes in the smart contract .
400402
401403### Ethereum UseCase Implementation
402404
403405Once we have generated ` Token ` wrapper, we'll create ` EthereumUseCaseImpl ` and implement the
404406methods. To create the ` Web3j ` instance, you'll require the rpcTarget URL. If you are using public
405407RPCs, you can face some network congestion. It's ideal to use paid RPCs for production.
406408
407- The ` getBalance ` , and ` approve ` methods are used to interact with smart contracts on Ethereum
408- ecosystem. The ` getBalance ` is used to read the balance from the ERC-20 smart contracts, where as
409- the ` approve ` is used to change the approval to zero for the ERC-20. For the ` getBalance ` and
410- ` approve ` we'll be using the ` Token ` wrapper.
409+ The ` getBalance ` , and ` approve ` methods are used to interact with smart contracts in the Ethereum
410+ ecosystem. The ` getBalance ` is used to read the balance from the ERC-20 smart contracts, whereas the
411+ ` approve ` is used to change the approval to zero for the ERC-20. For the ` getBalance ` and ` approve `
412+ we'll be using the ` Token ` wrapper.
411413
412414``` kotlin
413415class EthereumUseCaseImpl (
@@ -505,14 +507,14 @@ val appModule = module {
505507
506508## Set up Supported Chains
507509
508- After having our blockchain UseCase in place, the next step on the list to define the supported
509- chains. To keep things simple, we' ll simply a create a new file `ChainConfigList` with array of
510+ After having our blockchain UseCase in place, the next step on the list is to define the supported
511+ chains. To keep things simple, we' ll simply create a new file `ChainConfigList` with an array of
510512ChainConfig to define the supported chains.
511513
512514For the guide, we have added the support for Ethereum Sepolia, and Arbitrum Sepolia. If you wish to
513515support more chains in your wallet, you can simply add the config with the required details in the
514- list below. Along with that you can also add the desired chain using the add custom chain feature in
515- the app.
516+ list below. Along with that, you can also add the desired chain using the add custom chain feature
517+ in the app.
516518
517519```kotlin
518520var chainConfigList = arrayOf(
@@ -542,16 +544,16 @@ var chainConfigList = arrayOf(
542544## Wallet Implementation
543545
544546Once, we have set up the EthereumUseCase, and supported chains, it' s time to integrate and plug them
545- into the wallet. Since , we have already created `MainViewModel ` before, we' ll add the other features
547+ into the wallet. Since we have already created `MainViewModel ` before, we' ll add the other features
546548inside it.
547549
548- This will help us to seperate business logic from UI.
550+ This will help us to separate business logic from UI.
549551
550552### Set up MainViewModel
551553
552- Once we have set up supported chains, the next on list is to add more functionality in
553- `MinaViewModel` to help us maange the state & functionality of the wallet. It will help us manage
554- the state of currently selected chain, fetch balance, sign transactions, and access other
554+ Once we have set up supported chains, the next on the list is to add more functionality in
555+ `MinaViewModel` to help us manage the state & functionality of the wallet. It will help us manage
556+ the state of the currently selected chain, fetch balance, sign transactions, and access other
555557functionalities of Web3Auth.
556558
557559```kotlin
@@ -721,10 +723,10 @@ Once, we have our view model ready, we create a new `HomeScreen` to show user de
721723address, wallet address, user's balance for selectedChain, and blockchain interaction methods.
722724
723725To get the user's balance, we'll use ` getBalance ` method from the ` MainViewModel ` . The method
724- internally uses ` EthereumUseCaseImpl ` to retrieve user's wallet address, and fetch the wallet
725- balance for the address. Checkout ` EthereumUseCaseImpl ` implementation for more details.
726+ internally uses ` EthereumUseCaseImpl ` to retrieve the user's wallet address and fetch the wallet
727+ balance for the address. Check out ` EthereumUseCaseImpl ` implementation for more details.
726728
727- For the bottom navigation, we have created ` TabBarView ` , please checkout TabBarView.kt file for more
729+ For the bottom navigation, we have created ` TabBarView ` , please check TabBarView.kt file for more
728730details on UI implementation.
729731
730732``` kotlin
@@ -934,10 +936,10 @@ fun AccountView(viewModel: MainViewModel) {
934936
935937### Chain Interactions
936938
937- Once we have setup ` HomeScreen ` and ` AccountView ` , the next step is to setup chain interactions for
938- signing message , signing transaction , reading from contracts, and writing on contracts. For signing
939- message and transaction, we'll create a new ` TransactionScreen ` widget and utilize ` signMessage ` and
940- ` sendTransaction ` from ` MainViewModel ` for respective functionality.
939+ Once we have set up ` HomeScreen ` and ` AccountView ` , the next step is to set up chain interactions
940+ for signing messages , signing transactions , reading from contracts, and writing on contracts. For
941+ signing messages and transaction, we'll create a new ` TransactionScreen ` widget and utilize
942+ ` signMessage ` and ` sendTransaction ` from ` MainViewModel ` for the respective functionality.
941943
942944``` kotlin
943945@OptIn(ExperimentalPagerApi ::class )
@@ -1053,7 +1055,7 @@ fun TransactionView(viewModel: MainViewModel) {
10531055}
10541056```
10551057
1056- Once we have set up ` TransactionScreen ` , next is to create ` SmartContractsScreen ` for fetching
1058+ Once we have set up ` TransactionScreen ` , the next is to create ` SmartContractsScreen ` for fetching
10571059ERC-20 token balance, and revoking approval. We'll utilize the ` getTokenBalance ` and
10581060` revokeApproval ` methods from ` MainViewModel ` for the above functionality.
10591061
0 commit comments