MetaMask / MetaMask/metamask-mobile
When I use WalletConnect with MetaMask, MetaMask get request, send Token and ETH together that wrong
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 1.7k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 669
Description
When I use WalletConnect with MetaMask, MetaMask get request, send token and eth together in one transaction, equal amount, example 800tokens+800ETH that is wrong, when I use MetaMask without WalletConnect all ok, sends only 800tokens, that is right. I use different methods but result is only one wrong. Example:
```
const providerOptions = {
walletconnect: {
package: WalletConnectProvider,
options: {
// Mikko's test key - don't copy as your mileage may vary
infuraId: "**************"
}
}
};
web3Modal = new Web3Modal({
cacheProvider: false, // optional
providerOptions, // required
disableInjectedProvider: false, // optional. For MetaMask / Brave / Opera.
});
try {
provider = await web3Modal.connect(); //choose WalletConnect and open MetaMask
} catch(e) {
console.log("Could not get a wallet connection", e);
return;
}
let web3 = new Web3(provider);
let mycontract
try {
mycontract=new web3.eth.Contract(contract.abi,contract.address,{
from: selectedAccount // default from address
});
} catch (error) {
}
let amount=parseFloat(800).toFixed(18); //get count tokens
amount=web3.utils.toWei(amount, "ether");
let data=mycontract.methods.transfer(recipient,amount).encodeABI()
// start method 1 to send tokens
let params= [
{
from: selectedAccount,
to:contract.address,
data:data
}
];
provider.request({
method: 'eth_sendTransaction',
params
})
.then((result) => {
// The result varies by RPC method.
// For example, this method will return a transaction hash hexadecimal string on success.
console.log("provider.request:",result)
})
.catch((error) => {
onsole.error("provider.request error:",error)
// If the request fails, the Promise will reject with an error.
});
//end method 1, send 800tokens+800ETH in MetaMask and need only 800tokens
//start method 2 to send tokens
mycontract.methods.transfer(recipient,amount).send({from:selectedAccount},function(err,transfer){
if (err) throw err
});
//end method 2 send example 800tokens+800ETH in MetaMask and need only 800tokens
//Please help me, I don know what do,Where is trouble
```

Contributor guide
Research direction
No repository file or test is named. Start by reproducing the WalletConnect-to-MetaMask flow from the provided web3Modal setup, then inspect the provider.request eth_sendTransaction path and the contract transfer path. Done means the transaction sends only the requested token amount without an unintended ETH transfer, matching the injected-provider behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- blockchain, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100