mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-23 15:10:37 +00:00
localnet
This commit is contained in:
26
cli/Cargo.toml
Normal file
26
cli/Cargo.toml
Normal file
@@ -0,0 +1,26 @@
|
||||
[package]
|
||||
name = "ore-cli"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
homepage.workspace = true
|
||||
documentation.workspace = true
|
||||
repository.workspace = true
|
||||
keywords.workspace = true
|
||||
publish = false
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.22.1"
|
||||
bincode = "1.3.3"
|
||||
bytemuck = { workspace = true }
|
||||
ore-api = { path = "../api" }
|
||||
serde_json = "1.0.140"
|
||||
solana-client = { workspace = true }
|
||||
solana-sdk = { workspace = true }
|
||||
solana-program = { workspace = true }
|
||||
spl-associated-token-account.workspace = true
|
||||
tokio = { workspace = true }
|
||||
39
cli/src/main.rs
Normal file
39
cli/src/main.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use solana_client::nonblocking::rpc_client::RpcClient;
|
||||
use solana_sdk::{
|
||||
compute_budget::ComputeBudgetInstruction,
|
||||
signature::{read_keypair_file, Signer},
|
||||
transaction::Transaction,
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Read keypair from file
|
||||
let payer =
|
||||
read_keypair_file(&std::env::var("KEYPAIR").expect("Missing KEYPAIR env var")).unwrap();
|
||||
|
||||
// Build transaction
|
||||
let rpc = RpcClient::new(std::env::var("RPC").expect("Missing RPC env var"));
|
||||
let cu_budget_ix = ComputeBudgetInstruction::set_compute_unit_limit(1_400_000);
|
||||
let ix = match std::env::var("COMMAND")
|
||||
.expect("Missing COMMAND env var")
|
||||
.as_str()
|
||||
{
|
||||
"initialize" => ore_api::sdk::initialize(payer.pubkey()),
|
||||
// "payout" => ore_api::sdk::payout(payer.pubkey()),
|
||||
// "reset" => ore_api::sdk::reset(payer.pubkey()),
|
||||
_ => panic!("Invalid command"),
|
||||
};
|
||||
let blockhash = rpc.get_latest_blockhash().await.unwrap();
|
||||
let transaction = Transaction::new_signed_with_payer(
|
||||
&[cu_budget_ix, ix],
|
||||
Some(&payer.pubkey()),
|
||||
&[&payer],
|
||||
blockhash,
|
||||
);
|
||||
|
||||
// Send transaction
|
||||
match rpc.send_and_confirm_transaction(&transaction).await {
|
||||
Ok(signature) => println!("Transaction succeeded! Signature: {}", signature),
|
||||
Err(err) => println!("Transaction failed: {}", err),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user