Skip to content

Commit

Permalink
Use env var for priority fees (#22)
Browse files Browse the repository at this point in the history
* Added a global variable for the microLamports.

* remove possible type error.

* microLamports variable

* use priority fee by default

* additional tx

* add fee explanation

---------

Co-authored-by: MarkSackerberg <[email protected]>
  • Loading branch information
FlueschPluesch and MarkSackerberg authored Apr 7, 2024
1 parent 0e40362 commit 90bde6d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ NEXT_PUBLIC_ENVIRONMENT=devnet
NEXT_PUBLIC_RPC=https://api.devnet.solana.com
NEXT_PUBLIC_BUYMARKBEER=true
#NEXT_PUBLIC_ENVIRONMENT=mainnet-beta
#NEXT_PUBLIC_RPC=https://solana-mainnet.rpc.extrnode.com
#NEXT_PUBLIC_RPC=https://solana-mainnet.rpc.extrnode.com
NEXT_PUBLIC_MICROLAMPORTS=1001
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ You can customize the UI by changing the code. If you just want to modify some v
- `image` is the main image that is shown. You could change it to your project logo.
- `headerText` is the website header. You could change it to your project name.
- Decide if you want to allow multiple mints by a single user at the same time and in your `.env` file set `NEXT_PUBLIC_MULTIMINT` accordingly to `true` or `false`. By default a maximum of 15 NFTs can be minted at the same time this is because of wallet limitations. If you want to have less change `NEXT_PUBLIC_MAXMINTAMOUNT` in `.env`.
- Change Priority fees if you want. By default it is set to the cheapest that is still considered to have priority fees. https://twitter.com/CloakdDev/status/1776661443330339285

### Fees
This ui has a buy me a beer feature. Each mint will transfer a very small amount (0.005) of SOL to a tip wallet. If you do not want to support me feel free to change the NEXT_PUBLIC_BUYMARKBEER variable to false. I would appreachiate it though if you leave it on. 🍻
Expand Down
8 changes: 4 additions & 4 deletions components/initializeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const createLut =
builder = builder.setBlockhash(latestBlockhash);

builder = builder.prepend(
setComputeUnitPrice(umi, { microLamports: 500 })
setComputeUnitPrice(umi, { microLamports: parseInt(process.env.NEXT_PUBLIC_MICROLAMPORTS ?? "1001") })
);
const requiredCu = await getRequiredCU(umi, builder.build(umi));
builder = builder.prepend(
Expand Down Expand Up @@ -125,7 +125,7 @@ const initializeGuards =
}
if (builder.items.length > 0) {
builder = builder.prepend(
setComputeUnitPrice(umi, { microLamports: 500 })
setComputeUnitPrice(umi, { microLamports: parseInt(process.env.NEXT_PUBLIC_MICROLAMPORTS ?? "1001") })
);
const latestBlockhash = (await umi.rpc.getLatestBlockhash()).blockhash;
builder = builder.setBlockhash(latestBlockhash);
Expand Down Expand Up @@ -167,7 +167,7 @@ const buyABeer = (umi: Umi, amount: string) => async () => {
amount: sol(Number(amount)),
})
);
builder = builder.prepend(setComputeUnitPrice(umi, { microLamports: 500 }));
builder = builder.prepend(setComputeUnitPrice(umi, { microLamports: parseInt(process.env.NEXT_PUBLIC_MICROLAMPORTS ?? "1001") }));
const latestBlockhash = (await umi.rpc.getLatestBlockhash()).blockhash;
builder = builder.setBlockhash(latestBlockhash);
const requiredCu = await getRequiredCU(umi, builder.build(umi));
Expand Down Expand Up @@ -296,4 +296,4 @@ export const InitializeModal = ({ umi, candyMachine, candyGuard }: Props) => {
</VStack>
</>
);
};
};
2 changes: 1 addition & 1 deletion utils/mintHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export const buildTx = (
);
}
tx = tx.prepend(setComputeUnitLimit(umi, { units }));
tx = tx.prepend(setComputeUnitPrice(umi, { microLamports: 500 }));
tx = tx.prepend(setComputeUnitPrice(umi, { microLamports: parseInt(process.env.NEXT_PUBLIC_MICROLAMPORTS ?? "1001") }));
tx = tx.setAddressLookupTables(luts);
tx = tx.setBlockhash(latestBlockhash);
return tx.build(umi);
Expand Down

0 comments on commit 90bde6d

Please sign in to comment.