-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Merged Stronghold with basic examples in account * Updated explorer to identity resolver * Added explorer URL after basic example * Renamed examples * Completed manipulate did example * Fixed suggestions, removed replaced examples. * Improved example readme * Consistently use Stronghold and Resolver URL * Fix examples * Merged config example with private tangle * low-level-api private-network example runs * cargo fmt * cargo fmt with nightly * Impl suggestions
- Loading branch information
1 parent
e339286
commit a7cfab4
Showing
15 changed files
with
274 additions
and
340 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
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 was deleted.
Oops, something went wrong.
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,52 @@ | ||
// Copyright 2020-2021 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//! cargo run --example account_create | ||
use std::path::PathBuf; | ||
|
||
use identity::account::Account; | ||
use identity::account::AccountStorage; | ||
use identity::account::IdentityCreate; | ||
use identity::account::IdentityState; | ||
use identity::account::Result; | ||
use identity::iota::IotaDID; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
pretty_env_logger::init(); | ||
|
||
// Sets the location and password for the Stronghold | ||
// | ||
// Stronghold is an encrypted file that manages private keys. | ||
// It implements best practices for security and is the recommended way of handling private keys. | ||
let stronghold_path: PathBuf = "./example-strong.hodl".into(); | ||
let password: String = "my-password".into(); | ||
|
||
// Create a new Account with the default configuration | ||
let account: Account = Account::builder() | ||
.storage(AccountStorage::Stronghold(stronghold_path, Some(password))) | ||
.build() | ||
.await?; | ||
|
||
// Create a new Identity with default settings | ||
// | ||
// This step generates a keypair, creates an identity and publishes it to the IOTA mainnet. | ||
let identity: IdentityState = account.create_identity(IdentityCreate::default()).await?; | ||
let iota_did: &IotaDID = identity.try_did()?; | ||
|
||
// Print the local state of the DID Document | ||
println!( | ||
"[Example] Local Document from {} = {:#?}", | ||
iota_did, | ||
identity.to_document() | ||
); | ||
|
||
// Prints the Identity Resolver Explorer URL, the entire history can be observed on this page by "Loading History". | ||
println!( | ||
"[Example] Explore the DID Document = {}/{}", | ||
iota_did.network()?.explorer_url().unwrap().to_string(), | ||
iota_did.to_string() | ||
); | ||
Ok(()) | ||
} |
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
Oops, something went wrong.