MetaMask / MetaMask/metamask-sdk

[Bug]: Data don't work if I use transactionParameters

Open
#1,014 3 comments 0 reactions 0 assignees View on GitHub
Bug Triage
Dominant language
TypeScript
Stars
338
Forks
260
PR merge metrics
No merged PRs in 30d

Description

### SDK

React-Native

### Provide environment information

I'm using react-native and testing on the iPhone. I'm having trouble getting the transfer result and the updated balance.

### MetaMask SDK Version

0.28.2

### MetaMask Mobile app Version

7.29.2

### What browser are you using? (if relevant)

_No response_

### How are you deploying your application? (if relevant)

_No response_

### Describe the Bug

There is a currency called RAI, however, when I use the function
```
web3 = new Web3(provider);
contract = new web3.eth.Contract(contractAbi, contractAddress);
contract.methods.transfer(recipient, amount).send({ from: account })
```
on the web it works, and if I use it for the MetaMask app, it opens the app and shows the name of the currency. But I don't get a response when I'm waiting for the transaction result.
So for the app I tried to use the code below:

```
web3 = new Web3(provider);
contract = new web3.eth.Contract(contractAbi, contractAddress);
const transactionParameters = {
to,
from,
data: contract.methods.transfer(to, value).encodeABI(),
};
const txHash = await provider?.request({
method: 'eth_sendTransaction',
params: [transactionParameters],
});
```
The name of the currency does not appear in the MetaMask app, instead the name ERC20 appears.

I tried to use the same function as on the web, but I don't get any feedback when there is no error and I don't know how to get this feedback.

### Expected Behavior

Get feedback from the Metamask app whether the transaction was successful or not. And the current balance value.

### Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

_No response_

### To Reproduce

package.json:
```
"@metamask/sdk": "^0.28.2",
"@metamask/sdk-react": "^0.27.0",
"@react-native-async-storage/async-storage": "^2.0.0",
"ethers": "5.7.2",
"react": "^18.2.0",
"react-native": "0.72.7",
```

Use the function below:

```
const sendTransaction = async () => {
const to = inputAdress;
const value = (parseFloat(inputValue) * 10 ** 4);
let from = account
try {
web3 = new Web3(provider);
contract = new web3.eth.Contract(contractAbi, contractAddress);
const transactionParameters = {
to,
from,
data: contract.methods.transfer(to, value).encodeABI(),
};

const txHash = await provider?.request({
method: 'eth_sendTransaction',
params: [transactionParameters],
});
console.log("txHash",txHash);

} catch (e) {
Alert.alert('Erro na transferência');
setLoading(false);
}
};

```

Contributor guide

Open the contributing guide

Research direction

Start with the React Native sendTransaction example and the listed SDK versions, then trace provider.request with eth_sendTransaction and compare it with contract.methods.transfer(...).send. Check how the transaction result and balance are expected to be reported in this path. Done means confirming the behavior with a minimal reproduction and documenting or fixing the result and balance handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
blockchain, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.