MetaMask / metamask-sdk

The simplest yet most secure way to connect your blockchain-based applications to millions of MetaMask Wallet users.
https://metamask.io/sdk/
Other
165 stars 101 forks source link

[ReactNative, ios] Issues occurred in the use of Contract's ABI (MetaMask SDK: v0.2.3, MetaMask Mobile: v6.3.0) #113

Closed reese-1eco closed 1 year ago

reese-1eco commented 1 year ago

Describe the bug

To Reproduce Steps to reproduce the behaviour:

  1. Run the recatNativeDemo app.
  2. Click the 'connect' button.
  3. Connect a Metamask account and switch to recatNativeDemo.
  4. Display the connect info on recatNativeDemo.
  5. Click the "try to get contraint info" Click
  6. check call function with debugging tools

Expected behaviour expect to be able to read information normally and use contract abi.

Screenshots

Provide environment information

Additional context

reese-1eco commented 1 year ago

test contract information

Is there anything else I can do to fix the problem? If it is possible to give a guide, I will try to solve it.

reese-1eco commented 1 year ago

It appears to be an issue related to #108

abretonc7s commented 1 year ago

The issue seems to be linked to using ethers. You should still be able to use web3 library to access the contract and we will investigate a fix for ethers.js asap.

andreahaku commented 1 year ago

we are still investigating this and trying to find a solution. In any case please update to the latest version of the SDK (v0.4.0 should be released later today). Thanks for reporting.

reese-1eco commented 1 year ago

Thank you for providing information. I will check after installing sdk version 0.4.0.

reese-1eco commented 1 year ago

@abretonc7s What is the best way to use smart contract's transfer api with metamask-sdk version 0.5.3? Would it be better to use web3.js over ethers.js?

Is there any way to use the Ethereum provider API? If there is a document on how to control a smart contract with the Ethereum provider API, please let me know the url.

thank you

abretonc7s commented 1 year ago

We are still working on integrating new hooks to handle smart contracts but in the meantime using web3js is probably the best way for now.

reese-1eco commented 1 year ago

@abretonc7s thank you I will also try to use web3.js. Is there a recommended web3.js version or example? Please share if possible. I'm currently developing a dapp for mobile with react native.

abretonc7s commented 1 year ago

Please see this example

    const account = await sdk?.connect();
    console.log('account', account);
    let web3 = new Web3(sdk?.getProvider() as any);
    const accounts = await web3.eth.requestAccounts();
    console.log('accounts', accounts);

    await web3.eth.personal.sign(
      web3.utils.utf8ToHex('this is a test'),
      accounts[0],
      undefined as any,
    );
  };

Closing the issue for now, feel free to open another one if you need additional support.