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

General Question: Is there any example on submitting txs with priority fees? #166

Open
atulsriv opened this issue Jan 3, 2024 · 2 comments

Comments

@atulsriv
Copy link

atulsriv commented Jan 3, 2024

No description provided.

@atulsriv
Copy link
Author

atulsriv commented Jan 3, 2024

I'm looking to submit transactions with priority fees. I believe it should be included as a part of transaction opts in rpc/types.go, but not too familiar with the repo / solana in general. Any exmaples of people submitting txs with priority fees would be much appreciated?

@fgarciareyna
Copy link

fgarciareyna commented Mar 19, 2024

func CreateTx(ix solana.Instruction, feePayer solana.PublicKey, microlamports uint64) (*solana.Transaction, error) {
	feesInit := computebudget.NewSetComputeUnitPriceInstructionBuilder()
	feesInit.SetMicroLamports(microlamports)
	feesIx := feesInit.Build()

	result, err := rpc.New(rpc.MainNetBeta_RPC).GetRecentBlockhash(context.Background(), rpc.CommitmentFinalized)
	if err != nil {
		return nil, err
	}

	tx, err := solana.NewTransactionBuilder().
		AddInstruction(feesIx).
		AddInstruction(ix).
		SetRecentBlockHash(result.Value.Blockhash).
		SetFeePayer(feePayer).
		Build()
	if err != nil {
		return nil, err
	}

	return tx, nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants