michaelhly / solana-py

Solana Python SDK
https://michaelhly.github.io/solana-py
MIT License
981 stars 252 forks source link

How to set higher fee for transactions #377

Closed Tongoko closed 9 months ago

Tongoko commented 9 months ago

Hello! Is it possile to set custom fees for transactions? All of the transactions seem to be using the default fee of 0.000005 SOL, but how could I change it to a higher amount? Thanks

michaelhly commented 9 months ago

~~We need to port this program over: https://solana-labs.github.io/solana-web3.js/classes/ComputeBudgetProgram.html~~

kevinheavey commented 9 months ago

No need to port it, Solders already has it.

>>> from solders.compute_budget import set_compute_unit_limit
>>> set_compute_unit_limit(1_000_000)
Instruction(
    Instruction {
        program_id: ComputeBudget111111111111111111111111111111,
        accounts: [],
        data: [
            2,
            64,
            66,
            15,
            0,
        ],
    },
)

So just include a compute budget instruction in your transaction message

fedllanes commented 6 months ago

No need to port it, Solders already has it.

>>> from solders.compute_budget import set_compute_unit_limit
>>> set_compute_unit_limit(1_000_000)
Instruction(
    Instruction {
        program_id: ComputeBudget111111111111111111111111111111,
        accounts: [],
        data: [
            2,
            64,
            66,
            15,
            0,
        ],
    },
)

So just include a compute budget instruction in your transaction message

If i want to do token transfer, how can i add this to the code?

result = usdc_token.transfer(sender_token_address, receiver_token_address, sender, balance)