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

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,4 @@
1
+ /**
2
+ * Setup the vault for use in the CLI commands.
3
+ */
4
+ export declare function setupVault(): void;
@@ -0,0 +1,5 @@
1
+ export * from "./cli";
2
+ export * from "./commands/nftBurn";
3
+ export * from "./commands/nftMint";
4
+ export * from "./commands/nftResolve";
5
+ export * from "./commands/nftTransfer";
@@ -0,0 +1,5 @@
1
+ # @twin.org/nft-cli - Changelog
2
+
3
+ ## v0.0.1-next.10
4
+
5
+ - Initial Release
@@ -0,0 +1,142 @@
1
+ # @twin.org/nft-cli - Examples
2
+
3
+ ## Running
4
+
5
+ To install and run the CLI locally use the following commands:
6
+
7
+ ```shell
8
+ npm install @twin.org/nft-cli -g
9
+ twin-nft
10
+ ```
11
+
12
+ or run directly using NPX:
13
+
14
+ ```shell
15
+ npx "@twin.org/nft-cli"
16
+ ```
17
+
18
+ You should see output similar to the following:
19
+
20
+ ```shell
21
+ 🌍 TWIN NFT v1.0.0
22
+
23
+ Usage: twin-nft [command]
24
+
25
+ Options:
26
+ -V, --version output the version number
27
+ --lang <lang> The language to display the output in. (default: "en")
28
+ --load-env [env...] Load the env files to initialise any environment variables.
29
+ -h, --help display help for command
30
+
31
+ Commands:
32
+ mnemonic [options] Create a mnemonic.
33
+ address [options] Create bech32 addresses and keys from the seed.
34
+ faucet [options] Request funds from the faucet.
35
+ nft-mint [options] Mint an NFT.
36
+ nft-resolve [options] Resolve an NFT.
37
+ nft-burn [options] Burn an NFT.
38
+ nft-transfer [options] Transfer an NFT.
39
+ ```
40
+
41
+ You can get further details on the sub commands by using the help option for the individual commands.
42
+
43
+ ```shell
44
+ twin-nft nft-mint --help
45
+ ```
46
+
47
+ Output
48
+
49
+ ```shell
50
+ 🌍 TWIN NFT v1.0.0
51
+
52
+ Usage: twin-nft nft-mint [options]
53
+
54
+ Mint an NFT.
55
+
56
+ Options:
57
+ --seed <seed> The seed for the issuer address in hex or base64 used to fund the minting, or start with ! to read environment variable.
58
+ --issuer <issuer> The bech32 address of the NFT issuer, or start with ! to read environment variable.
59
+ --tag <tag> The tag for the NFT.
60
+ --immutable-json <immutable-json> A JSON file to read which includes the immutable data for the NFT.
61
+ --mutable-json <mutable-json> A JSON file to read which includes the mutable data for the NFT.
62
+ --no-console Hides the output in the console.
63
+ --json <filename> Creates a JSON file containing the output.
64
+ --merge-json If the JSON file already exists merge the data instead of overwriting.
65
+ --env <filename> Creates an env file containing the output.
66
+ --merge-env If the env file already exists merge the data instead of overwriting.
67
+ --node <url> The url for the node endpoint, or an environment variable name containing the url. (default: "!NODE_URL")
68
+ --explorer <url> The url for the explorer endpoint, or an environment variable name containing the url. (default: "!EXPLORER_URL")
69
+ -h, --help display help for command
70
+ ```
71
+
72
+ The commands `mnemonic`, `address` and `faucet` are described in more detail in the examples for `crypto-cli` and `wallet-cli`.
73
+
74
+ ## Command
75
+
76
+ ### nft-mint
77
+
78
+ 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.
79
+
80
+ ```shell
81
+ # Generate a seed and mnemonic and store it in the env file
82
+ twin-nft mnemonic --env wallet.env
83
+ # Generate an address and store it in the env file
84
+ twin-nft address --load-env wallet.env --hrp tst --seed !SEED --count 4 --env wallet.env --merge-env
85
+ ```
86
+
87
+ To run this on the IOTA testnet you will need an env file with the following settings. Store the following config as config.env
88
+
89
+ ```shell
90
+ NODE_URL="https://api.testnet.iotaledger.net"
91
+ FAUCET_URL="https://faucet.testnet.iotaledger.net/api/enqueue"
92
+ EXPLORER_URL="https://explorer.iota.org/iota-testnet/"
93
+ ```
94
+
95
+ 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.
96
+
97
+ ```json
98
+ {
99
+ "standard": "IRC27",
100
+ "version": "v1.0",
101
+ "type": "video/mp4",
102
+ "uri": "https://ipfs.io/ipfs/QmPoYcVm9fx47YXNTkhpMEYSxCD3Bqh7PJYr7eo5YjLgiT",
103
+ "name": "Test NFT",
104
+ "collectionName": "Test Collection",
105
+ "issuerName": "Test Issuer",
106
+ "description": "This is a test NFT."
107
+ }
108
+ ```
109
+
110
+ To request some funds and mint the NFT you can issue the following commands:
111
+
112
+ ```shell
113
+ # Fund the controller address from the faucet loading the config and wallet env files
114
+ twin-nft faucet --load-env config.env wallet.env --address !ADDRESS_0_BECH32
115
+
116
+ # Mint the NFT and store the id in the nft.env file
117
+ 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
118
+ ```
119
+
120
+ ### nft-resolve
121
+
122
+ To resolve the NFT and retrieve its details issue the following command.
123
+
124
+ ```shell
125
+ twin-nft nft-resolve --load-env config.env nft.env --id !NFT_ID
126
+ ```
127
+
128
+ ### nft-transfer
129
+
130
+ 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.
131
+
132
+ ```shell
133
+ twin-nft nft-transfer --load-env config.env wallet.env nft.env --seed !SEED --id !NFT_ID --recipient !ADDRESS_1_BECH32
134
+ ```
135
+
136
+ ### nft-burn
137
+
138
+ 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.
139
+
140
+ ```shell
141
+ twin-nft nft-burn --load-env config.env wallet.env nft.env --seed !SEED --issuer !ADDRESS_1_BECH32 --id !NFT_ID
142
+ ```
@@ -0,0 +1,59 @@
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`?, `options`?): `Promise`\<`number`\>
28
+
29
+ Run the app.
30
+
31
+ #### Parameters
32
+
33
+ ##### argv
34
+
35
+ `string`[]
36
+
37
+ The process arguments.
38
+
39
+ ##### localesDirectory?
40
+
41
+ `string`
42
+
43
+ The directory for the locales, default to relative to the script.
44
+
45
+ ##### options?
46
+
47
+ Additional options for the CLI.
48
+
49
+ ###### overrideOutputWidth
50
+
51
+ `number`
52
+
53
+ Override the output width.
54
+
55
+ #### Returns
56
+
57
+ `Promise`\<`number`\>
58
+
59
+ The exit code.
@@ -0,0 +1,45 @@
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
+ #### seed
14
+
15
+ `string`
16
+
17
+ The seed required for signing by the issuer.
18
+
19
+ #### issuer
20
+
21
+ `string`
22
+
23
+ The issuer address of the NFT.
24
+
25
+ #### id
26
+
27
+ `string`
28
+
29
+ The id of the NFT to burn in urn format.
30
+
31
+ #### node
32
+
33
+ `string`
34
+
35
+ The node URL.
36
+
37
+ #### explorer
38
+
39
+ `string`
40
+
41
+ The explorer URL.
42
+
43
+ ## Returns
44
+
45
+ `Promise`\<`void`\>
@@ -0,0 +1,17 @@
1
+ # Function: actionCommandNftMint()
2
+
3
+ > **actionCommandNftMint**(`opts`): `Promise`\<`void`\>
4
+
5
+ Action the nft mint command.
6
+
7
+ ## Parameters
8
+
9
+ ### opts
10
+
11
+ `object` & `ICliOutputOptionsConsole` & `ICliOutputOptionsEnv` & `ICliOutputOptionsJson`
12
+
13
+ The options for the command.
14
+
15
+ ## Returns
16
+
17
+ `Promise`\<`void`\>
@@ -0,0 +1,17 @@
1
+ # Function: actionCommandNftResolve()
2
+
3
+ > **actionCommandNftResolve**(`opts`): `Promise`\<`void`\>
4
+
5
+ Action the nft resolve command.
6
+
7
+ ## Parameters
8
+
9
+ ### opts
10
+
11
+ `object` & `ICliOutputOptionsConsole` & `ICliOutputOptionsEnv` & `ICliOutputOptionsJson`
12
+
13
+ The options for the command.
14
+
15
+ ## Returns
16
+
17
+ `Promise`\<`void`\>
@@ -0,0 +1,45 @@
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
+ #### seed
14
+
15
+ `string`
16
+
17
+ The seed required for signing by the issuer.
18
+
19
+ #### id
20
+
21
+ `string`
22
+
23
+ The id of the NFT to transfer in urn format.
24
+
25
+ #### recipient
26
+
27
+ `string`
28
+
29
+ The recipient address of the NFT.
30
+
31
+ #### node
32
+
33
+ `string`
34
+
35
+ The node URL.
36
+
37
+ #### explorer
38
+
39
+ `string`
40
+
41
+ The explorer URL.
42
+
43
+ ## Returns
44
+
45
+ `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,52 @@
1
+ {
2
+ "name": "@twin.org/nft-cli",
3
+ "version": "0.0.1-next.10",
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": "apps/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
+ "dependencies": {
17
+ "@twin.org/cli-core": "next",
18
+ "@twin.org/core": "next",
19
+ "@twin.org/crypto": "next",
20
+ "@twin.org/crypto-cli": "next",
21
+ "@twin.org/entity": "next",
22
+ "@twin.org/entity-storage-connector-memory": "next",
23
+ "@twin.org/nameof": "next",
24
+ "@twin.org/nft-connector-iota": "0.0.1-next.10",
25
+ "@twin.org/vault-connector-entity-storage": "next",
26
+ "@twin.org/vault-models": "next",
27
+ "@twin.org/wallet-cli": "next",
28
+ "commander": "13.0.0"
29
+ },
30
+ "main": "./dist/cjs/index.cjs",
31
+ "module": "./dist/esm/index.mjs",
32
+ "types": "./dist/types/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "require": "./dist/cjs/index.cjs",
36
+ "import": "./dist/esm/index.mjs",
37
+ "types": "./dist/types/index.d.ts"
38
+ }
39
+ },
40
+ "files": [
41
+ "bin",
42
+ "dist/cjs",
43
+ "dist/esm",
44
+ "dist/types",
45
+ "dist/locales",
46
+ "locales",
47
+ "docs"
48
+ ],
49
+ "bin": {
50
+ "twin-nft": "bin/index.js"
51
+ }
52
+ }