Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias outputs doc #1153

Merged
merged 23 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b8a8cf0
added docs for alias output. [wip] output pending.
anistark Sep 4, 2023
dbaaac9
outputs updated
anistark Sep 4, 2023
c7330a4
Fix broken urls
Dr-Electron Sep 4, 2023
64e9078
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/create.mdx
anistark Sep 6, 2023
d18c353
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/create.mdx
anistark Sep 6, 2023
b073e51
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/create.mdx
anistark Sep 6, 2023
78336e1
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/create.mdx
anistark Sep 6, 2023
d9b56d4
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/create.mdx
anistark Sep 6, 2023
7dc068b
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/destroy.mdx
anistark Sep 6, 2023
cd29f82
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/destroy.mdx
anistark Sep 6, 2023
38b78d8
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/destroy.mdx
anistark Sep 6, 2023
57d397a
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/destroy.mdx
anistark Sep 6, 2023
0ef14d6
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/destroy.mdx
anistark Sep 6, 2023
2a90b02
updated outputs to match all. except python
anistark Sep 12, 2023
7cbc022
Merge branch 'alias-output-doc' of github.com:iotaledger/iota-wiki in…
anistark Sep 12, 2023
e36bd91
Transaction -> Block
anistark Sep 12, 2023
0e69e84
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/destroy.mdx
anistark Sep 18, 2023
4af1213
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/create.mdx
anistark Sep 18, 2023
b117cee
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/create.mdx
anistark Sep 18, 2023
336ac38
Update docs/build/iota-sdk/1.0.0/docs/how-tos/alias/create.mdx
anistark Sep 18, 2023
37a39f8
Update destroy.mdx
anistark Sep 18, 2023
3841c82
Merge branch 'main' into alias-output-doc
luca-moser Sep 26, 2023
7c8c07e
moves files into appropriate folder
luca-moser Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions docs/build/iota-sdk/1.0.0/docs/how-tos/alias/create.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
title: Create Alias Output
description: 'How to programmatically create an alias output'
image: /img/logo/iota_mark_light.png
keywords:
- how to
- create
- alias
- output
- nodejs
- python
- rust
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

