Skip to content
Advertisement

Why am I getting “Error processing transaction request: intrinsic gas too low” error when trying to add tUSDT to a particular account?

I am trying to send test USDT to a particular account in Java using the following code:

JavaScript

The last statement results in the following exception:

JavaScript

TestGasProvider is defined as:

JavaScript

usdtContract was deployed using this script, which calls deploy.js:

JavaScript

This contract is running on a local testnet set up as described here.

What do I need to change in any of these components (testnet, contract, deploy scripts, Java code) in order to send any amount of USDT to a particular address (without any errors)?

Update 1: If I change TestGasProvider to

JavaScript

I get another error:

JavaScript

Update 1

I am looking to submit a set of code changes to the branch i16 of the minimal-crypto-exchange project which passes the following test:

Step 1

Set up the environment as described here.

Step 2

Set a breakpoint on line usdtContract.transfer(exchangeAddress, BigInteger.valueOf(10)).send(); in TransferUsdtToExchangeAccount class:

Screenshot of the code part with breakpoint

Step 3

Start the process engine application in debug mode. Its Java main method is located here.

Wait until you see the message starting to acquire jobs in the console output:

JavaScript

Step 4

Login with the credentials demo/demo at http://localhost:8080.

Screenshot of the login form

After login you should see a page like this:

Main Camunda dashboard with tasklist link highlighted

Step 5

Click on the tasklist link. You should see a page that looks like this:

"Start process" link the tasklist

Press the “Start process” link. Following screen will appear:

"Start process" dialog box with "Send USDT to the exchange account" process highlighted

Click on Send USDT to the exchange account process link. Following dialog box will appear:

"Start process" dialog

Enter an arbitrary value into the “business key” field and press the “Start” button.

Step 6

After a couple of seconds, the breakpoint from step 2 will activate.

The problem will be solved if usdtContract.transfer(exchangeAddress, BigInteger.valueOf(10)).send() is executed without errors.

Notes

  1. You are allowed to modify the amount in usdtContract.transfer(exchangeAddress, BigInteger.valueOf(10)).send(); from 10 to something else.
  2. You can also modify the parameters of the Ethereum testnet specified in docker-compose.yml and genesis.json, as well as those of the USDT smart contract which is deployed using this script.
  3. Your solution must work in this controlled environment (i. e. no faucets must be used).

Update 2

I made following changes:

  1. The set-up tutorial now contains step 7 in which ETH is added to the exchange account.
  2. Now a new version of the ETH testnet is being used, major changes being that log output is more verbose and the gas price is set to 1 (see --miner.gasprice 1 in entrypoint.sh).
  3. Modified the code in TransferUsdtToExchangeAccount so that now USDT is transferred not from the exchange account (which has zero balance), but from the buffer account.

Now I am receiving the error

JavaScript

Advertisement

Answer

My skills with Ethereum are still not sharp enough to give you a proper answer, but I hope you get some guidance.

The error states that you are trying to transfer by a party A certain quantity in the name of another party B, to a third one C, but the amount you are trying to transfer, using transferFrom, is greater than the one party B approved party A to send.

You can check the actual allowance between to parties using the method with the same name of your contract.

Please, consider review this integration test from the web3j library in Github. It is different than yours but I think it could be helpful.

Especially, it states that the actual transferFrom operation should be performed by the beneficiary of the allowance. Please, see the relevant code:

JavaScript

This fact is also indicated in this OpenZeppelin forum post.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement