forked from iotaledger/identity.rs
-
Notifications
You must be signed in to change notification settings - Fork 0
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
19 additions
and
15 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 |
---|---|---|
@@ -1,25 +1,30 @@ | ||
use identity::iota::Client; | ||
use identity::iota::IotaDocument; | ||
use identity::crypto::KeyPair; | ||
// Copyright 2020-2021 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use identity::crypto::KeyPair; | ||
use identity::iota::Client; | ||
use identity::iota::Document; | ||
use identity::iota::Network; | ||
use identity::iota::Result; | ||
|
||
use identity::iota::TangleRef; | ||
|
||
#[smol_potat::main] | ||
async fn main() -> Result<()> { | ||
let client: Client = Client::new()?; | ||
|
||
let (mut document, keypair): (IotaDocument, KeyPair) = IotaDocument::builder() | ||
.authentication_tag("key-1") | ||
.did_network(client.network().as_str()) | ||
.build()?; | ||
let keypair: KeyPair = KeyPair::new_ed25519()?; | ||
let mut document: Document = Document::from_keypair(&keypair)?; | ||
|
||
// Sign the DID Document with the default authentication key. | ||
document.sign(keypair.secret())?; | ||
|
||
// Use the client to publish the DID Document to the Tangle. | ||
let transaction: _ = client.publish_document(&document).await?; | ||
println!("DID Document Transaction > {}", client.transaction_url(&transaction)); | ||
document.publish(&client).await?; | ||
|
||
let network: Network = document.id().into(); | ||
let explore: String = format!("{}/transaction/{}", network.explorer_url(), document.message_id()); | ||
|
||
println!("DID Document Transaction > {}", explore); | ||
|
||
Ok(()) | ||
} |