{"id":13820532,"url":"https://github.com/heroims/react-native-web3-wallet","last_synced_at":"2025-12-27T20:38:51.899Z","repository":{"id":40389556,"uuid":"501970312","full_name":"heroims/react-native-web3-wallet","owner":"heroims","description":"Web3 Wallet in React Native (use ethers.js)","archived":false,"fork":false,"pushed_at":"2024-04-23T05:20:10.000Z","size":223,"stargazers_count":48,"open_issues_count":1,"forks_count":13,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-09T22:03:41.033Z","etag":null,"topics":["blockchain","crypto","ethers","wallet","web3"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heroims.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-10T08:53:36.000Z","updated_at":"2024-11-05T04:12:03.000Z","dependencies_parsed_at":"2023-12-27T09:28:52.422Z","dependency_job_id":"17a20175-773c-4435-84ef-7e7e5192c805","html_url":"https://github.com/heroims/react-native-web3-wallet","commit_stats":{"total_commits":76,"total_committers":2,"mean_commits":38.0,"dds":"0.052631578947368474","last_synced_commit":"93304c0092663de16b6b0bce5b0178f16beaff7c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroims%2Freact-native-web3-wallet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroims%2Freact-native-web3-wallet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroims%2Freact-native-web3-wallet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heroims%2Freact-native-web3-wallet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heroims","download_url":"https://codeload.github.com/heroims/react-native-web3-wallet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225423637,"owners_count":17472152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","crypto","ethers","wallet","web3"],"created_at":"2024-08-04T08:01:04.924Z","updated_at":"2025-12-27T20:38:51.824Z","avatar_url":"https://github.com/heroims.png","language":"JavaScript","funding_links":[],"categories":["TypeScript"],"sub_categories":["Flutter SDK / Libraries"],"readme":"# React Native Web3 Wallet\nWeb3 Wallet in React Native (use ethers.js)\n## Welcome\n\nThis is a safe web3 wallet tools, to help with develop wallet applications quickly. \n\nThis wallet module does not expose the private key, and only advocates storing the keystore or the mnemonic with the password authentication locally, and does not activate the wallet except for write operations. \n\n- [main branch](https://github.com/heroims/react-native-web3-wallet/tree/main) support ethers5.x\n- [ether6.x branch]( https://github.com/heroims/react-native-web3-wallet/tree/ether6.x) support ethers6.x \n- [bitcoin branch](https://github.com/heroims/react-native-web3-wallet/tree/bitcoin) support bitcoinjs\n\n## Installation\n\n```bash\nnpm install github:heroims/react-native-web3-wallet --save\nnpm install @ethersproject/shims --save\nnpm install react-native-get-random-values --save\nnpx pod-install\n```\n\n### fix React Native so slow\n```bash\nnpm install react-native-scrypt@1.2.1\nnpm install react-native-aes-crypto@3.0.1\n```\nmove `patches` finder to your root directory, and execute command `npx patch-package`\n\n\n## Usage\n\n### Import\n\n```javascript\nimport {\n  contractTransaction,\n  createWallet,\n  exportKeystore,\n  exportMnemonicFromKeystore,\n  exportPrivateKeyFromKeystore,\n  exportMnemonic,\n  exportKeystoreFromMnemonic,\n  exportPrivateKeyFromMnemonic,\n  importKeystore,\n  importMnemonic,\n  importPrivateKey,\n  getBalance,\n  getContractBalance,\n  getContractGasLimit,\n  getContractNfts,\n  getGasLimit,\n  getGasPrice,\n  getNonce,\n  sendTransaction,\n  signTransaction,\n  signMessage,\n  signTypedData,\n  waitForContractTransaction,\n  waitForTransaction,\n  getContract,\n  getSignerContract,\n  getWalletSigner,\n  getWalletSignerWithMnemonic,\n  getWalletSignerWithPrivateKey,\n  getSignerContractWithWalletProvider,\n  bigNumberFormatUnits,\n  bigNumberParseUnits,\n} from 'react-native-web3-wallet';\n```\n\n\n### Wallet\n\n#### Create Wallet\n\n```javascript\n//0 BTC    60 ETH\ncreateWallet('password', \"m/44'/60'/0'/0/0\")\n  .then(res =\u003e {\n    console.log(res);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\nPrint Results\n```\n{\n  \"keystore\": ..., \n  \"mnemonic\": ...,\n  \"shuffleMnemonic\": ...,\n  \"privateKey\" : ...,//option\n  \"publicKey\" : ...,//option  \n}\n```\nThe mnemonic and private keys are not recommended to be stored locally and are only used to verify that the user has made a record.\n\n#### Export keystore\nThe json object of the keystore is stored locally by default.\n```javascript\nexportKeystore(JSON.stringify(keystore), 'password')\n  .then(res =\u003e {\n    console.log(res);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n\nexportKeystoreFromMnemonic('password','mnemonic string','address',\"m/44'/60'/0'/0/0\",'mnemonicPassword')\n  .then(res =\u003e {\n    console.log(res);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\nPrint Keystore json object\n#### Export privateKey\n```javascript\nexportPrivateKeyFromKeystore(JSON.stringify(keystore), 'password')\n  .then(res =\u003e {\n    console.log('privateKey export', res);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n\nexportPrivateKeyFromMnemonic(\n  mnemonicString,\n  \"m/44'/60'/0'/0/0\",\n)\n  .then(res =\u003e {\n    console.log('privateKey export', res);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\nPrint privateKey \n#### Export Mnemonic\n```javascript\nexportMnemonicFromKeystore(JSON.stringify(keystore), 'password')\n  .then(res =\u003e {\n    console.log('mnemonic export', res);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n\nexportMnemonic('mnemonic', 'address', \"m/44'/60'/0'/0/0\", 'password')\n  .then(res =\u003e {\n    console.log('mnemonic export', res);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\nPrint mnemonic\n``` \n{\n  mnemonic : mnemonicArr, \n  shuffleMnemonic : shuffleMnemonicArr,     \n}\n```\n#### Import Wallet\n```javascript\nimportKeystore(JSON.stringify(keystore), 'password')\n  .then(res =\u003e {\n    console.log(res);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n\nimportMnemonic(\n  mnemonicString,\n  'password',\n)\n  .then(res =\u003e {\n    console.log(res);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n\nimportPrivateKey(\n  '0x00000000000000000000000000000000000',\n  'password',\n)\n  .then(res =\u003e {\n    console.log(res);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\nPrint Results\n```\n{\n  \"keystore\": ..., \n  \"privateKey\" : ...,//option\n  \"publicKey\" : ...,//option \n}\n```\n#### Singer\n```javascript\ngetWalletSigner(\n  rpcURL,\n  'keystore',\n  'password',\n)\n  .then(walletSigner =\u003e {\n    console.log('walletSigner', walletSigner);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n\ngetWalletSignerWithMnemonic(\n  rpcURL,\n  'mnemonic',\n  'address',\n  \"m/44'/60'/0'/0/0\",\n  'password',\n)\n  .then(walletSigner =\u003e {\n    console.log('walletSigner', walletSigner);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n\ngetWalletSignerWithPrivateKey(\n  rpcURL,\n  'privateKey',\n)\n  .then(walletSigner =\u003e {\n    console.log('walletSigner', walletSigner);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n\ngetSignerContractWithWalletProvider(\n  contractAddress,\n  contractAbi,\n  walletSigner,\n)\n  .then(contractSigner =\u003e {\n    console.log('contractSigner', contractSigner);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\n\n#### Sign Message\n```javascript\nsignMessage(\n  JSON.stringify(keystore),\n  'password',\n  message,\n)\n  .then(signedMs =\u003e {\n    console.log('signedMs', signedMs);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n\n```\n#### Sign TypedData\n```javascript\n// All properties on a domain are optional\nconst domain = {\n    name: 'Ether Mail',\n    version: '1',\n    chainId: 1,\n    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'\n};\n\n// The named list of all type definitions\nconst types = {\n    Person: [\n        { name: 'name', type: 'string' },\n        { name: 'wallet', type: 'address' }\n    ],\n    Mail: [\n        { name: 'from', type: 'Person' },\n        { name: 'to', type: 'Person' },\n        { name: 'contents', type: 'string' }\n    ]\n};\n\n// The data to sign\nconst value = {\n    from: {\n        name: 'Cow',\n        wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826'\n    },\n    to: {\n        name: 'Bob',\n        wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB'\n    },\n    contents: 'Hello, Bob!'\n};\nsignTypedData(\n  JSON.stringify(keystore),\n  'password',\n  domain,\n  types,\n  value,\n)\n  .then(signedTx =\u003e {\n    console.log('signedTx', signedTx);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\n#### Sign Transaction\n```javascript\nsignTransaction(\n  JSON.stringify(keystore),\n  'password',\n  nonce,\n  gasLimit,\n  gasPrice,\n  toAddress,\n  chainId,\n  amount,\n  data,\n)\n  .then(signedTx =\u003e {\n    console.log('signedTx', signedTx);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\n### Provider\n#### Get Balance\n```javascript\ngetBalance(\n  'https://bsc-dataseed1.binance.org/',\n  '0x00000000000000000000000000',\n)\n  .then(res =\u003e {\n    console.log(bigNumberFormatUnits(res, 18));\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\nPrint BigNumberish\n#### Transcation\n```javascript\nlet data = '0x' +\n  Buffer.from('hello world').toString(\n    'hex',\n  );\nlet amount = '0.02';\nlet rpcURL = 'https://ropsten.infura.io/v3/';\nlet chainId = 3\n\ngetGasPrice(rpcURL)\n  .then(gasPrice =\u003e {\n    console.log('gasPrice', gasPrice.toString());\n    getGasLimit(\n      rpcURL,\n      fromAddress,\n      toAddress,\n      amount,\n      data,\n    )\n      .then(gasLimit =\u003e {\n        console.log('gasLimit', gasLimit.toString());\n        console.log('gas', bigNumberFormatUnits(gasPrice.mul(gasLimit)));\n\n        getNonce(\n          rpcURL,\n          fromAddress,\n        )\n          .then(nonce =\u003e {\n            console.log('nonce', nonce);\n            signTransaction(\n              JSON.stringify(keystore),\n              'password',\n              nonce,\n              gasLimit,\n              gasPrice,\n              toAddress,\n              chainId,\n              amount,\n              data,\n            )\n              .then(signedTx =\u003e {\n                console.log('signedTx', signedTx);\n                sendTransaction(rpcURL, signedTx)\n                  .then(resTx =\u003e {\n                    console.log(resTx);\n                    waitForTransaction(\n                      rpcURL,\n                      resTx.hash,\n                    )\n                      .then(res =\u003e {\n                        console.log(res);\n                      })\n                      .catch(err =\u003e {\n                        console.log(err);\n                      });\n                  })\n                  .catch(err =\u003e {\n                    console.log(err);\n                  });\n              })\n              .catch(err =\u003e {\n                console.log(err);\n              });\n          })\n          .catch(err =\u003e {\n            console.log(err);\n          });\n      })\n      .catch(err =\u003e {\n        console.log(err);\n      });\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\n| Method| return| \n|--|--|\n|getGasPrice| BigNumberish|\n|getGasLimit|BigNumberish|\n|getNonce| number|\n|signTransaction| String|\nsendTransaction Print \n```\n{\"chainId\": 999, \"confirmations\": 0, \"data\": \"0x\", \"from\": \"0x000000000000000000000\", \"gasLimit\": {\"hex\": \"0x5208\", \"type\": \"BigNumber\"}, \"gasPrice\": {\"hex\": \"0x0430e23400\", \"type\": \"BigNumber\"}, \"hash\": \"0x181ab94b9fe7b032d2fc9f47ce794fd26dfd39f1cdd28cce03ee353f79dd396d\", \"nonce\": 6, \"r\": \"0xc42d9808612967fb25c136f8c4ea352e334124f09eda02a6d81e3154c8411599\", \"s\": \"0x436749faf39974940687e53223a776d339f61e48e4b782124964e75e4d843d22\", \"to\": \"0x0000000000000000000000000\", \"type\": null, \"v\": 40360896, \"value\": {\"hex\": \"0x470de4df820000\", \"type\": \"BigNumber\"}, \"wait\": [Function anonymous]}\n```\nwaitForTransaction Print \n```\n{\"blockHash\": \"0x35b818367ce9a14917cf9e2423b0d71c8343e78e0210388918b607f7170e3274\", \"blockNumber\": 9243147, \"byzantium\": true, \"confirmations\": 1, \"contractAddress\": null, \"cumulativeGasUsed\": {\"hex\": \"0x5208\", \"type\": \"BigNumber\"}, \"from\": \"0x0000000000000000000000000000\", \"gasUsed\": {\"hex\": \"0x5208\", \"type\": \"BigNumber\"}, \"logs\": [], \"logsBloom\": \"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\", \"status\": 1, \"to\": \"0x000000000000000000000000000\", \"transactionHash\": \"0x00000000000000000000000000000000000000\", \"transactionIndex\": 1, \"type\": 0}\n```\n#### Listen Transaction\n``` javascript\nlet provider = getProvider('https://bsc-dataseed1.binance.org/');\nlet rxHash =\n  '0x0000000000000000000000000000000';\nprovider.on(rxHash, res =\u003e {\n  if (res.confirmations \u003e 22) {\n    provider.removeAllListeners(rxHash);\n  }\n});\n```\nListen Transaction Print\n```\n{\"to\":\"0xA27F8f580C01Db0682Ce185209FFb84121a2F711\",\"from\":\"0xC8B6B589256f79ee6cDefC6034CD5805dDa060B2\",\"contractAddress\":null,\"transactionIndex\":1,\"gasUsed\":{\"type\":\"BigNumber\",\"hex\":\"0x5b11\"},\"logsBloom\":\"0x00000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000080000000000000000000008000000000000000000000000000000000000000000000000000000000000000200000000000000000000000001000010000000000000000000000000000000000000000000000000000000000000000080100000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000004000000000000000000000000040000000000000000000000080000000000000000000000000\",\"blockHash\":\"0xec167635c0616f13936ff26a073c1be355fd9838550780222e14c27fd6b4b5b9\",\"transactionHash\":\"0x2818970ff2d7e0e35396a7501fd79cab039c6d4ff6058bf6004895556f74a4d0\",\"logs\":[{\"transactionIndex\":1,\"blockNumber\":9423310,\"transactionHash\":\"0x2818970ff2d7e0e35396a7501fd79cab039c6d4ff6058bf6004895556f74a4d0\",\"address\":\"0xA27F8f580C01Db0682Ce185209FFb84121a2F711\",\"topics\":[\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\",\"0x000000000000000000000000c8b6b589256f79ee6cdefc6034cd5805dda060b2\",\"0x0000000000000000000000006025b091c6ab619f8e2f75170eb69dc57040dc6e\"],\"data\":\"0x00000000000000000000000000000000000000000000006c6b935b8bbd400000\",\"logIndex\":0,\"blockHash\":\"0xec167635c0616f13936ff26a073c1be355fd9838550780222e14c27fd6b4b5b9\"}],\"blockNumber\":9423310,\"confirmations\":4063,\"cumulativeGasUsed\":{\"type\":\"BigNumber\",\"hex\":\"0x5b11\"},\"status\":1,\"type\":0,\"byzantium\":true}\n```\n### Contract \n#### Get Contract Balance\n```javascript\ngetContractBalance(\n  rpcURL,\n  contractAddress,\n  erc20ABI,\n  ownAddress,\n)\n  .then(res =\u003e {\n    console.log(bigNumberFormatUnits(res));\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\n| Method| return| \n|--|--|\n|getContractBalance| BigNumberish|\n#### Get Contract to Call balanceOf Method\n```javascript\nlet contract = getContract(rpcURL, contractAddress, erc20ABI);\ncontract.balanceOf(ownAddress)\n  .then(res =\u003e {\n    console.log(bigNumberFormatUnits(res));\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n\n\ngetSignerContract(\n  rpcURL,\n  contractAddress,\n  erc20ABI,\n  JSON.stringify(keystore),\n  'password',\n)\n  .then(contract =\u003e {\n    contract\n      .balanceOf(ownAddress)\n      .then(res =\u003e {\n        console.log(bigNumberFormatUnits(res));\n      })\n      .catch(err =\u003e {\n        console.log(err);\n      });\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\n\n| Method| return| \n|--|--|\n|getContract|Contract|\n|getSignerContract| Contract|\n\n#### Contract Transcation\n```javascript\ngetGasPrice(rpcURL)\n  .then(gasPrice =\u003e {\n    console.log('gasPrice', gasPrice.toString());\n    getNonce(\n      rpcURL,\n      fromAddress,\n    )\n      .then(nonce =\u003e {\n        console.log('nonce', nonce);\n        contractTransaction(\n          rpcURL,\n          contractAddress,\n          erc20ABI,\n          JSON.stringify(keystore),\n          'password',\n          nonce,\n          gasLimit,\n          gasPrice,\n          toAddress,\n          amount,\n          contractDecmis,\n        )\n          .then(tx =\u003e {\n            console.log(tx);\n            waitForContractTransaction(tx)\n              .then(res =\u003e {\n                console.log(res);\n              })\n              .catch(err =\u003e {\n                console.log(err);\n              });\n          })\n          .catch(err =\u003e {\n            console.log(err);\n          });\n      })\n      .catch(err =\u003e {\n        console.log(err);\n      });\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\ncontractTransaction Print \n```\n{\"chainId\": 20180430, \"confirmations\": 0, \"data\": \"0xa9059cbb0000000000000000000000006025b091c6ab619f8e2f75170eb69dc57040dc6e0000000000000000000000000000000000000000000000000de0b6b3a7640000\", \"from\": \"0x000000000000000000000000\", \"gasLimit\": {\"hex\": \"0x9569\", \"type\": \"BigNumber\"}, \"gasPrice\": {\"hex\": \"0x0430e23400\", \"type\": \"BigNumber\"}, \"hash\": \"0xce39d74dac6606ffa8e74a7987dd4f9c5b268884fd72527ae386d5886868700d\", \"nonce\": 7, \"r\": \"0x07842ad39d3136e4729e5faeed002a7868782b7d0330222db82c427af18dda5e\", \"s\": \"0x1f83d27c87db5fa250ee81ea7092c0220bedd46056316d929e3f5403ab9d600e\", \"to\": \"0x00000000000000000000\", \"type\": null, \"v\": 40360896, \"value\": {\"hex\": \"0x00\", \"type\": \"BigNumber\"}, \"wait\": [Function anonymous]}\n```\nwaitForContractTransaction Print\n```\n{\"blockHash\": \"0x43498f57fbbd0ff6b6150a590e495e6f067de47c9ae837cd876c2600deb46e48\", \"blockNumber\": 9243425, \"byzantium\": true, \"confirmations\": 1, \"contractAddress\": null, \"cumulativeGasUsed\": {\"hex\": \"0x9569\", \"type\": \"BigNumber\"}, \"events\": [{\"address\": \"0xA27F8f580C01Db0682Ce185209FFb84121a2F711\", \"args\": [Array], \"blockHash\": \"0x43498f57fbbd0ff6b6150a590e495e6f067de47c9ae837cd876c2600deb46e48\", \"blockNumber\": 9243425, \"data\": \"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000\", \"decode\": [Function anonymous], \"event\": \"Transfer\", \"eventSignature\": \"Transfer(address,address,uint256)\", \"getBlock\": [Function anonymous], \"getTransaction\": [Function anonymous], \"getTransactionReceipt\": [Function anonymous], \"logIndex\": 0, \"removeListener\": [Function anonymous], \"topics\": [Array], \"transactionHash\": \"0xce39d74dac6606ffa8e74a7987dd4f9c5b268884fd72527ae386d5886868700d\", \"transactionIndex\": 1}], \"from\": \"0x0000000000000000000\", \"gasUsed\": {\"hex\": \"0x9569\", \"type\": \"BigNumber\"}, \"logs\": [{\"address\": \"0xA27F8f580C01Db0682Ce185209FFb84121a2F711\", \"blockHash\": \"0x43498f57fbbd0ff6b6150a590e495e6f067de47c9ae837cd876c2600deb46e48\", \"blockNumber\": 9243425, \"data\": \"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000\", \"logIndex\": 0, \"topics\": [Array], \"transactionHash\": \"0xce39d74dac6606ffa8e74a7987dd4f9c5b268884fd72527ae386d5886868700d\", \"transactionIndex\": 1}], \"logsBloom\": \"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000008000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000010000000000000000002000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000200000000000000002000000000000000000000000000000000000000000404000000000000000000000000040000000000000000000000080000000000000000000000000\", \"status\": 1, \"to\": \"0x00000000000000000000000\", \"transactionHash\": \"0xce39d74dac6606ffa8e74a7987dd4f9c5b268884fd72527ae386d5886868700d\", \"transactionIndex\": 1, \"type\": 0}\n```\n#### Get Contract to Call transaction Method\n```javascript\ngetSignerContract(\n  rpcURL,\n  contractAddress,\n  erc20ABI,\n  JSON.stringify(keystore),\n  'password',\n)\n  .then(contract =\u003e {\n    let realAmount = bigNumberParseUnits(amount);\n\n    contract.estimateGas\n    .transfer(toAddress, realAmount)\n    .then(gasLimit =\u003e {\n      let tx = {\n        nonce: nonce,\n        gasLimit: gasLimit,\n        gasPrice: gasPrice,\n      };\n\n      contract\n      .transfer(toAddress, realAmount, tx)\n      .then(res =\u003e {\n        fulfill(res);\n      })\n      .catch(err =\u003e {\n        reject(err);\n      });\n    })\n    .catch(err =\u003e {\n      reject(err);\n    });\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\n#### Listen Contract Transcation\n```javascript\nlet contract = getContract(\n  rpcURL,\n  contractAddress,\n  erc20ABI,\n);\nlet filterTo = contract.filters.Transfer(\n  null,\n  ownAddress,\n);\ncontract.on(filterTo, (from, to, amount, event) =\u003e {\n  console.log(bigNumberFormatUnits(amount));\n  event.getTransactionReceipt(event.transactionHash).then(console.log);\n  event.getBlock(event.blockNumber).then(res =\u003e {\n    let date = new Date(res.timestamp * 1000);\n    console.log(date);\n  });\n  contract.provider.on(event.transactionHash, res =\u003e {\n    console.log(JSON.stringify(res));\n    if (res.confirmations \u003e 21) {\n      contract.provider.removeAllListeners(event.transactionHash);\n    }\n  });\n});\n```\nevent Print\n```\n{\"address\": \"0xA27F8f580C01Db0682Ce185209FFb84121a2F711\", \"args\": [\"0x6025B091C6AB619F8e2F75170EB69dc57040dc6e\", \"0xaEE480Af938234865e4719119c29188eF4053e38\", [Object]], \"blockHash\": \"0x8747bb4712910057daea326c0d2baef80dc198be0df2d18e8f0777ba78db8925\", \"blockNumber\": 9429388, \"data\": \"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000\", \"decode\": [Function anonymous], \"event\": \"Transfer\", \"eventSignature\": \"Transfer(address,address,uint256)\", \"getBlock\": [Function anonymous], \"getTransaction\": [Function anonymous], \"getTransactionReceipt\": [Function anonymous], \"logIndex\": 0, \"removeListener\": [Function anonymous], \"removed\": false, \"topics\": [\"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef\", \"0x0000000000000000000000006025b091c6ab619f8e2f75170eb69dc57040dc6e\", \"0x000000000000000000000000aee480af938234865e4719119c29188ef4053e38\"], \"transactionHash\": \"0xc6765aa805ed8c5d846f2f70dc7344348a8b7c44d537ef92eee89e57fff1a1b3\", \"transactionIndex\": 1}\n```\ngetTransactionReceipt Print\n```\n{\"blockHash\": \"0xfa7a938b5f9908ac1a06ed11ed2bd346ba963916ab6740f0d198cdbfeba8aee6\", \"blockNumber\": 9429342, \"byzantium\": true, \"confirmations\": 1, \"contractAddress\": null, \"cumulativeGasUsed\": {\"hex\": \"0xd001\", \"type\": \"BigNumber\"}, \"from\": \"0x6025B091C6AB619F8e2F75170EB69dc57040dc6e\", \"gasUsed\": {\"hex\": \"0xd001\", \"type\": \"BigNumber\"}, \"logs\": [{\"address\": \"0xA27F8f580C01Db0682Ce185209FFb84121a2F711\", \"blockHash\": \"0xfa7a938b5f9908ac1a06ed11ed2bd346ba963916ab6740f0d198cdbfeba8aee6\", \"blockNumber\": 9429342, \"data\": \"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000\", \"logIndex\": 0, \"topics\": [Array], \"transactionHash\": \"0xef37fa6f7ce519f2d0564b31cb31991d2b951df67b0aad01c473fd1ee705e37e\", \"transactionIndex\": 1}], \"logsBloom\": \"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000002000000080000000000000000000008000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000010000000000000000000080000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000004000000000000000000000000040000000000000000000000080000000000000000000000000\", \"status\": 1, \"to\": \"0xA27F8f580C01Db0682Ce185209FFb84121a2F711\", \"transactionHash\": \"0xef37fa6f7ce519f2d0564b31cb31991d2b951df67b0aad01c473fd1ee705e37e\", \"transactionIndex\": 1, \"type\": 0}\n```\ngetBlock Print\n```\n{\"_difficulty\": {\"hex\": \"0x06\", \"type\": \"BigNumber\"}, \"difficulty\": 6, \"extraData\": \"0x29afa5018b3d9a5099d0ab5077c5ab321b50b802ddc4e9ca6c5e28915ce1afea6e4f857dfbef3a036e8625006c745a8613399329c418a67e3e3e16ef9e5f39c5ecadd80fc33501ef78155cfe9fbf481ed2b385fde38ec13b2d61d5fa14ec059f04c4aece002d81e8327380a1d8f253cf2a1a108293169cde61f1d129e07bcc0ecf05cdef9a4ab1eed385e211905ec9477630cd6b07827485263f75a11bbbf1b23dcfd1a5980ca5f12d803850a5b12f5f074b2cdfffeee323fc30c6e2b3bdecc15c599b368f3625fe58a99e14eeab533714e577159a3a78ff7750d2ddcca9db7e7100\", \"gasLimit\": {\"hex\": \"0x02625a00\", \"type\": \"BigNumber\"}, \"gasUsed\": {\"hex\": \"0x9569\", \"type\": \"BigNumber\"}, \"hash\": \"0x8747bb4712910057daea326c0d2baef80dc198be0df2d18e8f0777ba78db8925\", \"miner\": \"0xaCfa98C108D540a5b04Ca3a11B5073C3D6F0b812\", \"nonce\": \"0x0000000000000000\", \"number\": 9429388, \"parentHash\": \"0xd133b174187c07aa5a8b92063f6e9994cdb231ba394afaec9c9280b866293392\", \"timestamp\": 1657903483, \"transactions\": [\"0xc6765aa805ed8c5d846f2f70dc7344348a8b7c44d537ef92eee89e57fff1a1b3\"]}\n```\n\n#### Get Contract Nfts tokenIds\n```javascript\ngetContractNfts(\n  rpcURL,\n  contractAddress,\n  erc721ABI,\n  ownAddress,\n)\n  .then(nfts =\u003e {\n    console.log(nfts);\n  })\n  .catch(err =\u003e {\n    console.log(err);\n  });\n```\n### Get Contract to call nftInfos\n```javascript\nasync function getNFTInfos(ownAddress = undefined, page = 0, limit = 0) {\n  const contract = getContract(\n    rpcURL,\n    contractAddress,\n    ERC721EnumerableAbi,\n  );\n  var nftCount;\n  if (ownAddress === undefined) {\n    nftCount = await contract.totalSupply();\n  } else {\n    nftCount = await contract.balanceOf(ownAddress);\n  }\n\n  let token_idxs = [...Array(nftCount.toNumber()).keys()];\n\n  if (limit === 0) {\n    limit = token_idxs.length;\n  }\n  let lastPage = Math.ceil(token_idxs / limit);\n  if (page \u003e= 0 \u0026\u0026 page \u003c lastPage) {\n    token_idxs = token_idxs.slice(page * limit, page * limit + limit);\n  }\n  let nftInfos = [];\n\n  for await (const idx of token_idxs) {\n    var token_id;\n    if (ownAddress === undefined) {\n      token_id = (await contract.tokenByIndex(idx)).toNumber();\n    } else {\n      token_id = (await contract.tokenOfOwnerByIndex(ownAddress, idx)).toNumber();\n    }\n\n    let token_uri = await contract.tokenURI(token_id);\n\n    let nftInfo = {\n      id: token_id,\n      uri: token_uri,\n    };\n\n    if (ownAddress === undefined) {\n      let ownerOf = await contract.ownerOf(token_id);\n      nftInfo.ownerOf = ownerOf;\n    }\n    nftInfos.push(nftInfo);\n  }\n  return nftInfos;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheroims%2Freact-native-web3-wallet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheroims%2Freact-native-web3-wallet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheroims%2Freact-native-web3-wallet/lists"}