@twin.org/nft-cli 0.0.1-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,141 @@
1
+ # @twin.org/nft-cli - Examples
2
+
3
+ ## Command Line Tool
4
+
5
+ First install the tool with the following script.
6
+
7
+ ```shell
8
+ npm install @twin.org/nft-cli
9
+ ```
10
+
11
+ Running the tool with no commands will provide help for all the commands. By issuing the following command you should see the result.
12
+
13
+ ```shell
14
+ twin-nft
15
+ ```
16
+
17
+ Output
18
+
19
+ ```shell
20
+ 🌍 TWIN NFT v1.0.0
21
+
22
+ Usage: twin-nft [command]
23
+
24
+ Options:
25
+ -V, --version output the version number
26
+ --lang <lang> The language to display the output in. (default: "en")
27
+ --load-env [env...] Load the env files to initialise any environment variables.
28
+ -h, --help display help for command
29
+
30
+ Commands:
31
+ mnemonic [options] Create a mnemonic.
32
+ address [options] Create bech32 addresses and keys from the seed.
33
+ faucet [options] Request funds from the faucet.
34
+ nft-mint [options] Mint an NFT.
35
+ nft-resolve [options] Resolve an NFT.
36
+ nft-burn [options] Burn an NFT.
37
+ nft-transfer [options] Transfer an NFT.
38
+ ```
39
+
40
+ You can get further details on the sub commands by using the help option for the individual commands.
41
+
42
+ ```shell
43
+ twin-nft nft-mint --help
44
+ ```
45
+
46
+ Output
47
+
48
+ ```shell
49
+ 🌍 TWIN NFT v1.0.0
50
+
51
+ Usage: twin-nft nft-mint [options]
52
+
53
+ Mint an NFT.
54
+
55
+ Options:
56
+ --seed <seed> The seed for the issuer address in hex or base64 used to fund the minting, or start with ! to read environment variable.
57
+ --issuer <issuer> The bech32 address of the NFT issuer, or start with ! to read environment variable.
58
+ --tag <tag> The tag for the NFT.
59
+ --immutable-json <immutable-json> A JSON file to read which includes the immutable data for the NFT.
60
+ --mutable-json <mutable-json> A JSON file to read which includes the mutable data for the NFT.
61
+ --no-console Hides the output in the console.
62
+ --json <filename> Creates a JSON file containing the output.
63
+ --merge-json If the JSON file already exists merge the data instead of overwriting.
64
+ --env <filename> Creates an env file containing the output.
65
+ --merge-env If the env file already exists merge the data instead of overwriting.
66
+ --node <url> The url for the node endpoint, or an environment variable name containing the url. (default: "!NODE_URL")
67
+ --explorer <url> The url for the explorer endpoint, or an environment variable name containing the url. (default: "!EXPLORER_URL")
68
+ -h, --help display help for command
69
+ ```
70
+
71
+ The commands `mnemonic`, `address` and `faucet` are described in more detail in the examples for `crypto-cli` and `wallet-cli`.
72
+
73
+ ## Command
74
+
75
+ ### nft-mint
76
+
77
+ Use this command to mint a new NFT, the issuer address must have sufficient funds to store the NFT. The seed and the funds can be generated using the `mnemonic` and `faucet` commands.
78
+
79
+ ```shell
80
+ # Generate a seed and mnemonic and store it in the env file
81
+ twin-nft mnemonic --env wallet.env
82
+ # Generate an address and store it in the env file
83
+ twin-nft address --load-env wallet.env --hrp tst --seed !SEED --count 4 --env wallet.env --merge-env
84
+ ```
85
+
86
+ To run this on the IOTA testnet you will need an env file with the following settings. Store the following config as config.env
87
+
88
+ ```shell
89
+ NODE_URL="https://api.testnet.iotaledger.net"
90
+ FAUCET_URL="https://faucet.testnet.iotaledger.net/api/enqueue"
91
+ EXPLORER_URL="https://explorer.iota.org/iota-testnet/"
92
+ ```
93
+
94
+ We also need to create a JSON file containing the immutable metadata for the NFT. The following JSON file follows the IRC27 standard for NFT data. Save this file as `immutable.json` to use in the following scripts.
95
+
96
+ ```json
97
+ {
98
+ "standard": "IRC27",
99
+ "version": "v1.0",
100
+ "type": "video/mp4",
101
+ "uri": "https://ipfs.io/ipfs/QmPoYcVm9fx47YXNTkhpMEYSxCD3Bqh7PJYr7eo5YjLgiT",
102
+ "name": "Test NFT",
103
+ "collectionName": "Test Collection",
104
+ "issuerName": "Test Issuer",
105
+ "description": "This is a test NFT."
106
+ }
107
+ ```
108
+
109
+ To request some funds and mint the NFT you can issue the following commands:
110
+
111
+ ```shell
112
+ # Fund the controller address from the faucet loading the config and wallet env files
113
+ twin-nft faucet --load-env config.env wallet.env --address !ADDRESS_0_BECH32
114
+
115
+ # Mint the NFT and store the id in the nft.env file
116
+ twin-nft nft-mint --load-env config.env wallet.env --seed !SEED --issuer !ADDRESS_0_BECH32 --tag MY-NFT --immutable-json immutable.json --env nft.env
117
+ ```
118
+
119
+ ### nft-resolve
120
+
121
+ To resolve the NFT and retrieve its details issue the following command.
122
+
123
+ ```shell
124
+ twin-nft nft-resolve --load-env config.env nft.env --id !NFT_ID
125
+ ```
126
+
127
+ ### nft-transfer
128
+
129
+ You can transfer the NFT to another address using the following command. You must provide the seed from the current issuer/owner so that it can be unlocked and transferred. In this example we read the nft id from the env file and transfer to the second address we created earlier.
130
+
131
+ ```shell
132
+ twin-nft nft-transfer --load-env config.env wallet.env nft.env --seed !SEED --id !NFT_ID --recipient !ADDRESS_1_BECH32
133
+ ```
134
+
135
+ ### nft-burn
136
+
137
+ To burn the NFT and reclaim the funds we issue the following command. We still require the seed as we need to transfer the deposit funds back to the issuer/owner.
138
+
139
+ ```shell
140
+ twin-nft nft-burn --load-env config.env wallet.env nft.env --seed !SEED --issuer !ADDRESS_1_BECH32 --id !NFT_ID
141
+ ```
@@ -0,0 +1,45 @@
1
+ # Class: CLI
2
+
3
+ The main entry point for the CLI.
4
+
5
+ ## Extends
6
+
7
+ - `CLIBase`
8
+
9
+ ## Constructors
10
+
11
+ ### new CLI()
12
+
13
+ > **new CLI**(): [`CLI`](CLI.md)
14
+
15
+ #### Returns
16
+
17
+ [`CLI`](CLI.md)
18
+
19
+ #### Inherited from
20
+
21
+ `CLIBase.constructor`
22
+
23
+ ## Methods
24
+
25
+ ### run()
26
+
27
+ > **run**(`argv`, `localesDirectory`?): `Promise`\<`number`\>
28
+
29
+ Run the app.
30
+
31
+ #### Parameters
32
+
33
+ • **argv**: `string`[]
34
+
35
+ The process arguments.
36
+
37
+ • **localesDirectory?**: `string`
38
+
39
+ The directory for the locales, default to relative to the script.
40
+
41
+ #### Returns
42
+
43
+ `Promise`\<`number`\>
44
+
45
+ The exit code.
@@ -0,0 +1,35 @@
1
+ # Function: actionCommandNftBurn()
2
+
3
+ > **actionCommandNftBurn**(`opts`): `Promise`\<`void`\>
4
+
5
+ Action the nft burn command.
6
+
7
+ ## Parameters
8
+
9
+ • **opts**
10
+
11
+ The options for the command.
12
+
13
+ • **opts.seed**: `string`
14
+
15
+ The seed required for signing by the issuer.
16
+
17
+ • **opts.issuer**: `string`
18
+
19
+ The issuer address of the NFT.
20
+
21
+ • **opts.id**: `string`
22
+
23
+ The id of the NFT to burn in urn format.
24
+
25
+ • **opts.node**: `string`
26
+
27
+ The node URL.
28
+
29
+ • **opts.explorer**: `string`
30
+
31
+ The explorer URL.
32
+
33
+ ## Returns
34
+
35
+ `Promise`\<`void`\>
@@ -0,0 +1,15 @@
1
+ # Function: actionCommandNftMint()
2
+
3
+ > **actionCommandNftMint**(`opts`): `Promise`\<`void`\>
4
+
5
+ Action the nft mint command.
6
+
7
+ ## Parameters
8
+
9
+ • **opts**: `object` & `ICliOutputOptionsConsole` & `ICliOutputOptionsEnv` & `ICliOutputOptionsJson`
10
+
11
+ The options for the command.
12
+
13
+ ## Returns
14
+
15
+ `Promise`\<`void`\>
@@ -0,0 +1,15 @@
1
+ # Function: actionCommandNftResolve()
2
+
3
+ > **actionCommandNftResolve**(`opts`): `Promise`\<`void`\>
4
+
5
+ Action the nft resolve command.
6
+
7
+ ## Parameters
8
+
9
+ • **opts**: `object` & `ICliOutputOptionsConsole` & `ICliOutputOptionsEnv` & `ICliOutputOptionsJson`
10
+
11
+ The options for the command.
12
+
13
+ ## Returns
14
+
15
+ `Promise`\<`void`\>
@@ -0,0 +1,35 @@
1
+ # Function: actionCommandNftTransfer()
2
+
3
+ > **actionCommandNftTransfer**(`opts`): `Promise`\<`void`\>
4
+
5
+ Action the nft transfer command.
6
+
7
+ ## Parameters
8
+
9
+ • **opts**
10
+
11
+ The options for the command.
12
+
13
+ • **opts.seed**: `string`
14
+
15
+ The seed required for signing by the issuer.
16
+
17
+ • **opts.id**: `string`
18
+
19
+ The id of the NFT to transfer in urn format.
20
+
21
+ • **opts.recipient**: `string`
22
+
23
+ The recipient address of the NFT.
24
+
25
+ • **opts.node**: `string`
26
+
27
+ The node URL.
28
+
29
+ • **opts.explorer**: `string`
30
+
31
+ The explorer URL.
32
+
33
+ ## Returns
34
+
35
+ `Promise`\<`void`\>
@@ -0,0 +1,11 @@
1
+ # Function: buildCommandNftBurn()
2
+
3
+ > **buildCommandNftBurn**(): `Command`
4
+
5
+ Build the nft burn command for the CLI.
6
+
7
+ ## Returns
8
+
9
+ `Command`
10
+
11
+ The command.
@@ -0,0 +1,11 @@
1
+ # Function: buildCommandNftMint()
2
+
3
+ > **buildCommandNftMint**(): `Command`
4
+
5
+ Build the nft mint command for the CLI.
6
+
7
+ ## Returns
8
+
9
+ `Command`
10
+
11
+ The command.
@@ -0,0 +1,11 @@
1
+ # Function: buildCommandNftResolve()
2
+
3
+ > **buildCommandNftResolve**(): `Command`
4
+
5
+ Build the nft resolve command for the CLI.
6
+
7
+ ## Returns
8
+
9
+ `Command`
10
+
11
+ The command.
@@ -0,0 +1,11 @@
1
+ # Function: buildCommandNftTransfer()
2
+
3
+ > **buildCommandNftTransfer**(): `Command`
4
+
5
+ Build the nft transfer command for the CLI.
6
+
7
+ ## Returns
8
+
9
+ `Command`
10
+
11
+ The command.
@@ -0,0 +1,16 @@
1
+ # @twin.org/nft-cli
2
+
3
+ ## Classes
4
+
5
+ - [CLI](classes/CLI.md)
6
+
7
+ ## Functions
8
+
9
+ - [buildCommandNftBurn](functions/buildCommandNftBurn.md)
10
+ - [actionCommandNftBurn](functions/actionCommandNftBurn.md)
11
+ - [buildCommandNftMint](functions/buildCommandNftMint.md)
12
+ - [actionCommandNftMint](functions/actionCommandNftMint.md)
13
+ - [buildCommandNftResolve](functions/buildCommandNftResolve.md)
14
+ - [actionCommandNftResolve](functions/actionCommandNftResolve.md)
15
+ - [buildCommandNftTransfer](functions/buildCommandNftTransfer.md)
16
+ - [actionCommandNftTransfer](functions/actionCommandNftTransfer.md)
@@ -0,0 +1,123 @@
1
+ {
2
+ "commands": {
3
+ "nft-mint": {
4
+ "summary": "Mint an NFT.",
5
+ "description": "Mint an NFT.",
6
+ "options": {
7
+ "seed": {
8
+ "param": "--seed '<'seed'>'",
9
+ "description": "The seed for the issuer address in hex or base64 used to fund the minting, or start with ! to read environment variable."
10
+ },
11
+ "issuer": {
12
+ "param": "--issuer '<'issuer'>'",
13
+ "description": "The bech32 address of the NFT issuer, or start with ! to read environment variable."
14
+ },
15
+ "tag": {
16
+ "param": "--tag '<'tag'>'",
17
+ "description": "The tag for the NFT."
18
+ },
19
+ "immutable-json": {
20
+ "param": "--immutable-json '<'immutable-json'>'",
21
+ "description": "A JSON file to read which includes the immutable data for the NFT."
22
+ },
23
+ "mutable-json": {
24
+ "param": "--mutable-json '<'mutable-json'>'",
25
+ "description": "A JSON file to read which includes the mutable data for the NFT."
26
+ }
27
+ },
28
+ "progress": {
29
+ "mintingNft": "Minting NFT"
30
+ },
31
+ "labels": {
32
+ "issuer": "Issuer",
33
+ "tag": "Tag",
34
+ "immutableJsonFilename": "Immutable JSON Filename",
35
+ "mutableJsonFilename": "Mutable JSON Filename",
36
+ "immutableJson": "Immutable JSON",
37
+ "mutableJson": "Mutable JSON",
38
+ "nftId": "NFT Id"
39
+ }
40
+ },
41
+ "nft-resolve": {
42
+ "summary": "Resolve an NFT.",
43
+ "description": "Resolve an NFT.",
44
+ "options": {
45
+ "id": {
46
+ "param": "--id '<'id'>'",
47
+ "description": "The id for the NFT in urn format."
48
+ }
49
+ },
50
+ "progress": {
51
+ "resolvingNft": "Resolving NFT"
52
+ },
53
+ "labels": {
54
+ "nft": "NFT",
55
+ "nftId": "NFT Id"
56
+ }
57
+ },
58
+ "nft-burn": {
59
+ "summary": "Burn an NFT.",
60
+ "description": "Burn an NFT.",
61
+ "options": {
62
+ "seed": {
63
+ "param": "--seed '<'seed'>'",
64
+ "description": "The seed for the issuer address in hex or base64 used to fund the burning, or start with ! to read environment variable."
65
+ },
66
+ "issuer": {
67
+ "param": "--issuer '<'issuer'>'",
68
+ "description": "The bech32 address of the NFT issuer, or start with ! to read environment variable."
69
+ },
70
+ "id": {
71
+ "param": "--id '<'id'>'",
72
+ "description": "The id for the NFT in urn format."
73
+ }
74
+ },
75
+ "progress": {
76
+ "burningNft": "Burning NFT"
77
+ },
78
+ "labels": {
79
+ "issuer": "Issuer",
80
+ "nftId": "NFT Id"
81
+ }
82
+ },
83
+ "nft-transfer": {
84
+ "summary": "Transfer an NFT.",
85
+ "description": "Transfer an NFT.",
86
+ "options": {
87
+ "seed": {
88
+ "param": "--seed '<'seed'>'",
89
+ "description": "The seed for the issuer address in hex or base64 used to fund the transfer, or start with ! to read environment variable."
90
+ },
91
+ "id": {
92
+ "param": "--id '<'id'>'",
93
+ "description": "The id for the NFT in urn format."
94
+ },
95
+ "recipient": {
96
+ "param": "--recipient '<'recipient'>'",
97
+ "description": "The bech32 address of the NFT recipient, or start with ! to read environment variable."
98
+ }
99
+ },
100
+ "progress": {
101
+ "transferringNft": "Transferring NFT"
102
+ },
103
+ "labels": {
104
+ "recipient": "Recipient",
105
+ "nftId": "NFT Id"
106
+ }
107
+ },
108
+ "common": {
109
+ "options": {
110
+ "node": {
111
+ "param": "--node '<'url'>'",
112
+ "description": "The url for the node endpoint, or an environment variable name containing the url."
113
+ }
114
+ },
115
+ "labels": {
116
+ "did": "DID",
117
+ "node": "Node",
118
+ "explorer": "Explorer",
119
+ "explore": "Explore"
120
+ }
121
+ }
122
+ }
123
+ }
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@twin.org/nft-cli",
3
+ "version": "0.0.1-next.3",
4
+ "description": "A command line interface for interacting with the nft connectors",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/nft.git",
8
+ "directory": "packages/nft-cli"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "scripts": {
17
+ "clean": "rimraf dist coverage",
18
+ "build": "tspc",
19
+ "merge-locales": "merge-locales",
20
+ "test": "vitest --run --config ./vitest.config.ts --no-cache",
21
+ "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
22
+ "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
23
+ "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
24
+ "bundle": "npm run bundle:esm && npm run bundle:cjs",
25
+ "docs:clean": "rimraf docs/reference",
26
+ "docs:generate": "typedoc",
27
+ "docs": "npm run docs:clean && npm run docs:generate",
28
+ "dist": "npm run clean && npm run build && npm run merge-locales && npm run test && npm run bundle && npm run docs"
29
+ },
30
+ "dependencies": {
31
+ "@twin.org/core": "next",
32
+ "@twin.org/crypto": "next",
33
+ "@twin.org/cli-core": "next",
34
+ "@twin.org/crypto-cli": "next",
35
+ "@twin.org/entity": "next",
36
+ "@twin.org/entity-storage-connector-memory": "next",
37
+ "@twin.org/nameof": "next",
38
+ "@twin.org/nft-connector-iota": "0.0.1-next.3",
39
+ "@twin.org/vault-connector-entity-storage": "next",
40
+ "@twin.org/vault-models": "next",
41
+ "@twin.org/wallet-cli": "next",
42
+ "commander": "12.1.0"
43
+ },
44
+ "devDependencies": {
45
+ "@twin.org/merge-locales": "next",
46
+ "@twin.org/nameof-transformer": "next",
47
+ "@types/node": "22.5.5",
48
+ "@vitest/coverage-v8": "2.1.1",
49
+ "copyfiles": "2.4.1",
50
+ "rimraf": "6.0.1",
51
+ "rollup": "4.22.0",
52
+ "rollup-plugin-typescript2": "0.36.0",
53
+ "ts-patch": "3.2.1",
54
+ "typedoc": "0.26.7",
55
+ "typedoc-plugin-markdown": "4.2.7",
56
+ "typescript": "5.6.2",
57
+ "vitest": "2.1.1"
58
+ },
59
+ "main": "./dist/cjs/index.cjs",
60
+ "module": "./dist/esm/index.mjs",
61
+ "types": "./dist/types/index.d.ts",
62
+ "exports": {
63
+ ".": {
64
+ "require": "./dist/cjs/index.cjs",
65
+ "import": "./dist/esm/index.mjs",
66
+ "types": "./dist/types/index.d.ts"
67
+ }
68
+ },
69
+ "files": [
70
+ "bin",
71
+ "dist/cjs",
72
+ "dist/esm",
73
+ "dist/types",
74
+ "dist/locales",
75
+ "locales",
76
+ "docs"
77
+ ],
78
+ "bin": {
79
+ "twin-nft": "bin/index.js"
80
+ }
81
+ }