Prepare Your Development Environment
To run the code in this tutorial, you will need the following:
The
@iota/iota.js
libraryThe
iota.js
auxiliary libraries:@iota/crypto.js
@iota/util.js
.@iota/pow-neon.js
to run Proof of Work (PoW). Alternatively, you can spin up your own node to run the PoW remotely.
Access to a Stardust Node (Hornet 2.0.0). You can use the Shimmer testnet Nodes at https://api.testnet.shimmer.network.
(Optional) A TypeScript compiler and related packages
(optional) Download the Code
You can download the tutorials codebase to follow while you read the next sections.
If you plan on using the provided code example, please read the article How To Run Code Examples.
The tutorial's codebase uses several predefined Shimmer addresses and outputs. If you are going to use other addresses, you will need to update the code accordingly. Likewise, the tutorial codebase assumes a particular state of the addresses and outputs. Before executing the code, please ensure your addresses and outputs are in the expected state.
Available Commands
Mint Alias Output
You can run the mint-new-alias
script by running the following command from the example's directory:
npm run mint <outputID>
Where outputID
is the ID of an Output that has enough funds to cover the storage deposit of your newly minted Alias.
Transition Alias Output
You can run the alias-transaction
script by running the following command from the example's directory:
npm run alias-transaction <AliasID>
Where AliasID
is the Alias ID you want to transact with so that it transitions to a new state.
Create Your package.json File
You can create your package.json
file from the example below and place it in your projects base directory:
{
"name": "tutorial-alias",
"version": "1.0.0",
"scripts": {
"dist": "tsc",
"mint": "node dist/mint-new-alias",
"alias-transaction": "node dist/alias-transaction"
},
"dependencies": {
"@iota/crypto.js": "2.0.0-rc.1",
"@iota/iota.js": "2.0.0-rc.2",
"@iota/util.js": "2.0.0-rc.1",
"@iota/pow-neon.js": "2.0.0-rc.2"
},
"devDependencies": {
"typescript": "^4.4.3",
"@types/node": "18.7.23"
}
}
After you have created the package.json
file, you can install all the necessary dependencies by running the following
command from the same directory:
npm install
Troubleshooting
If you are getting any errors during the installation process please make sure your system is using Node.js 16. You can check your node version by running the following command:
node -v