I'm trying to send USDT (custom token) with the metamask API using web3. I'm developing on ReactJS and I could detected correctly the user account from metamask.
My code:
const web3 = new Web3(window.web3.currentProvider);
const contractInstance = new web3.eth.Contract(abiUSDT, addressUSDT);
const amount = 200;
const tx = {
from: 'PERSON_SENDER',
to: contractInstance._address,
data: contractInstance.methods.transfer('PERSON_RECIPIENT', web3.utils.toWei( amount.toString() ) ).encodeABI(),
}
web3.eth.sendTransaction(tx).then(res => {
console.log("res",res)
}).catch(err => {
console.log("err",err)
});
obviously, I replace the fields called: PERSON_SENDER and PERSON_RECIPIENT with:
PERSON_SENDER: The user account
PERSON_RECIPIENT: My personal account (I want to deposit in this account)
Using this config, the transaction doesn't send to my account when I check in etherscan (and the amount was sent to the address of the contract), and a user communicate that if he uses real values for him real account, metamask doesn't touch his amount.