An [Alias Output](https://wiki.iota.org/tips/tips/TIP-0018/#alias-output) is a specific implementation of a UTXO state machine. The Alias ID, the unique identifier of an instance of the deployed state machine, is generated deterministically by the protocol and is not allowed to change in future state transitions.

An Alias Output represents an alias account in the ledger with two control levels and a permanent Alias Address. The account owns other outputs that are locked under the Alias Address. The account keeps track of state transitions (`State Index` counter) and controlled foundries (`Foundry Counter`) and anchors the layer 2 state as metadata into the UTXO ledger.

## Example Code

<Tabs groupId="language" queryString>
<TabItem value="rust" label="Rust">

The following example will:

1. Instantiate a [`Wallet`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/core/struct.Wallet.html), get Alice's `Account` which was
[created in the first guide](../accounts-and-addresses/create-account.mdx).
2. Create an Alias Output transaction by calling the [`Account.create_alias_output()`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/account/struct.CreateAliasParams.html) function.

<div className={'hide-code-block-extras'}>

```rust reference
https://github.com/iotaledger/iota-sdk/blob/develop/sdk/examples/how_tos/alias/create.rs#L40
```

</div>

3. Retry the [`Transaction`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/account/struct.Account.html#method.retry_transaction_until_included) until included.

<div className={'hide-code-block-extras'}>

```rust reference
https://github.com/iotaledger/iota-sdk/blob/develop/sdk/examples/how_tos/alias/create.rs#L43-L45
```

</div>

</TabItem>
<TabItem value="typescript-node" label="Typescript (Node.js)">

The following example will:

1. Instantiate a [`Wallet`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/core/struct.Wallet.html), get Alice's `Account` which was
[created in the first guide](../accounts-and-addresses/create-account.mdx) and [sync it](../accounts-and-addresses/check-balance.mdx).
2. Create an Alias Output transaction by calling the [`Account.prepareCreateAliasOutput()`](../../references/nodejs/classes/Account.md#preparecreatealiasoutput) function, and then [send](../../references/nodejs/classes/Account.md#send) it.

<div className={'hide-code-block-extras'}>

```typescript reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/how_tos/alias/create.ts#L53-L55
```

</div>

3. Retry transaction until included [`Transaction`](../../references/nodejs/classes/Account.md#retrytransactionuntilincluded) that was sent.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. Retry transaction until included [`Transaction`](../../references/nodejs/classes/Account.md#retrytransactionuntilincluded) that was sent.
3. Retry the [`Transaction`](../../references/nodejs/classes/Account.md#retrytransactionuntilincluded) until included.


<div className={'hide-code-block-extras'}>

```typescript reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/how_tos/alias/create.ts#L60
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/how_tos/alias/create.ts#L60
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/how_tos/alias/create.ts#L60-L62

```

</div>

</TabItem>
<TabItem value="python" label="Python">

1. Instantiate a [`Wallet`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/core/struct.Wallet.html), get Alice's `Account` which was
[created in the first guide](../accounts-and-addresses/create-account.mdx) and [sync it](../accounts-and-addresses/check-balance.mdx).
2. Prepare an Alias Output transaction by calling the [`Account.prepare_create_alias_output()`](../../references/python/iota_sdk/wallet/account.md#prepare_create_alias_output) function, and then [send](../../references/python/iota_sdk/wallet/account.md#send) it.

<div className={'hide-code-block-extras'}>

```python reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/python/examples/how_tos/alias/create.py#L22
```

</div>

</TabItem>
</Tabs>

### Full Example Code

<Tabs groupId="language" queryString>
<TabItem value="rust" label="Rust">

```rust reference
https://github.com/iotaledger/iota-sdk/blob/develop/sdk/examples/how_tos/alias_wallet/request_funds.rs
```

</TabItem>
<TabItem value="typescript-node" label="Typescript (Node.js)">

```typescript reference
https://github.com/iotaledger/iota-sdk/blob/develop/sdk/examples/how_tos/alias/create.rs
```

</TabItem>
<TabItem value="python" label="Python">

```python reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/python/examples/how_tos/alias/create.py
```

</TabItem>
</Tabs>

### Expected Output

```plaintext
Aliases BEFORE:
[
...
]
Sending the create-alias transaction...
Transaction sent: 0x7ce05ab09bc562c7b383067b774edd780e3a9235e9c76a5cccabdd9744b6a719
Block included: https://explorer.shimmer.network/testnet/block/0x603c0e010b4e7665913c04729aad692a1c7557234185e98c821e1142fa49823d
Aliases AFTER:
[
...
]
```
135 changes: 135 additions & 0 deletions docs/build/iota-sdk/1.0.0/docs/how-tos/alias/destroy.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
title: Destroy Alias Output
description: 'How to programmatically destroy an alias output'
image: /img/logo/iota_mark_light.png
keywords:
- how to
- destroy
- alias
- output
- nodejs
- python
- rust
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

You can destroy an alias output by ID.

## Example Code

<Tabs groupId="language" queryString>
<TabItem value="rust" label="Rust">

The following example will:

1. Instantiate a [`Wallet`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/core/struct.Wallet.html), get Alice's `Account` which was
[created in the first guide](../accounts-and-addresses/create-account.mdx).
2. Destroy an Alias Output transaction by calling the [`Account.burn()`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/account/struct.Account.html#method.burn) function.

<div className={'hide-code-block-extras'}>

```rust reference
https://github.com/iotaledger/iota-sdk/blob/develop/sdk/examples/how_tos/alias/destroy.rs#L44
```

</div>

3. Retry the [`Transaction`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/account/struct.Account.html#method.retry_transaction_until_included) until included.

<div className={'hide-code-block-extras'}>

```rust reference
https://github.com/iotaledger/iota-sdk/blob/develop/sdk/examples/how_tos/alias/destroy.rs#L47-L49
```

</div>

</TabItem>
<TabItem value="typescript-node" label="Typescript (Node.js)">

The following example will:

1. Instantiate a [`Wallet`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/core/struct.Wallet.html), get Alice's `Account` which was
[created in the first guide](../accounts-and-addresses/create-account.mdx) and [sync it](../accounts-and-addresses/check-balance.mdx).
2. Prepare the transaction to destroy an Alias Output by calling the [`Account.preparedestroyalias()`](../../references/nodejs/classes/Account.md#preparedestroyalias) function, and then [send](../../references/nodejs/classes/Account.md#send) it.

<div className={'hide-code-block-extras'}>

```typescript reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/how_tos/alias/destroy.ts#L56-L58
```

</div>

3. Retry transaction until included [`Transaction`](../../references/nodejs/classes/Account.md#retrytransactionuntilincluded) that was sent.

<div className={'hide-code-block-extras'}>

```typescript reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/nodejs/examples/how_tos/alias/destroy.ts#L63
```

</div>

</TabItem>
<TabItem value="python" label="Python">

1. Instantiate a [`Wallet`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/core/struct.Wallet.html), get Alice's `Account` which was
[created in the first guide](../accounts-and-addresses/create-account.mdx) and [sync it](../accounts-and-addresses/check-balance.mdx).
2. Destroy the transaction that will destroy the alias output by calling the [`Account.prepare_destroy_alias()`](../../references/python/iota_sdk/wallet/account.md#prepare_destroy_alias) function, and then [send](../../references/python/iota_sdk/wallet/account.md#send) it.

<div className={'hide-code-block-extras'}>

```python reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/python/examples/how_tos/alias/destroy.py#L25
```

</div>

</TabItem>
</Tabs>

### Full Example Code

<Tabs groupId="language" queryString>
<TabItem value="rust" label="Rust">

```rust reference
https://github.com/iotaledger/iota-sdk/blob/develop/sdk/examples/how_tos/alias_wallet/destroy.rs
```

</TabItem>
<TabItem value="typescript-node" label="Typescript (Node.js)">

```typescript reference
https://github.com/iotaledger/iota-sdk/blob/develop/sdk/examples/how_tos/alias/destroy.rs
```

</TabItem>
<TabItem value="python" label="Python">

```python reference
https://github.com/iotaledger/iota-sdk/blob/develop/bindings/python/examples/how_tos/alias/destroy.py
```

</TabItem>
</Tabs>

### Expected Output

```plaintext
Aliases BEFORE destroying (142):
[
...
]
Sending the destroy-alias transaction...
Transaction sent: 0x829a635a7edc28bee4d4a1019b7b1f1bedec11d83c118b6f2a7904590f4bb458
Block included: https://explorer.shimmer.network/testnet/block/0xd455b8132c0b109dd0b2d1d157c6b1d7275318f69dcf56f536a7b14d9fa17bb3
Destroyed alias 0xf708a29e9619e847916de76c2e167e87a704c235dcbd7cda018865be7f561b5a
Aliases AFTER destroying (141):
[
...
]
```
10 changes: 10 additions & 0 deletions docs/build/iota-sdk/1.0/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ module.exports = {
},
],
},
{
type: 'category',
label: 'Alias Outputs',
items: [
{
type: 'autogenerated',
dirName: 'how-tos/alias',
},
],
},
{
type: 'category',
label: 'Advanced Transactions',
Expand Down
Loading