-
Notifications
You must be signed in to change notification settings - Fork 56
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
Showing
2 changed files
with
56 additions
and
3 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
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,24 @@ | ||
use autonomi::{Bytes, Client, EvmNetwork, Wallet}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// Default wallet of testnet. | ||
let key = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"; | ||
Check failure Code scanning / devskim A token or key was found in source code. If this represents a secret, it should be moved somewhere else. Error
Do not store tokens or keys in source code.
|
||
|
||
let client = Client::connect(&["/ip4/127.0.0.1/udp/1234/quic-v1".parse()?]).await?; | ||
Check notice Code scanning / devskim Accessing localhost could indicate debug code, or could hinder scaling. Note
Do not leave debug code in production
|
||
let wallet = Wallet::new_from_private_key(EvmNetwork::ArbitrumSepolia, key)?; | ||
|
||
// Put and fetch data. | ||
let data_addr = client | ||
.data_put(Bytes::from("Hello, World"), wallet.clone().into()) | ||
.await?; | ||
let _data_fetched = client.data_get(data_addr).await?; | ||
|
||
// Put and fetch directory from local file system. | ||
let dir_addr = client.dir_upload("files/to/upload".into(), &wallet).await?; | ||
client | ||
.dir_download(dir_addr, "files/downloaded".into()) | ||
.await?; | ||
|
||
Ok(()) | ||
} |