Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USDT approve error #597

Closed
sunnycn2013 opened this issue Sep 2, 2019 · 4 comments
Closed

USDT approve error #597

sunnycn2013 opened this issue Sep 2, 2019 · 4 comments
Labels
discussion Questions, feedback and general information.

Comments

@sunnycn2013
Copy link

sunnycn2013 commented Sep 2, 2019

I want approve usdt to other adddess, I have deal amount like this, but it is error too..
please help me! thanks

`
let contractAddress ="0xdac17f958d2ee523a2206206994597c13d831ec7";
let acountNum = ethers.utils.parseUnits('1',6);

// 使用Provider 连接合约,将只有对合约的可读权限
let contract = new ethers.Contract(contractAddress, contracObj.contractAbi, this.provider);
//创建一个签名过的合约实例
let contractWithSigner = contract.connect(wallet);
await contractWithSigner.approve(toAcount, acountNum);
`

error:

body: "{"method":"eth_estimateGas","params":[{"gasPrice":"0x28fa6ae00","from":"0xeDc6B81DD981F912ff6C8Ec70603274913Dde36a","to":"0xdAC17F958D2ee523a2206206994597C13D831ec7","data":"0x095ea7b300000000000000000000000074622073a4821dbfd046e9aa2ccf691341a076e1000000000000000000000000000000000000000000000000000000000754d4c0"}],"id":50,"jsonrpc":"2.0"}" code: -32016 data: undefined responseText: "{"jsonrpc":"2.0","error":{"code":-32016,"message":"The execution failed due to an exception."},"id":50}↵" url: "http://47.91.28.165:8545/eth" message: "The execution failed due to an exception." stack: "Error: The execution failed due to an exception.↵ at v (blob:http://localhost:8081/ca8a38ea-6f36-460e-9dea-5b620cad2f69:141817:21)↵ at XMLHttpRequest.o.onreadystatechange (blob:http://localhost:8081/ca8a38ea-6f36-460e-9dea-5b620cad2f69:145548:23)↵ at XMLHttpRequest.dispatchEvent (blob:http://localhost:8081/ca8a38ea-6f36-460e-9dea-5b620cad2f69:28786:27)↵ at XMLHttpRequest.setReadyState (blob:http://localhost:8081/ca8a38ea-6f36-460e-9dea-5b620cad2f69:28524:14)↵ at XMLHttpRequest.__didCompleteResponse (blob:http://localhost:8081/ca8a38ea-6f36-460e-9dea-5b620cad2f69:28366:16)↵ at blob:http://localhost:8081/ca8a38ea-6f36-460e-9dea-5b620cad2f69:28476:47↵ at RCTDeviceEventEmitter.emit (blob:http://localhost:8081/ca8a38ea-6f36-460e-9dea-5b620cad2f69:6129:37)↵ at MessageQueue.__callFunction (blob:http://localhost:8081/ca8a38ea-6f36-460e-9dea-5b620cad2f69:2587:44)↵ at blob:http://localhost:8081/ca8a38ea-6f36-460e-9dea-5b620cad2f69:2344:17↵ at MessageQueue.__guard (blob:http://localhost:8081/ca8a38ea-6f36-460e-9dea-5b620cad2f69:2541:13)" __proto__: Object

@sunnycn2013
Copy link
Author

@ricmoo

@ricmoo
Copy link
Member

ricmoo commented Sep 5, 2019

That error means that the nodes were unable to correctly estimate a gas limit, so you will need to specify it manually. It could be unable to estimate because the contract has complex external calls, or because the transaction will cause a revert. You can try:

let overrides = {
    gasLimit: 500000
};
await contractWithSigner.approve(toAcount, acountNum, overrides);

Let me know if you still have any problems.

@ricmoo ricmoo added the discussion Questions, feedback and general information. label Sep 5, 2019
@ricmoo
Copy link
Member

ricmoo commented Sep 9, 2019

I think that may have solved your issue, so I'm going to close this now. Please feel free to re-open if it did not though.

Thanks! :)

@ricmoo ricmoo closed this as completed Sep 9, 2019
@Nuel-C
Copy link

Nuel-C commented Aug 14, 2022

I’m having issues approving usdt on my Metamask. The transaction keeps failing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Questions, feedback and general information.
Projects
None yet
Development

No branches or pull requests

3 participants