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

Error: (code: -32000, message: transaction underpriced, data: None) #6

Closed
DiMiTriFrog opened this issue Aug 6, 2023 · 24 comments
Closed
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@DiMiTriFrog
Copy link

I'm trying to make swap in mumbai and I'm having this issue:

Error: (code: -32000, message: transaction underpriced, data: None)

@azerpas
Copy link
Owner

azerpas commented Aug 6, 2023

@DiMiTriFrog could you use the --verbose flag and add the logs to the issue?
Make sure to remove any private data

@azerpas azerpas added the bug Something isn't working label Aug 6, 2023
@azerpas azerpas self-assigned this Aug 6, 2023
@DiMiTriFrog
Copy link
Author

@DiMiTriFrog could you use the --verbose flag and add the logs to the issue?
Make sure to remove any private data

No explorer found for chain id 80001
💫 Welcome to the Uniswap V3 Swap CLI 💫
We will use wallet with address: 0x5187…8193
Converting to 18 decimals
Amount to approve specified. Approving 4 tokens.
Error: (code: -32000, message: transaction underpriced, data: None)

@azerpas
Copy link
Owner

azerpas commented Aug 7, 2023

@DiMiTriFrog could you use the --verbose flag and add the logs to the issue?
Make sure to remove any private data

No explorer found for chain id 80001 💫 Welcome to the Uniswap V3 Swap CLI 💫 We will use wallet with address: 0x5187…8193 Converting to 18 decimals Amount to approve specified. Approving 4 tokens. Error: (code: -32000, message: transaction underpriced, data: None)

Are you using an Infura RPC? [1] [2]

@DiMiTriFrog
Copy link
Author

@DiMiTriFrog could you use the --verbose flag and add the logs to the issue?
Make sure to remove any private data

No explorer found for chain id 80001 💫 Welcome to the Uniswap V3 Swap CLI 💫 We will use wallet with address: 0x5187…8193 Converting to 18 decimals Amount to approve specified. Approving 4 tokens. Error: (code: -32000, message: transaction underpriced, data: None)

Are you using an Infura RPC? [1] [2]

No... it's 100% necessary?

I want to use private anon RPC

Has any way to use own RPC? I'm executing from source so i can modify it.

@azerpas
Copy link
Owner

azerpas commented Aug 7, 2023

@DiMiTriFrog could you use the --verbose flag and add the logs to the issue?
Make sure to remove any private data

No explorer found for chain id 80001 💫 Welcome to the Uniswap V3 Swap CLI 💫 We will use wallet with address: 0x5187…8193 Converting to 18 decimals Amount to approve specified. Approving 4 tokens. Error: (code: -32000, message: transaction underpriced, data: None)

Are you using an Infura RPC? [1] [2]

No... it's 100% necessary?

I want to use private anon RPC

Has any way to use own RPC? I'm executing from source so i can modify it.

You can use any RPC you want but it seems like on their end the transaction is ignored as it's considered "underpriced". Increasing the value of the transaction or switching RPC might do the trick for you.

Please let me know.

@DiMiTriFrog
Copy link
Author

You are fully right, thank you very much,

Now the issue i'm having is that in testnet there isn't a pool for the tokens I want to swap. I thought that the uniswap router was the one to do it.

@azerpas
Copy link
Owner

azerpas commented Aug 8, 2023

You are fully right, thank you very much,

Now the issue i'm having is that in testnet there isn't a pool for the tokens I want to swap. I thought that the uniswap router was the one to do it.

From what I can see at 0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD (Uniswap V3 Router on Mumbai), WETH and WMATIC can be swapped together.

@DiMiTriFrog
Copy link
Author

0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD

