Alias Wallet Transaction
Once you have requested funds from the faucet you are ready to send your first transaction from an alias account.
Alias or NFT as wallet
Although this How-To shows how to use an Alias as wallet, the same code can be applied for NFTs with minor changes
Online Faucet
You can request test funds from the Testnet Faucet.
Example Code
- Rust
- Typescript (Node.js)
- Python
The following example will:
- Instantiate a
Wallet, get Alice'sAccountwhich was created in the first guide. - Sync the account with the node to get the latest transactions by calling the
Account.sync()function. Note how theSyncOptionsfor the Alias setAliasSyncOptions.basicOutputstotrue.
- Retrieve the Alias Id of the first
AliasOutputrelated to Alice's account.
- Retrieve the Alias' address using the
Client.alias_id_to_bech32()function.
- Send 1 SMR to an address using the
Account.send()function. Make sure to update the code sample to send to the address of your choice.
The following example will:
- Instantiate a
Wallet, get Alice'sAccountwhich was created in the first guide. - Sync the account with the node to get the latest transactions by calling the
Account.sync()function. Note how theSyncOptionsfor the Alias setAliasSyncOptions.basicOutputstotrue.
- Retrieve the Alias Id of the first
AliasOutputrelated to Alice's account.
- Retrieve the Alias' address using the
Utils.aliasIdToBech32()function.
- Define the inputs for the transaction as the first Output that can be unlocked by the Alias address.
- Send 1 SMR to an address using the
Account.sendWithParams()function. Make sure to update the code sample to send to the address of your choice.
The following example will:
- Instantiate a
Wallet, get Alice'sAccountwhich was created in the first guide. - Sync the account with the node to get the latest transactions by calling the
Account.sync()function. Note how thesync_optionsfor the Alias setAliasSyncOptions.basic_outputstotrue.
- Retrieve the Alias Id of the first
AliasOutputrelated to Alice's account.
- Retrieve the
AliasAddressusing theUtils.alias_id_to_bech32()function.
- Define the inputs for the transaction as the first Output that can be unlocked by the Alias address.
- Send 1 SMR to an address using the
Account.send_with_params()function. Make sure to update the code sample to send to the address of your choice.
Full Example Code
- Rust
- Typescript (Node.js)
- Python
sdk/examples/how_tos/alias_wallet/transaction.rs
loading...
bindings/nodejs/examples/how_tos/alias_wallet/transaction.ts
loading...
bindings/python/examples/how_tos/alias_wallet/transaction.py
loading...
Expected Output
Balance before sending funds from alias: 2000000000
Alias Id: 0x81df8f7e1ad625befebf1456cd0775a124b47a274061010e080bbf7c18593acc
Transaction with custom input: https://explorer.shimmer.network/testnet/transaction/0x0f2f72e09a3a9f9fc8cd1fd4e196c2d198580ec9c873efcf5d6d99809bd9e8f7
Balance after sending funds from alias: 1999000000