mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-13 23:16:55 +00:00
3land tools implementation
This commit is contained in:
56
README.md
56
README.md
@@ -35,7 +35,10 @@ Anyone - whether an SF-based AI researcher or a crypto-native builder - can brin
|
||||
- Balance checks
|
||||
- Stake SOL
|
||||
- Zk compressed Airdrop by Light Protocol and Helius
|
||||
|
||||
- **NFTs on 3.Land**
|
||||
- Create your own collection
|
||||
- NFT creation and automatic listing on 3.land
|
||||
- List your NFT for sale in any SPL token
|
||||
- **NFT Management via Metaplex**
|
||||
- Collection deployment
|
||||
- NFT minting
|
||||
@@ -127,6 +130,57 @@ const result = await agent.deployToken(
|
||||
|
||||
console.log("Token Mint Address:", result.mint.toString());
|
||||
```
|
||||
### Create NFT Collection on 3Land
|
||||
```typescript
|
||||
const optionsWithBase58: StoreInitOptions = {
|
||||
privateKey: "",
|
||||
isMainnet: true, // if false, collection will be created on devnet 3.land (dev.3.land)
|
||||
};
|
||||
|
||||
const collectionOpts: CreateCollectionOptions = {
|
||||
collectionName: "",
|
||||
collectionSymbol: "",
|
||||
collectionDescription: "",
|
||||
mainImageUrl: ""
|
||||
};
|
||||
|
||||
const result = await agent.create3LandCollection(
|
||||
optionsWithBase58,
|
||||
collectionOpts
|
||||
);
|
||||
```
|
||||
|
||||
### Create NFT on 3Land
|
||||
When creating an NFT using 3Land's tool, it automatically goes for sale on 3.land website
|
||||
```typescript
|
||||
const optionsWithBase58: StoreInitOptions = {
|
||||
privateKey: "",
|
||||
isMainnet: true, // if false, listing will be on devnet 3.land (dev.3.land)
|
||||
};
|
||||
const collectionAccount = ""; //hash for the collection
|
||||
const createItemOptions: CreateSingleOptions = {
|
||||
itemName: "",
|
||||
sellerFee: 500, //5%
|
||||
itemAmount: 100, //total items to be created
|
||||
itemSymbol: "",
|
||||
itemDescription: "",
|
||||
traits: [
|
||||
{ trait_type: "", value: "" },
|
||||
],
|
||||
price: 0, //100000000 == 0.1 sol, can be set to 0 for a free mint
|
||||
mainImageUrl: "",
|
||||
splHash: "", //present if listing is on a specific SPL token, if not present sale will be on $SOL
|
||||
};
|
||||
|
||||
const result = await agent.create3LandNft(
|
||||
optionsWithBase58,
|
||||
collectionAccount,
|
||||
createItemOptions,
|
||||
optionsWithBase58.isMainnet
|
||||
);
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Create NFT Collection
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"author": "sendaifun",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@3land/listings-sdk": "^0.0.3",
|
||||
"@ai-sdk/openai": "^1.0.11",
|
||||
"@bonfida/spl-name-service": "^3.0.7",
|
||||
"@cks-systems/manifest-sdk": "0.1.59",
|
||||
|
||||
2761
pnpm-lock.yaml
generated
2761
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -75,6 +75,15 @@ import {
|
||||
FlashTradeParams,
|
||||
FlashCloseTradeParams,
|
||||
} from "../types";
|
||||
import {
|
||||
createCollection,
|
||||
createSingle,
|
||||
} from "../tools/create_3land_collectible";
|
||||
import {
|
||||
CreateCollectionOptions,
|
||||
CreateSingleOptions,
|
||||
StoreInitOptions,
|
||||
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
|
||||
|
||||
/**
|
||||
* Main class for interacting with Solana blockchain
|
||||
@@ -563,4 +572,27 @@ export class SolanaAgentKit {
|
||||
async flashCloseTrade(params: FlashCloseTradeParams): Promise<string> {
|
||||
return flashCloseTrade(this, params);
|
||||
}
|
||||
|
||||
async create3LandCollection(
|
||||
optionsWithBase58: StoreInitOptions,
|
||||
collectionOpts: CreateCollectionOptions,
|
||||
): Promise<string> {
|
||||
const tx = await createCollection(optionsWithBase58, collectionOpts);
|
||||
return `Transaction: ${tx}`;
|
||||
}
|
||||
|
||||
async create3LandNft(
|
||||
optionsWithBase58: StoreInitOptions,
|
||||
collectionAccount: string,
|
||||
createItemOptions: CreateSingleOptions,
|
||||
isMainnet: boolean,
|
||||
): Promise<string> {
|
||||
const tx = await createSingle(
|
||||
optionsWithBase58,
|
||||
collectionAccount,
|
||||
createItemOptions,
|
||||
isMainnet,
|
||||
);
|
||||
return `Transaction: ${tx}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2250,6 +2250,62 @@ export class SolanaFetchTokenDetailedReportTool extends Tool {
|
||||
}
|
||||
}
|
||||
|
||||
export class Solana3LandCreateSingle extends Tool {
|
||||
name = "3land_minting_tool";
|
||||
description = `Creates an NFT and lists it on 3.land's website
|
||||
|
||||
Inputs:
|
||||
optionsWithBase58 (required): represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string
|
||||
collectionAccount (optional): represents the account for the nft collection
|
||||
createItemOptions (required): the options for the creation of the single NFT listing
|
||||
isMainnet (required): defines is the tx takes places in mainnet
|
||||
`;
|
||||
|
||||
constructor(private solanaKit: SolanaAgentKit) {
|
||||
super();
|
||||
}
|
||||
|
||||
protected async _call(input: string): Promise<string> {
|
||||
try {
|
||||
const inputFormat = JSON.parse(input);
|
||||
const optionsWithBase58 = inputFormat.optionsWithBase58;
|
||||
let collectionAccount = inputFormat.collectionAccount;
|
||||
const createItemOptions = inputFormat.createItemOptions;
|
||||
const isMainnet = inputFormat.isMainnet;
|
||||
|
||||
if (!collectionAccount) {
|
||||
collectionAccount = "Fpm8XgXEuNxxjmqUQuqEFkGusiSsKM6astUGPs5U9x6v";
|
||||
}
|
||||
|
||||
console.log(
|
||||
"options inside 3land func: ",
|
||||
optionsWithBase58,
|
||||
collectionAccount,
|
||||
createItemOptions,
|
||||
isMainnet,
|
||||
);
|
||||
|
||||
const tx = await this.solanaKit.create3LandNft(
|
||||
optionsWithBase58,
|
||||
collectionAccount,
|
||||
createItemOptions,
|
||||
isMainnet,
|
||||
);
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
message: `Created listing successfully ${tx}`,
|
||||
transaction: tx,
|
||||
});
|
||||
} catch (error: any) {
|
||||
return JSON.stringify({
|
||||
status: "error",
|
||||
message: error.message,
|
||||
code: error.code || "UNKNOWN_ERROR",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createSolanaTools(solanaKit: SolanaAgentKit) {
|
||||
return [
|
||||
new SolanaBalanceTool(solanaKit),
|
||||
@@ -2306,5 +2362,6 @@ export function createSolanaTools(solanaKit: SolanaAgentKit) {
|
||||
new SolanaPerpCloseTradeTool(solanaKit),
|
||||
new SolanaFlashOpenTrade(solanaKit),
|
||||
new SolanaFlashCloseTrade(solanaKit),
|
||||
new Solana3LandCreateSingle(solanaKit),
|
||||
];
|
||||
}
|
||||
|
||||
69
src/tools/create_3land_collectible.ts
Normal file
69
src/tools/create_3land_collectible.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { createCollectionImp, createSingleImp } from "@3land/listings-sdk";
|
||||
import {
|
||||
StoreInitOptions,
|
||||
CreateCollectionOptions,
|
||||
CreateSingleOptions,
|
||||
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
|
||||
|
||||
/**
|
||||
* Create a collection on 3Land
|
||||
* @param optionsWithBase58 represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string
|
||||
* @param collectionOpts represents the options for the collection creation
|
||||
* @returns
|
||||
*/
|
||||
export async function createCollection(
|
||||
optionsWithBase58: StoreInitOptions,
|
||||
collectionOpts: CreateCollectionOptions,
|
||||
) {
|
||||
try {
|
||||
const collection = await createCollectionImp(
|
||||
optionsWithBase58,
|
||||
collectionOpts,
|
||||
);
|
||||
return collection;
|
||||
} catch (error: any) {
|
||||
throw new Error(`Collection creation failed: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a single edition on 3Land
|
||||
* @param optionsWithBase58 represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string
|
||||
* @param collectionAccount represents the account for the nft collection
|
||||
* @param createItemOptions the options for the creation of the single NFT listing
|
||||
* @returns
|
||||
*/
|
||||
export async function createSingle(
|
||||
optionsWithBase58: StoreInitOptions,
|
||||
collectionAccount: string,
|
||||
createItemOptions: CreateSingleOptions,
|
||||
isMainnet: boolean,
|
||||
) {
|
||||
try {
|
||||
const landStore = isMainnet
|
||||
? "AmQNs2kgw4LvS9sm6yE9JJ4Hs3JpVu65eyx9pxMG2xA"
|
||||
: "GyPCu89S63P9NcCQAtuSJesiefhhgpGWrNVJs4bF2cSK";
|
||||
|
||||
const singleEditionTx = await createSingleImp(
|
||||
optionsWithBase58,
|
||||
landStore,
|
||||
collectionAccount,
|
||||
createItemOptions,
|
||||
);
|
||||
return singleEditionTx;
|
||||
} catch (error: any) {
|
||||
throw new Error(`Single edition creation failed: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Buy a single edition on 3Land
|
||||
* @param
|
||||
* @returns
|
||||
*/
|
||||
// export async function buySingle() {
|
||||
// try {
|
||||
// } catch (error: any) {
|
||||
// throw new Error(`Buying single edition failed: ${error.message}`);
|
||||
// }
|
||||
// }
|
||||
61
test/tools/3land.ts
Normal file
61
test/tools/3land.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import {
|
||||
CreateCollectionOptions,
|
||||
CreateSingleOptions,
|
||||
StoreInitOptions,
|
||||
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
|
||||
|
||||
import "dotenv/config";
|
||||
import { SolanaAgentKit, createSolanaTools } from "../../src";
|
||||
|
||||
const agent = new SolanaAgentKit(
|
||||
process.env.SOLANA_PRIVATE_KEY!,
|
||||
process.env.RPC_URL!,
|
||||
process.env.OPENAI_API_KEY!,
|
||||
);
|
||||
|
||||
const optionsWithBase58: StoreInitOptions = {
|
||||
privateKey: process.env.SOLANA_PRIVATE_KEY!,
|
||||
isMainnet: false,
|
||||
};
|
||||
|
||||
const collectionOpts: CreateCollectionOptions = {
|
||||
collectionName: "collectionXD",
|
||||
collectionSymbol: "CXD",
|
||||
collectionDescription: "a collection that is cool",
|
||||
mainImageUrl:
|
||||
"https://arweave.net/FMkKYYsheEImBfejYaPPoJbI3CxJxunwvErD9VYzxOY?ext=jpeg",
|
||||
};
|
||||
|
||||
(async () => {
|
||||
const collection = await agent.create3LandCollection(
|
||||
optionsWithBase58,
|
||||
collectionOpts,
|
||||
);
|
||||
|
||||
console.log("collection: ", collection);
|
||||
})();
|
||||
|
||||
//const collectionAccount = "";
|
||||
// const createItemOptions: CreateSingleOptions = {
|
||||
// itemName: "",
|
||||
// sellerFee: 500,
|
||||
// itemAmount: 100,
|
||||
// itemSymbol: "",
|
||||
// itemDescription: "",
|
||||
// traits: [{ trait_type: "", value: "" }],
|
||||
// price: 0, //100000000 == 0.1 sol
|
||||
// mainImageUrl: "",
|
||||
// };
|
||||
|
||||
// const isMainnet = true;
|
||||
//(async() => {
|
||||
// const result = agent.create3LandNft(
|
||||
// optionsWithBase58,
|
||||
// collectionAccount,
|
||||
// createItemOptions,
|
||||
// isMainnet,
|
||||
// );
|
||||
// console.log("result: ", result);
|
||||
//})();
|
||||
|
||||
// export { SolanaAgentKit, createSolanaTools };
|
||||
Reference in New Issue
Block a user