Same result... :(

The run:
cargo run -- -u https://polygon-mumbai-bor.publicnode.com -n 80001 -d true -a 4 -s 1 -i 0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889 -o 0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa --verbose

The output:
Error: (code: -32000, message: transaction underpriced, data: None)

Inside main.rs:

    const UNISWAP_V3_ROUTER_ADDRESS: &str = "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD";
    const UNISWAP_V3_QUOTER_ADDRESS: &str = "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6";

Thank you very much for your help @azerpas

@azerpas
Copy link
Owner

azerpas commented Aug 11, 2023

0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD

Same result... :(

The run: cargo run -- -u https://polygon-mumbai-bor.publicnode.com -n 80001 -d true -a 4 -s 1 -i 0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889 -o 0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa --verbose

The output: Error: (code: -32000, message: transaction underpriced, data: None)

Inside main.rs:

    const UNISWAP_V3_ROUTER_ADDRESS: &str = "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD";
    const UNISWAP_V3_QUOTER_ADDRESS: &str = "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6";

Thank you very much for your help @azerpas

Could you modify your comment with the full logs please? 😃

@DiMiTriFrog
Copy link
Author

0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD

Same result... :(
The run: cargo run -- -u https://polygon-mumbai-bor.publicnode.com -n 80001 -d true -a 4 -s 1 -i 0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889 -o 0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa --verbose
The output: Error: (code: -32000, message: transaction underpriced, data: None)
Inside main.rs:

    const UNISWAP_V3_ROUTER_ADDRESS: &str = "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD";
    const UNISWAP_V3_QUOTER_ADDRESS: &str = "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6";

Thank you very much for your help @azerpas

Could you modify your comment with the full logs please? 😃

Screenshot 2023-08-11 at 09 51 36

No more logs...

@azerpas
Copy link
Owner

azerpas commented Aug 11, 2023

@DiMiTriFrog as you're building the project from source, could you try to increasing the gas for the approve transaction?

// Line 117
let approve_tx: TransactionReceipt = token_in_contract
            .approve(router_address, amount_to_approve)
+           .gas(300000000)
            .send()
            .await?
            .await?
            .expect("Approve transaction failed");

@DiMiTriFrog
Copy link
Author

@DiMiTriFrog as you're building the project from source, could you try to increasing the gas for the approve transaction?

// Line 117
let approve_tx: TransactionReceipt = token_in_contract
            .approve(router_address, amount_to_approve)
+           .gas(300000000)
            .send()
            .await?
            .await?
            .expect("Approve transaction failed");
Screenshot 2023-08-11 at 23 42 47

I tried before but the method is not implemented.

Screenshot 2023-08-11 at 23 43 33

Thanks very much for your help.

@azerpas
Copy link
Owner

azerpas commented Aug 11, 2023

@DiMiTriFrog as you're building the project from source, could you try to increasing the gas for the approve transaction?

// Line 117
let approve_tx: TransactionReceipt = token_in_contract
            .approve(router_address, amount_to_approve)
+           .gas(300000000)
            .send()
            .await?
            .await?
            .expect("Approve transaction failed");
Screenshot 2023-08-11 at 23 42 47 I tried before but the method is not implemented. Screenshot 2023-08-11 at 23 43 33 Thanks very much for your help.

Mind it's need to be before the send() call

@DiMiTriFrog
Copy link
Author

Su

@DiMiTriFrog as you're building the project from source, could you try to increasing the gas for the approve transaction?

// Line 117
let approve_tx: TransactionReceipt = token_in_contract
            .approve(router_address, amount_to_approve)
+           .gas(300000000)
            .send()
            .await?
            .await?
            .expect("Approve transaction failed");
Screenshot 2023-08-11 at 23 42 47 I tried before but the method is not implemented. Screenshot 2023-08-11 at 23 43 33 Thanks very much for your help.

Mind it's need to be before the send() call

Sure, sorry.

Now i have this output:_

Amount to approve specified. Approving 4 tokens.
Error: (code: -32000, message: exceeds block gas limit, data: None)

😭😭

@DiMiTriFrog
Copy link
Author

Is there anything else I can try?

@azerpas
Copy link
Owner

azerpas commented Aug 15, 2023

@DiMiTriFrog Playing with the gas() function to find the right amount is the only option I can think of atm...

Something that you could try that I haven't tried is use the estimate_gas() func.

        // Approve the router to spend USDT
        let approve_tx = token_in_contract
            .approve(router_address, amount_to_approve);

        let approve_tx_gas = approve_tx.estimate_gas().await?;

        if args.verbose {
            println!("Approve transaction gas estimate: {}", approve_tx_gas);
        }

        let approve_tx: TransactionReceipt = approve_tx
            .gas(approve_tx_gas)
            .send()
            .await?
            .await?
            .expect("Approve transaction failed");

@DiMiTriFrog
Copy link
Author

@DiMiTriFrog Playing with the gas() function to find the right amount is the only option I can think of atm...

Something that you could try that I haven't tried is use the estimate_gas() func.

        // Approve the router to spend USDT
        let approve_tx = token_in_contract
            .approve(router_address, amount_to_approve);

        let approve_tx_gas = approve_tx.estimate_gas().await?;

        if args.verbose {
            println!("Approve transaction gas estimate: {}", approve_tx_gas);
        }

        let approve_tx: TransactionReceipt = approve_tx
            .gas(approve_tx_gas)
            .send()
            .await?
            .await?
            .expect("Approve transaction failed");

I appreciate too very much your help, these function is so useful for me, but is still not working.

I change my tests to Sepolia and now I have a new error output.

I'm using as input token wETH 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14
and as output token UNI 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984.

I swapped previously using Uniswap UI and when i tried to do the same using the CLI using this command ->

cargo run -- -u https://ethereum-sepolia.blockpi.network/v1/rpc/public -n 11155111 -a 2000000000000000000 -s 1000000 -i 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14 -o 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 --verbose

But after executing it, i have this output ->

 We will use wallet with address: 0x5187…8193
Amount to approve specified. Approving 2000000000000000000 tokens.
Approve transaction gas estimate: 26152
Approved Uniswap V3 Router spending. Transaction Hash: 0xf283431625f74bc34ed19e3609d12b7dcd63dd809341f802293bc01d8f2278b3
Transaction Receipt: TransactionReceipt {
    transaction_hash: 0xf283431625f74bc34ed19e3609d12b7dcd63dd809341f802293bc01d8f2278b3,
    transaction_index: 3,
    block_hash: Some(
        0x0d4e5e6a08b6167d1af68fde7b0ca541ed2d70f316047368cc70d38fb464579a,
    ),
    block_number: Some(
        4095185,
    ),
    from: 0x518766536b70187c48a99d2020725799dc3b8193,
    to: Some(
        0xfff9976782d46cc05630d1f6ebab18b2324d6b14,
    ),
    cumulative_gas_used: 1329004,
    gas_used: Some(
        26152,
    ),
    contract_address: None,
    logs: [
        Log {
            address: 0xfff9976782d46cc05630d1f6ebab18b2324d6b14,
            topics: [
                0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925,
                0x000000000000000000000000518766536b70187c48a99d2020725799dc3b8193,
                0x0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad,
            ],
            data: Bytes(0x0000000000000000000000000000000000000000000000001bc16d674ec80000),
            block_hash: Some(
                0x0d4e5e6a08b6167d1af68fde7b0ca541ed2d70f316047368cc70d38fb464579a,
            ),
            block_number: Some(
                4095185,
            ),
            transaction_hash: Some(
                0xf283431625f74bc34ed19e3609d12b7dcd63dd809341f802293bc01d8f2278b3,
            ),
            transaction_index: Some(
                3,
            ),
            log_index: Some(
                3,
            ),
            transaction_log_index: None,
            log_type: None,
            removed: Some(
                false,
            ),
        },
    ],
    status: Some(
        1,
    ),
    root: None,
    logs_bloom: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000080000000000000000000000000000000000000000000000000020000000000000000000000000000000000400000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000020020001000000000040000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000010000000000000000000000000000000001000000000000000000000000000,
    transaction_type: Some(
        2,
    ),
    effective_gas_price: Some(
        3189829117,
    ),
    other: OtherFields {
        inner: {},
    },
}
Error: Failed to quote swap from 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14 to 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984. Check that a pool exists for this pair.

Caused by:
    Invalid name: please ensure the contract and method you're calling exist! failed to decode empty bytes. if you're using jsonrpc this is likely due to jsonrpc returning `0x` in case contract or method don't exist
macbookproPau:uniswap-cli-0.5.0 pauperales$ cargo run -- -u https://ethereum-sepolia.blockpi.network/v1/rpc/public -n 11155111 -a 2000000000000000000 -s 1000000 -i 0xfFf9976782d46CC05630D1f6eBAb18b2

Maybe I'm using wrong Uniswap Router or Quoter addresses ->
const UNISWAP_V3_ROUTER_ADDRESS: &str = "0x3fC91A3afd70395Cd496C647d5a6CC9D4B2b7FAD";
const UNISWAP_V3_QUOTER_ADDRESS: &str = "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6";

@azerpas
Copy link
Owner

azerpas commented Aug 15, 2023

@DiMiTriFrog from their docs it says Uniswap contracts are deployed on Sepolia but I can't find the Quoter and Router adresses.

FYI I'm using Goerli for my tests which has the contracts deployed at the same addresses.

@DiMiTriFrog
Copy link
Author

@DiMiTriFrog from their docs it says Uniswap contracts are deployed on Sepolia but I can't find the Quoter and Router adresses.

FYI I'm using Goerli for my tests which has the contracts deployed at the same addresses.

I think i'm so near, but now i'm having this output:

Transaction Receipt: TransactionReceipt {
    transaction_hash: 0x4669005aa3b08a4ec315f890feb8dc45bb50c2e9caa274daab0159f50e2ee2c2,
    transaction_index: 2,
    block_hash: Some(
        0x601bbb0d94791c2c53d3954d57869fbe8591f24230b40e10a699a2cec6a45a5f,
    ),
    block_number: Some(
        9526800,
    ),
    from: 0x518766536b70187c48a99d2020725799dc3b8193,
    to: Some(
        0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6,
    ),
    cumulative_gas_used: 178554,
    gas_used: Some(
        26175,
    ),
    contract_address: None,
    logs: [
        Log {
            address: 0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6,
            topics: [
                0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925,
                0x000000000000000000000000518766536b70187c48a99d2020725799dc3b8193,
                0x0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad,
            ],
            data: Bytes(0x000000000000000000000000000000000000000000000000000001d1a94a2000),
            block_hash: Some(
                0x601bbb0d94791c2c53d3954d57869fbe8591f24230b40e10a699a2cec6a45a5f,
            ),
            block_number: Some(
                9526800,
            ),
            transaction_hash: Some(
                0x4669005aa3b08a4ec315f890feb8dc45bb50c2e9caa274daab0159f50e2ee2c2,
            ),
            transaction_index: Some(
                2,
            ),
            log_index: Some(
                5,
            ),
            transaction_log_index: None,
            log_type: None,
            removed: Some(
                false,
            ),
        },
    ],
    status: Some(
        1,
    ),
    root: None,
    logs_bloom: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000200000000000080400000000000000000000000000000000000000000000000020000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000001000000000040000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000001000000000000000000000000000,
    transaction_type: Some(
        2,
    ),
    effective_gas_price: Some(
        3000001396,
    ),
    other: OtherFields {
        inner: {},
    },
}
Will swap 10 for 196 tokens

Error: Contract call reverted with data: 0x

There is some. way to force to push the transaction to check it failure transaction on explorer?, like allow_revert

Thanks!

@azerpas
Copy link
Owner

azerpas commented Aug 16, 2023

@DiMiTriFrog please add the whole logs with the params used in the command. I suspect that the contract reverts because of insufficient funds. You should be able to see the error details easily with Alchemy RPC requests logs.

@DiMiTriFrog
Copy link
Author

@DiMiTriFrog please add the whole logs with the params used in the command. I suspect that the contract reverts because of insufficient funds. You should be able to see the error details easily with Alchemy RPC requests logs.

Here the full LOGS ->

cargo run -- -u https://eth-goerli.public.blastapi.io -n 5 -a 2000000000000 -s 10 -i 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6 -o 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 --verbose
   Compiling uniswap-cli v0.2.0 (/Users/UserName/Downloads/uniswap-cli-0.5.0)
warning: unused imports: `Locale`, `ToFormattedString`
 --> src/utils.rs:1:18
  |
1 | use num_format::{Locale, ToFormattedString};
  |                  ^^^^^^  ^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused variable: `approve_tx_gas`
   --> src/main.rs:122:13
    |
122 |         let approve_tx_gas = approve_tx.estimate_gas().await?;
    |             ^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_approve_tx_gas`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: variants `LOWEST`, `LOW`, and `HIGH` are never constructed
  --> src/main.rs:17:5
   |
16 | enum FeeAmount {
   |      --------- variants in this enum
17 |     LOWEST = 150,
   |     ^^^^^^
18 |     LOW = 500,
   |     ^^^
19 |     MEDIUM = 3000,
20 |     HIGH = 10000,
   |     ^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: `uniswap-cli` (bin "uniswap-cli") generated 3 warnings (run `cargo fix --bin "uniswap-cli"` to apply 2 suggestions)
    Finished dev [unoptimized + debuginfo] target(s) in 12.70s
     Running `target/debug/uniswap-cli -u 'https://eth-goerli.public.blastapi.io' -n 5 -a 2000000000000 -s 10 -i 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6 -o 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 --verbose`
Your password: 
💫 Welcome to the Uniswap V3 Swap CLI 💫
 We will use wallet with address: 0x5187…8193
Amount to approve specified. Approving 2000000000000 tokens.
Approved Uniswap V3 Router spending. Transaction Hash: 0x681415ed39277453a5aaf92836de4acef46d42c44d677192d4477d2e4b49c327
Transaction Receipt: TransactionReceipt {
    transaction_hash: 0x681415ed39277453a5aaf92836de4acef46d42c44d677192d4477d2e4b49c327,
    transaction_index: 9,
    block_hash: Some(
        0x2152d28cd87b00ae584871973f83f94884518c1acac91dc55e877b11281e2563,
    ),
    block_number: Some(
        9532215,
    ),
    from: 0x518766536b70187c48a99d2020725799dc3b8193,
    to: Some(
        0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6,
    ),
    cumulative_gas_used: 1813088,
    gas_used: Some(
        26175,
    ),
    contract_address: None,
    logs: [
        Log {
            address: 0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6,
            topics: [
                0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925,
                0x000000000000000000000000518766536b70187c48a99d2020725799dc3b8193,
                0x0000000000000000000000003fc91a3afd70395cd496c647d5a6cc9d4b2b7fad,
            ],
            data: Bytes(0x000000000000000000000000000000000000000000000000000001d1a94a2000),
            block_hash: Some(
                0x2152d28cd87b00ae584871973f83f94884518c1acac91dc55e877b11281e2563,
            ),
            block_number: Some(
                9532215,
            ),
            transaction_hash: Some(
                0x681415ed39277453a5aaf92836de4acef46d42c44d677192d4477d2e4b49c327,
            ),
            transaction_index: Some(
                9,
            ),
            log_index: Some(
                48,
            ),
            transaction_log_index: None,
            log_type: None,
            removed: Some(
                false,
            ),
        },
    ],
    status: Some(
        1,
    ),
    root: None,
    logs_bloom: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000200000000000080400000000000000000000000000000000000000000000000020000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000001000000000040000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000001000000000000000000000000000,
    transaction_type: Some(
        2,
    ),
    effective_gas_price: Some(
        3000000017,
    ),
    other: OtherFields {
        inner: {},
    },
}
Will swap 10 for 196 tokens

Error: Contract call reverted with data: 0x

And the Goerli address i'm using -> 0x518766536b70187c48a99d2020725799dc3b8193

@DiMiTriFrog
Copy link
Author

Could you show me an example with command that how to swap ETH to other contract in Goerli?

@DiMiTriFrog
Copy link
Author

I clean all packages and now is working, the command for goerli i'm using to swap WETH to UNI:

cargo run -- -u https://eth-goerli.public.blastapi.io -n 5 -a 1000000000000000000 -s 1000000000000000 -o 0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6 -i 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 --verbose

Thank you very much.

@azerpas
Copy link
Owner

azerpas commented Aug 21, 2023

Nice to know @DiMiTriFrog 😃

@azerpas azerpas added the good first issue Good for newcomers label Aug 22, 2023
@azerpas azerpas pinned this issue Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants