|
| 1 | +### NFT Collection Generation Plugin |
| 2 | + |
| 3 | +A plugin for handling NFT collection generation, NFT creation, and verification on the Solana blockchain. |
| 4 | + |
| 5 | +## Handlers |
| 6 | + |
| 7 | +### createCollection |
| 8 | +The createCollection handler generates an NFT collection logo, uploads it to AWS S3, and creates a Solana blockchain collection. |
| 9 | + |
| 10 | +#### Usage |
| 11 | +```typescript |
| 12 | +import { createCollection } from "./handlers/createCollection.ts"; |
| 13 | + |
| 14 | +const result = await createCollection({ |
| 15 | + runtime: runtimeInstance, // An instance of IAgentRuntime |
| 16 | + collectionName: "MyCollection", // The name of the collection |
| 17 | + fee: 0.01, // (Optional) Fee for transactions |
| 18 | +}); |
| 19 | + |
| 20 | +console.log("Collection created:", result); |
| 21 | +``` |
| 22 | + |
| 23 | +#### Features |
| 24 | + |
| 25 | +Image Generation: Automatically generates a collection logo based on the provided name and theme. |
| 26 | +AWS S3 Integration: Uploads the generated logo and metadata to AWS S3. |
| 27 | +Solana Blockchain: Creates a collection with the generated logo and metadata on the Solana blockchain. |
| 28 | +### createNFT |
| 29 | +The createNFT handler generates individual NFTs for a collection. It includes metadata creation and uploads the NFT information to AWS S3. |
| 30 | + |
| 31 | +#### Usage |
| 32 | + |
| 33 | +```typescript |
| 34 | +import { createNFT } from "./handlers/createNFT.ts"; |
| 35 | + |
| 36 | +const nftResult = await createNFT({ |
| 37 | + runtime: runtimeInstance, |
| 38 | + collectionName: "MyCollection", |
| 39 | + collectionAddress: "collectionAddress123", |
| 40 | + collectionAdminPublicKey: "adminPublicKey123", |
| 41 | + collectionFee: 0.01, |
| 42 | + tokenId: 1, |
| 43 | +}); |
| 44 | + |
| 45 | +console.log("NFT created:", nftResult); |
| 46 | +``` |
| 47 | + |
| 48 | +### verifyNFT |
| 49 | + |
| 50 | +The verifyNFT handler verifies an NFT against its collection using the Solana blockchain. |
| 51 | + |
| 52 | +#### Usage |
| 53 | + |
| 54 | +```typescript |
| 55 | +import { verifyNFT } from "./handlers/verifyNFT.ts"; |
| 56 | + |
| 57 | +const verificationResult = await verifyNFT({ |
| 58 | + runtime: runtimeInstance, |
| 59 | + collectionAddress: "collectionAddress123", |
| 60 | + NFTAddress: "NFTAddress123", |
| 61 | +}); |
| 62 | + |
| 63 | +console.log("NFT verified:", verificationResult); |
| 64 | +```` |
| 65 | +--- |
| 66 | + |
| 67 | +### Example Workflow |
| 68 | + |
| 69 | +The plugin provides a streamlined process for generating and verifying NFT collections: |
| 70 | + |
| 71 | +```typescript |
| 72 | +import { createCollection, createNFT, verifyNFT } from "./handlers"; |
| 73 | +
|
| 74 | +const runtime = initializeRuntime(); // Replace with actual IAgentRuntime initialization |
| 75 | +
|
| 76 | +(async () => { |
| 77 | + // Step 1: Create Collection |
| 78 | + const collectionResult = await createCollection({ |
| 79 | + runtime, |
| 80 | + collectionName: "MyUniqueCollection", |
| 81 | + }); |
| 82 | +
|
| 83 | + console.log("Collection created:", collectionResult); |
| 84 | +
|
| 85 | + // Step 2: Create an NFT in the Collection |
| 86 | + const nftResult = await createNFT({ |
| 87 | + runtime, |
| 88 | + collectionName: "MyUniqueCollection", |
| 89 | + collectionAddress: collectionResult.address, |
| 90 | + collectionAdminPublicKey: collectionResult.collectionInfo.adminPublicKey, |
| 91 | + collectionFee: 0.01, |
| 92 | + tokenId: 1, |
| 93 | + }); |
| 94 | +
|
| 95 | + console.log("NFT created:", nftResult); |
| 96 | +
|
| 97 | + // Step 3: Verify the NFT |
| 98 | + const verificationResult = await verifyNFT({ |
| 99 | + runtime, |
| 100 | + collectionAddress: collectionResult.address, |
| 101 | + NFTAddress: nftResult.address, |
| 102 | + }); |
| 103 | +
|
| 104 | + console.log("NFT verified:", verificationResult); |
| 105 | +})(); |
| 106 | +``` |
| 107 | + |
| 108 | +### Configuration |
| 109 | + |
| 110 | +#### Environment Variables |
| 111 | +``` |
| 112 | +Ensure the following environment variables are set for proper functionality: |
| 113 | + |
| 114 | +Variable Name Description |
| 115 | +AWS_ACCESS_KEY_ID AWS access key for S3 uploads |
| 116 | +AWS_SECRET_ACCESS_KEY AWS secret key for S3 uploads |
| 117 | +AWS_REGION AWS region where S3 is located |
| 118 | +AWS_S3_BUCKET Name of the AWS S3 bucket |
| 119 | +SOLANA_PUBLIC_KEY Public key for Solana blockchain |
| 120 | +SOLANA_PRIVATE_KEY Private key for Solana blockchain |
| 121 | +SOLANA_ADMIN_PUBLIC_KEY Admin public key for Solana operations |
| 122 | +SOLANA_ADMIN_PRIVATE_KEY Admin private key for Solana operations |
| 123 | +``` |
| 124 | +#### Example Prompts |
| 125 | +
|
| 126 | +Here are some examples of user prompts to trigger NFT collection generation: |
| 127 | +
|
| 128 | +"Generate a collection named MyCollection." |
| 129 | +"Create a new NFT collection." |
| 130 | +"Compile an NFT collection for me." |
| 131 | +"Build a sci-fi themed collection." |
| 132 | +
|
| 133 | +
|
| 134 | +#### Local Testing with TEE Simulator |
| 135 | +
|
| 136 | +To test locally using a Trusted Execution Environment (TEE) simulator, follow these steps: |
| 137 | +
|
| 138 | +Pull the simulator Docker image: |
| 139 | +``` bash |
| 140 | +docker pull phalanetwork/tappd-simulator:latest |
| 141 | +``` |
| 142 | +Run the simulator: |
| 143 | + |
| 144 | +``` bash |
| 145 | +docker run --rm -p 8090:8090 phalanetwork/tappd-simulator:latest |
| 146 | +``` |
| 147 | +Update your environment variable for the simulator: |
| 148 | + |
| 149 | +```env |
| 150 | +DSTACK_SIMULATOR_ENDPOINT="http://localhost:8090" |
| 151 | +``` |
| 152 | + |
| 153 | +#### Dependencies |
| 154 | + |
| 155 | +This plugin relies on the following services and libraries: |
| 156 | + |
| 157 | +[@elizaos/plugin-node] |
| 158 | +[@elizaos/eliza] |
| 159 | +[@elizaos/plugin-image-generation] |
| 160 | +[@solana/web3.js] |
| 161 | + |
| 162 | +### Action Configuration |
| 163 | + |
| 164 | +#### GENERATE_COLLECTION |
| 165 | +The action for generating NFT collections is configured with the following parameters: |
| 166 | + |
| 167 | +```typescript |
| 168 | +const nftCollectionGeneration: Action = { |
| 169 | + name: "GENERATE_COLLECTION", |
| 170 | + description: "Generate an NFT collection for the message", |
| 171 | + handler: async (runtime, message, state, options, callback) => { |
| 172 | + // Implementation |
| 173 | + }, |
| 174 | + examples: [ |
| 175 | + { |
| 176 | + user: "{{user1}}", |
| 177 | + content: { text: "Generate a collection named Galaxy." }, |
| 178 | + }, |
| 179 | + { |
| 180 | + agent: "{{agentName}}", |
| 181 | + content: { text: "The collection Galaxy has been successfully created." }, |
| 182 | + }, |
| 183 | + ], |
| 184 | +}; |
| 185 | +``` |
0 commit comments