@@ -44,6 +44,9 @@ class SendEther extends Component {
4444 this . checkWallet ( ) ;
4545 }
4646
47+ /**
48+ * @method to check wallet in localstorage
49+ */
4750 async checkWallet ( ) {
4851 try {
4952 const value = await AsyncStorage . getItem ( 'account' ) ;
@@ -59,6 +62,9 @@ class SendEther extends Component {
5962 }
6063 }
6164
65+ /**
66+ * @method to fetch balance of wallet
67+ */
6268 async getETHBalance ( ) {
6369 let balance = await web3 . eth . getBalance ( this . state . account . address ) ;
6470 balance = web3 . utils . fromWei ( balance , 'ether' ) ;
@@ -67,8 +73,12 @@ class SendEther extends Component {
6773 await this . setState ( { ETHBalance : Number ( balance ) . toFixed ( 3 ) } ) ;
6874 }
6975
76+ /**
77+ * @method to transfer Ether
78+ */
7079 async transferEther ( ) {
7180 await this . setState ( { dialogVisible : false } )
81+ // ETH address validation
7282 if ( this . state . receiver === undefined || this . state . receiver . length !== 42 || web3 . utils . isAddress ( this . state . receiver ) === false ) {
7383 Alert . alert (
7484 'Wrong Ethereum Address!' ,
@@ -100,6 +110,7 @@ class SendEther extends Component {
100110 } ;
101111
102112 let tx = new EthereumTx ( rawTransaction ) ;
113+ // sign transaction with private key
103114 tx . sign ( privateKey ) ;
104115 let serializedTx = tx . serialize ( ) ;
105116
@@ -111,6 +122,7 @@ class SendEther extends Component {
111122 ]
112123 ) ;
113124
125+ // Send signed transaction to Ethereum blockchain
114126 web3 . eth . sendSignedTransaction ( '0x' + serializedTx . toString ( 'hex' ) ) . then ( result => {
115127 console . log ( result ) ;
116128
@@ -122,7 +134,6 @@ class SendEther extends Component {
122134 ]
123135 ) ;
124136 } ) . catch ( error => {
125- console . log ( typeof error ) ;
126137 console . log ( error ) ;
127138 this . setState ( { error, receiver : undefined } ) ;
128139
0 commit comments