Skip to content

Commit 6bbb6d4

Browse files
committed
implemented nft creation with LP
1 parent dc520df commit 6bbb6d4

File tree

8 files changed

+391
-40
lines changed

8 files changed

+391
-40
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const result = await agent.create3LandCollection(
153153
When creating an NFT using 3Land's tool, it automatically goes for sale on 3.land website
154154
```typescript
155155
const isDevnet = true; // (Optional) if not present TX takes place in Mainnet
156-
156+
const withPool = true; // (Optional) only present if NFT will be created with a Liquidity Pool for a specific SPL token
157157
const collectionAccount = ""; //hash for the collection
158158
const createItemOptions: CreateSingleOptions = {
159159
itemName: "",
@@ -165,13 +165,15 @@ const createItemOptions: CreateSingleOptions = {
165165
{ trait_type: "", value: "" },
166166
],
167167
price: 0, //100000000 == 0.1 sol, can be set to 0 for a free mint
168+
splHash: "", //present if listing is on a specific SPL token, if not present sale will be on $SOL, must be present if "withPool" is true
169+
poolName: "", // Only present if "withPool" is true
168170
mainImageUrl: "",
169-
splHash: "", //present if listing is on a specific SPL token, if not present sale will be on $SOL
170171
};
171172
const result = await agent.create3LandNft(
172173
collectionAccount,
173174
createItemOptions,
174175
isDevnet, // (Optional) if not present TX takes place in Mainnet
176+
withPool
175177
);
176178

177179
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"author": "sendaifun",
2424
"license": "Apache-2.0",
2525
"dependencies": {
26-
"@3land/listings-sdk": "^0.0.4",
26+
"@3land/listings-sdk": "^0.0.6",
2727
"@ai-sdk/openai": "^1.0.11",
2828
"@bonfida/spl-name-service": "^3.0.7",
2929
"@cks-systems/manifest-sdk": "0.1.59",

pnpm-lock.yaml

Lines changed: 355 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/agent/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ export class SolanaAgentKit {
651651
collectionAccount: string,
652652
createItemOptions: CreateSingleOptions,
653653
isDevnet: boolean = false,
654+
withPool: boolean = false,
654655
): Promise<string> {
655656
let optionsWithBase58: StoreInitOptions = {
656657
privateKey: this.wallet.secretKey,
@@ -666,6 +667,7 @@ export class SolanaAgentKit {
666667
collectionAccount,
667668
createItemOptions,
668669
!isDevnet,
670+
withPool,
669671
);
670672
return `Transaction: ${tx}`;
671673
}

src/langchain/3land/create_collection.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export class Solana3LandCreateCollection extends Tool {
1010
description = `Creates an NFT Collection that you can visit on 3.land's website (3.land/collection/{collectionAccount})
1111
1212
Inputs:
13-
privateKey (required): represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string
1413
isMainnet (required): defines is the tx takes places in mainnet
1514
collectionSymbol (required): the symbol of the collection
1615
collectionName (required): the name of the collection
@@ -26,14 +25,8 @@ export class Solana3LandCreateCollection extends Tool {
2625
protected async _call(input: string): Promise<string> {
2726
try {
2827
const inputFormat = JSON.parse(input);
29-
const privateKey = inputFormat.privateKey;
3028
const isMainnet = inputFormat.isMainnet;
3129

32-
const optionsWithBase58: StoreInitOptions = {
33-
...(privateKey && { privateKey }),
34-
...(isMainnet && { isMainnet }),
35-
};
36-
3730
const collectionSymbol = inputFormat?.collectionSymbol;
3831
const collectionName = inputFormat?.collectionName;
3932
const collectionDescription = inputFormat?.collectionDescription;
@@ -49,8 +42,8 @@ export class Solana3LandCreateCollection extends Tool {
4942
};
5043

5144
const tx = await this.solanaKit.create3LandCollection(
52-
optionsWithBase58,
5345
collectionOpts,
46+
!isMainnet,
5447
);
5548
return JSON.stringify({
5649
status: "success",

src/langchain/3land/create_single.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export class Solana3LandCreateSingle extends Tool {
1010
description = `Creates an NFT and lists it on 3.land's website
1111
1212
Inputs:
13-
privateKey (required): represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string
1413
collectionAccount (optional): represents the account for the nft collection
1514
itemName (required): the name of the NFT
1615
sellerFee (required): the fee of the seller
@@ -21,7 +20,9 @@ export class Solana3LandCreateSingle extends Tool {
2120
mainImageUrl (required): the main image of the NFT
2221
coverImageUrl (optional): the cover image of the NFT
2322
splHash (optional): the hash of the spl token, if not provided listing will be in $SOL
24-
isMainnet (required): defines is the tx takes places in mainnet
23+
poolName (optional): the name of the pool
24+
isMainnet (required): defines if the tx takes places in mainnet
25+
withPool (optional): defines if minted edition will be tied to a liquidity pool
2526
`;
2627

2728
constructor(private solanaKit: SolanaAgentKit) {
@@ -31,13 +32,9 @@ export class Solana3LandCreateSingle extends Tool {
3132
protected async _call(input: string): Promise<string> {
3233
try {
3334
const inputFormat = JSON.parse(input);
34-
const privateKey = inputFormat.privateKey;
3535
const isMainnet = inputFormat.isMainnet;
36-
37-
const optionsWithBase58: StoreInitOptions = {
38-
...(privateKey && { privateKey }),
39-
...(isMainnet && { isMainnet }),
40-
};
36+
const withPool = inputFormat.withPool;
37+
const poolName = inputFormat.poolName;
4138

4239
const collectionAccount = inputFormat.collectionAccount;
4340

@@ -52,6 +49,15 @@ export class Solana3LandCreateSingle extends Tool {
5249
const coverImageUrl = inputFormat?.coverImageUrl;
5350
const splHash = inputFormat?.splHash;
5451

52+
if (withPool) {
53+
if (!poolName) {
54+
throw new Error("poolName is required when withPool is true");
55+
}
56+
if (!splHash) {
57+
throw new Error("splHash is required when withPool is true");
58+
}
59+
}
60+
5561
const createItemOptions: CreateSingleOptions = {
5662
...(itemName && { itemName }),
5763
...(sellerFee && { sellerFee }),
@@ -63,17 +69,18 @@ export class Solana3LandCreateSingle extends Tool {
6369
...(mainImageUrl && { mainImageUrl }),
6470
...(coverImageUrl && { coverImageUrl }),
6571
...(splHash && { splHash }),
72+
...(poolName && { poolName }),
6673
};
6774

6875
if (!collectionAccount) {
6976
throw new Error("Collection account is required");
7077
}
7178

7279
const tx = await this.solanaKit.create3LandNft(
73-
optionsWithBase58,
7480
collectionAccount,
7581
createItemOptions,
76-
isMainnet,
82+
!isMainnet,
83+
withPool,
7784
);
7885
return JSON.stringify({
7986
status: "success",

src/tools/3land/create_3land_collectible.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export async function createSingle(
3737
optionsWithBase58: StoreInitOptions,
3838
collectionAccount: string,
3939
createItemOptions: CreateSingleOptions,
40-
isMainnet: boolean,
40+
isMainnet: boolean = false,
41+
withPool: boolean = false,
4142
) {
4243
try {
4344
const landStore = isMainnet
@@ -49,6 +50,8 @@ export async function createSingle(
4950
landStore,
5051
collectionAccount,
5152
createItemOptions,
53+
true, //isAI
54+
withPool,
5255
);
5356
return singleEditionTx;
5457
} catch (error: any) {

test/tools/3land.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,24 @@ const collectionAccount = "";
3838
const createItemOptions: CreateSingleOptions = {
3939
itemName: "",
4040
sellerFee: 500, //5%
41-
itemAmount: 100,
41+
itemAmount: 333,
4242
itemSymbol: "",
4343
itemDescription: "",
4444
traits: [{ trait_type: "", value: "" }],
45-
price: 0, //100000000 == 0.1 sol
45+
price: 100000000, //100000000 == 0.1 sol,
46+
splHash: "",
47+
poolName: "",
4648
mainImageUrl: "",
4749
};
4850

51+
const withPool = true;
52+
4953
(async () => {
5054
const result = agent.create3LandNft(
5155
collectionAccount,
5256
createItemOptions,
5357
isDevnet,
58+
withPool,
5459
);
5560
console.log("result: ", result);
5661
})();

0 commit comments

Comments
 (0)