diff --git a/README.md b/README.md index c46e0c3..ee42e5e 100644 --- a/README.md +++ b/README.md @@ -132,10 +132,7 @@ 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 isDevnet = true; // (Optional) if not present TX takes place in Mainnet const collectionOpts: CreateCollectionOptions = { collectionName: "", @@ -145,18 +142,16 @@ const optionsWithBase58: StoreInitOptions = { }; const result = await agent.create3LandCollection( - optionsWithBase58, - collectionOpts + collectionOpts, + isDevnet, // (Optional) if not present TX takes place in Mainnet ); ``` ### 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 isDevnet = true; // (Optional) if not present TX takes place in Mainnet + const collectionAccount = ""; //hash for the collection const createItemOptions: CreateSingleOptions = { itemName: "", @@ -171,12 +166,10 @@ const createItemOptions: CreateSingleOptions = { mainImageUrl: "", splHash: "", //present if listing is on a specific SPL token, if not present sale will be on $SOL }; -const isMainnet = true; const result = await agent.create3LandNft( - optionsWithBase58, collectionAccount, createItemOptions, - isMainnet + isDevnet, // (Optional) if not present TX takes place in Mainnet ); ``` diff --git a/src/agent/index.ts b/src/agent/index.ts index 07cb294..e5fda5b 100644 --- a/src/agent/index.ts +++ b/src/agent/index.ts @@ -574,24 +574,41 @@ export class SolanaAgentKit { } async create3LandCollection( - optionsWithBase58: StoreInitOptions, collectionOpts: CreateCollectionOptions, + isDevnet: boolean = false, ): Promise { + let optionsWithBase58: StoreInitOptions = { + privateKey: this.wallet.secretKey, + }; + if (isDevnet) { + optionsWithBase58.isMainnet = false; + } else { + optionsWithBase58.isMainnet = true; + } + const tx = await createCollection(optionsWithBase58, collectionOpts); return `Transaction: ${tx}`; } async create3LandNft( - optionsWithBase58: StoreInitOptions, collectionAccount: string, createItemOptions: CreateSingleOptions, - isMainnet: boolean, + isDevnet: boolean = false, ): Promise { + let optionsWithBase58: StoreInitOptions = { + privateKey: this.wallet.secretKey, + }; + if (isDevnet) { + optionsWithBase58.isMainnet = false; + } else { + optionsWithBase58.isMainnet = true; + } + const tx = await createSingle( optionsWithBase58, collectionAccount, createItemOptions, - isMainnet, + !isDevnet, ); return `Transaction: ${tx}`; } diff --git a/test/tools/3land.ts b/test/tools/3land.ts index aadc634..b482312 100644 --- a/test/tools/3land.ts +++ b/test/tools/3land.ts @@ -13,10 +13,7 @@ const agent = new SolanaAgentKit( { OPENAI_API_KEY: process.env.OPENAI_API_KEY! }, ); -const optionsWithBase58: StoreInitOptions = { - privateKey: process.env.SOLANA_PRIVATE_KEY!, - isMainnet: false, -}; +const isDevnet = true; /****************************** CREATING COLLECTION ******************************** */ @@ -29,8 +26,8 @@ const collectionOpts: CreateCollectionOptions = { (async () => { const collection = await agent.create3LandCollection( - optionsWithBase58, collectionOpts, + isDevnet, ); console.log("collection: ", collection); @@ -49,13 +46,11 @@ const createItemOptions: CreateSingleOptions = { mainImageUrl: "", }; -const isMainnet = false; (async () => { const result = agent.create3LandNft( - optionsWithBase58, collectionAccount, createItemOptions, - isMainnet, + isDevnet, ); console.log("result: ", result); })();