Crates.io | near-accounts |
lib.rs | near-accounts |
version | 0.1.0-alpha |
source | src |
created_at | 2024-03-20 09:57:18.365197 |
updated_at | 2024-03-20 09:57:18.365197 |
description | Simplify interaction with NEAR Protocol accounts. High-level abstractions for managing accounts, deploying contracts, and executing transactions on the NEAR blockchain. |
homepage | |
repository | |
max_upload_size | |
id | 1180280 |
size | 218,399 |
The near-accounts
is a Rust crate designed to simplify interaction with NEAR Protocol accounts. Building upon the lower-level near-transactions
and near-providers
crate, it provides developers with high-level abstractions for managing accounts, deploying contracts, and executing transactions on the NEAR blockchain.
Account Management: Create and delete NEAR Protocol accounts.
Access Key Management: Add and delete access keys for accounts.
Contract Deployment: Deploy and call smart contracts.
Transaction Handling: Send NEAR and call contract functions with customizable gas and attached deposit.
Querying Blockchain State: View account details, contract state, and call view functions on contracts.
Asynchronous API: All network interactions are asynchronous, leveraging tokio for efficient concurrency.
Builder Pattern: Utilizes TransactionBuilder for a flexible and error-resistant way to construct transactions.
near-accounts
to Your CrateTo use near-accounts
in your project, add the following to your Cargo.toml:
[dependencies]
near-accounts = "0.1.0-alpha"
Ensure you have tokio
and other dependencies set up in your project for asynchronous runtime.
Look at deploy_contract.rs
example in the examples directory.
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
let signer_account_id: AccountId = utils::input("Enter the signer Account ID: ")?.parse()?;
let signer_secret_key = utils::input("Enter the signer's private key: ")?.parse()?;
let signer = InMemorySigner::from_secret_key(signer_account_id.clone(), signer_secret_key);
let signer = Arc::new(signer);
let provider = Arc::new(JsonRpcProvider::new("https://rpc.testnet.near.org"));
let account = Account::new(signer_account_id, signer, provider);
let wasm_code = read_wasm_file()?;
let result = account.deploy_contract(wasm_code).await;
println!("response: {:#?}", result);
Ok(())
}
The crate includes examples that demonstrate how to use various features. To run an example, use the following command:
cargo run --example <example_name>
For instance, to test the create_account
function:
cargo run --example create_subaccount
We welcome contributions to the near-accounts
crate! Please feel free to submit pull requests or open issues to suggest improvements or add new features.