-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9521ad1
commit 983508b
Showing
2 changed files
with
42 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
PublicKey, | ||
SystemProgram, | ||
ComputeBudgetInstruction, | ||
ComputeBudgetProgram, | ||
} from "@solana/web3.js"; | ||
import { ledgerSignAndSend } from "./helpers"; | ||
import { connection, getSigner, getEnv } from "./env"; | ||
type Config = { | ||
to: PublicKey; | ||
amount: bigint; // lamports | ||
}; | ||
|
||
(async () => { | ||
const config: Config = { | ||
to: new PublicKey(getEnv("TO")), | ||
amount: BigInt(getEnv("AMOUNT")), | ||
}; | ||
|
||
const signer = await getSigner(); | ||
const signerPk = new PublicKey(await signer.getAddress()); | ||
|
||
const transferIx = SystemProgram.transfer({ | ||
fromPubkey: signerPk, | ||
toPubkey: config.to, | ||
lamports: config.amount, | ||
}); | ||
|
||
const setComputePriceIx = ComputeBudgetProgram.setComputeUnitPrice({ | ||
microLamports: 1_200_000, | ||
}); | ||
|
||
console.log(`Transferring ${config.amount} lamports to ${config.to.toBase58()}`); | ||
const result = await ledgerSignAndSend([setComputePriceIx, transferIx], []); | ||
console.log("Tx Sent: ", result); | ||
const txIncluded = await connection.confirmTransaction(result); | ||
console.log("Tx Included"); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters