0

hi can you help me I want to get tether balance of an account and send tether to my contract using web3 and send the tether in the contract to another address. and I have no idea how to do it. I didn't find any tutorial

1

3 Answers 3

1

I think this is the way to transfer USDT or any ERc20 token on any EVM chain with web3JS:-

Step 1: see the code. e.g. this is USDT (Polygon Matic) solidity code https://polygonscan.com/address/0x2791bca1f2de4661ed88a30c99a7a9449aa84174#code#L121

step 2: find the function which transfer tokens. solidity code : aakash4dev

step 3: get ABI code most of the trusted NFT-721 give their solidity source code, from there you can get ABI codes.

finally: use web3js .send() methond to interact with that function.

let contract = new web3.eth.Contract(ABI, contractadddress)
contract.methods.transferProxyOwnership("0x23498...").send({<gas fee settings>})
        .then(receipt =>console.log(receipt))
        .catch(err=>console.log(err))

learn proper web3js from youtube & official docs https://web3js.readthedocs.io/en/v1.2.11/index.html

0

here is a solution for you.

  1. Use Zapper.fi API to get the USDT balance of an address (Store this).

  2. Then use either their API features or plain Web3.js to interact with the USDT smart contract and execute the transferFrom function with this as the "_value".

That's it! I hope this gives you some guidance :)

2
0

I think you must put a deposit function on your contract. You cannot transfer randomly to a contract tokens, it will be reverted, only to address.

1
  • 1
    Important correction: it would not revert in most cases. Meaning the USDT would be stuck where you sent them, assuming you didn't plan a way to get them out
    – natewelch_
    Commented Apr 27, 2022 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.