Skip to content

Commit

Permalink
Add calc-account-ret-fee package with Solana dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
DaviRain-Su committed Aug 2, 2023
1 parent 36a4d14 commit 4302a85
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions code/account/calc-account-ret-fee/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "calc-account-ret-fee"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
solana-client = "1.16.6"
solana-sdk = "1.16.6"
18 changes: 18 additions & 0 deletions code/account/calc-account-ret-fee/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 计算账户费用
// 在Solana上保持账户活跃会产生一项存储费用,称为 租金/rent。
// 通过存入至少两年租金的金额,你可以使账户完全免除租金收取。
// 对于费用的计算,你需要考虑你打算在账户中存储的数据量。
use solana_client::rpc_client::RpcClient;
use solana_sdk::commitment_config::CommitmentConfig;

fn main() {
let rpc_url = String::from("http://127.0.0.1:8899");
let connection = RpcClient::new_with_commitment(rpc_url, CommitmentConfig::confirmed());
let data_length = 1500;

let rent_exemption_amount = connection
.get_minimum_balance_for_rent_exemption(data_length)
.unwrap();

println!("rent exemption amount: {}", rent_exemption_amount);
}

0 comments on commit 4302a85

Please sign in to comment.