0

Can I set gas price in internal transactions, of my functions? For example:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

interface Itest {
     function sendToken(address to) external;
}

contract TestContract {

    Itest _Itest;

    constructor(address add) {
        _Itest = Itest(add);
    }

    function sendTokens(address to1, address to2) external {
        _Itest.sendToken(to1);
        _Itest.sendToken(to2);
}
    
}

I call function sendTokens(address to1, address to2), which sent tokens on two addresses, with the help of Interface of another contract. I want to manipulate the gas price of this internal transactions.

Can I do this?

Thanks!!

1
  • I am not sure I understand your answer correctly. Can you tell me what do you meant by manipulating gas prices?
    – Ad-h0c
    Sep 26, 2022 at 4:20

2 Answers 2

3

You cannot set/update the gas price inside your transaction. The gas price is determined by the one signing and thus initializing the transaction.

1
  • and if I want to swap some tokens in DeFi (uniswap, pancakeswap) from the code in one function, will all of them have one gas price, which I chose in call of function?
    – dimokrit
    Sep 27, 2022 at 13:30
0

The gas price is determined by the market, not by the contract.

Your Answer

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

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