Send USDT transaction error

I want to send USDT transaction on Ethereum mainnet. But on the MetaMask, I got the error like this.
And the gas fee is so high.

And my code is like this:

let contractAddress = '0xdAC17F958D2ee523a2206206994597C13D831ec7';
let _amount = '0x' + Big(10).pow(6).times(amount).toNumber().toString(16)
contract = new web3.eth.Contract(abi, contractAddress);
data = await contract.methods.transfer(to, _amount).encodeABI();
ethereum
    .request({
        method: 'eth_sendTransaction',
        params: [{
            from: from, // The user's active address.
            to: contractAddress, 
            data: data,
            }],
    })
    .then((txHash) => {
        console.log(txHash)
    })
    .catch((error) => console.error(error));

The abi is like this I copy from Ethercan

[{
  "constant": false, 
  "inputs": [
      {
          "name": "_to", 
          "type": "address"
      }, 
      {
          "name": "_value", 
          "type": "uint256"
      }
  ], 
  "name": "transfer", 
  "outputs": [ ], 
  "payable": false, 
  "stateMutability": "nonpayable", 
  "type": "function"
}]

Anyone could tell me what is wrong. Thank you very much!

Hi where is it your code or are you using any contract sdk. I know the transactions were stopped to update dependencies not sure if it’s related could you try again later please

1 Like

My enviroment is pure JavaScript.

And I import to js files in the code.

<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js"></script>
<script src="https://c0f4f41c-2f55-4863-921b-sdk-docs.github.io/cdn/metamask-sdk.js"></script>

And get Provider like this:

const web3 = new Web3(window.ethereum);
const MMSDK = new MetaMaskSDK.MetaMaskSDK()
await MMSDK.init();
const ethereum = MMSDK.getProvider() /
1 Like

Thanks I’m not sure where you got this total formula I think it’s a bit off, have you tried on the testnet too before using mainnet do you see the same result?

Why does it add 1.38816… of ETH where this code is coming from:

Screen Shot 2023-12-19 at 1.39.49 PM

please open a support ticket to look further into this: https://support.metamask.io/hc/en-us/requests/new?ticket_form_id=15071540780827

Thanks for reply. The gas fee is calculated by MetaMask, might caused by an error in the contract. But I don’t know where is the error.

Could you please open a ticket with the support team: https://support.metamask.io/hc/en-us/requests/new?ticket_form_id=15071540780827 we need to check further, thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.