Skip to content

Commit

Permalink
added docs for alias output. [wip] output pending.
Browse files Browse the repository at this point in the history
  • Loading branch information
anistark committed Sep 4, 2023
1 parent eff881d commit b8a8cf0
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 0 deletions.
126 changes: 126 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,126 @@
---
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';

The Alias Output is a specific implementation of a UTXO state machine. 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 any future state transitions.

Alias Output represents an alias account in the ledger with two control levels and a permanentAlias Address. The account owns other outputs that are locked under Alias Address. The account keeps track of state transitions (`State Index` counter), 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 transaction until included [`Transaction`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/account/struct.Account.html#method.retry_transaction_until_included) that was sent.

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

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

</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.

<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
```

</div>

3. Retry transaction until included [`Transaction`](../../references/nodejs/classes/Account/#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/create.ts#L60
```

</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. Create an alias output transaction by calling the [`Account.prepareCreateAliasOutput()`](../../references/python/iota_sdk/wallet/account.md#prepare_create_alias_output) function.

<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
...
```
124 changes: 124 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,124 @@
---
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. If the alias still owns any outputs when you try to destroy it, you will get an error.

## 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 transaction until included [`Transaction`](https://docs.rs/iota-sdk/latest/iota_sdk/wallet/account/struct.Account.html#method.retry_transaction_until_included) that was sent.

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

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

</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. Destroy an alias output transaction by calling the [`Account.preparedestroyalias()`](../../references/nodejs/classes/Account.md#preparedestroyalias) function.

<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
```

</div>

3. Retry transaction until included [`Transaction`](../../references/nodejs/classes/Account/#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 an alias output transaction by calling the [`Account.prepare_destroy_alias()`](../../references/python/iota_sdk/wallet/account.md#prepare_destroy_alias) function.

<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
...
```
10 changes: 10 additions & 0 deletions docs/build/iota-sdk/1.0.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

0 comments on commit b8a8cf0

Please sign in to comment.