Ethereum React Native Boilerplate Questions

Is this issue related to WalletConnect?

Works sometimes, and mostly crash

1 Like

I have the same problem

Hi,
Thank you for your reply.
Capture
video: https://streamable.com/o42ty9

The transaction popup in metamask, is still not opened. Are there any solutions to fix this?

I GOT THIS MASSEGE FROM 1INCH SUPPORT:

Hi, the token must have 10k USD worth of liquidity on a connector token. Along with that, the Moralis plugin is outdated and uses an old version of 1inch.

Hi, even I’m getting same error. Is there a solution for this?
Thank you

@fatih01 @eugene @gen
It seems that after 2 weeks of struggling I finally found the solution for the transaction pop up problem in react-native app using the boilerplate project with WalletConnect and MetaMask.
You can see my approach below:

const { web3 } = useMoralis();
const connector = useWalletConnect();

const sendTransaction = React.useCallback(async () => {
    try {
      const data = web3.eth.abi.encodeFunctionCall({
        name: 'storeGeoCoordinate',
        type: 'function',
        inputs: [{type: 'string', name: 'lat'},
                {type: 'string', name: 'long'}]
      }, ["40.730610", "-73.935242"])

       await connector.sendTransaction({
        data: data,
        from: connector.accounts[0],
        to: '0x8caa9810Ecd5E19b85585Bdd342cb1EE8984261e',
        value: '0x00',
      });
    } catch (e) {
      console.error(e);
    }
  }, [connector]);

Use the walletConnector instance instead of Moralis.executeFunction to send the transaction and encode the smart contract function parameters through web3 instance as showed above.
For the ā€œtoā€ param specify the live smart contract address on the network you are using.
The modal to sign the transaction will finally pop up and the transaction goes through, and writes the state as expected. I tested it on ropsten test network, but should be working also on kovan and other networks.
:ok_hand:

2 Likes

Awesome! @sandormaraczy
Really helped me a lot. Thanks.

1 Like

I get Internal JSON-RPC error. from wallet connect when sending the transaction - any ideas? The encodeFunctionCall works as expected though

Reinstall the metamask. It can be the solution.

Reinstallation of MetaMask can be a solution, but I would suggest first to double check the function parameters: types and values you specify when encoding the function call

Another smaller pure function works flawlessly - it’s just this function but I am pretty sure the args (tuples and types) are correct. Do I need to specify more wei etc in the call? Contract Code works fine on truffle and remix

No, I don’t think you need.
The example I came up with refers to a smart contract transaction that modifies the state.
The user needs to sign this transaction in order for the state to be modified.
A pure function does not modify the state, you only read the state, therefore there is no need to specify gas either, you just need to make a ā€œcallā€ to get the result from.
If you do it through moralis you can use ā€œrunContractFunctionā€ for read-only calls:
https://docs.moralis.io/moralis-server/web3-sdk/native

But you can also do it with the web3 object as well as shown here!
https://web3js.readthedocs.io/en/v1.2.4/web3-eth-contract.html#id25

myContract.methods.myMethod(123).call({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'}, function(error, result){
    ...
});
1 Like

I reran in remix and found that Internal rpc can be sent for transactions that fail - on require. Ugh wallet connect doesn’t pass the error message on react native. So I just need to ensure I am meeting my contracts requirements. Nothing wrong here :sweat_smile:

1 Like

i am getting this error for yarn start , any help will be appreciated .

Starting the development server…

Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at module.exports (C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:417:16)
at handleParseError (C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:471:10)
at C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:503:5
at C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:358:12
at C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at iterateNormalLoaders (C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
C:\DEV\ethereum-boilerplate\node_modules\react-scripts\scripts\start.js:19
throw err;
^

Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at module.exports (C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\util\createHash.js:135:53)
at NormalModule._initBuildHash (C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:417:16)
at C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:452:10
at C:\DEV\ethereum-boilerplate\node_modules\webpack\lib\NormalModule.js:323:13
at C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:367:11
at C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:233:18
at context.callback (C:\DEV\ethereum-boilerplate\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
at C:\DEV\ethereum-boilerplate\node_modules\react-scripts\node_modules\babel-loader\lib\index.js:59:103 {
opensslErrorStack: [ ā€˜error:03000086:digital envelope routines::initialization error’ ],
library: ā€˜digital envelope routines’,
reason: ā€˜unsupported’,
code: ā€˜ERR_OSSL_EVP_UNSUPPORTED’
}

Node.js v17.2.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS C:\DEV\ethereum-boilerplate>

@BTCbullDOG if you have node v17 and and above, try downgrading to node v16.13.0. And also try to post this in Ethereum Boilerplate forum. Thanks!

For the WalletConnect problem there is an answer in this forum to fix it. In AndroidManifest file from android/app/src/main paste this

<queries>
<package android:name="io.metamask"/>
<package android:name="com.wallet.crypto.trustapp"/>
</queries>

inside it and it should work. I’m using API version 32 of android emulator and it works perfectly.

Same here for the ā€œERR_OSSL_EVP_UNSUPPORTEDā€ error,

I found another solution, given in StackOverflow :

I added the following to node_modules\react-scripts\config\webpack.config.js
(i did at line 77…)

const crypto = require("crypto");
const crypto_orig_createHash = crypto.createHash;
crypto.createHash = algorithm => crypto_orig_createHash(algorithm == "md4" ? "sha256" : algorithm);

and then ā€œyarn startā€ runs without problems

I did this it opens wallet and when I click back button nothing happens in the app!