mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-23 23:26:45 +00:00
refactoring for standarization
This commit is contained in:
19
README.md
19
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
|
||||
);
|
||||
|
||||
```
|
||||
|
||||
@@ -574,24 +574,41 @@ export class SolanaAgentKit {
|
||||
}
|
||||
|
||||
async create3LandCollection(
|
||||
optionsWithBase58: StoreInitOptions,
|
||||
collectionOpts: CreateCollectionOptions,
|
||||
isDevnet: boolean = false,
|
||||
): Promise<string> {
|
||||
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<string> {
|
||||
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}`;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user