Skip to content

Commit

Permalink
priority fees added (#235)
Browse files Browse the repository at this point in the history
# Pull Request Description
## Related Issue
Adds priority fees to 3land transactions

## Changes Made
- Added default priority fee of 50000 for all transactions
- Implemented custom priority fee override for failed transactions
- Added fee parameter to transaction functions

## Implementation Details
- Set default priority fee = 50000 in transaction handler
- Added optional priorityFee parameter to allow user overrides
- Applied priority fees to all contract interaction methods

## Checklist
- [x] I have tested these changes locally
- [x] I have updated the documentation
- [x] I have added a transaction link

let me know if you have any questions :D
  • Loading branch information
thearyanag authored Jan 24, 2025
2 parents f7fd180 + b909310 commit 776e94a
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 12 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ console.log("Token Mint Address:", result.mint.toString());
```
### Create NFT Collection on 3Land
```typescript
const isDevnet = true; // (Optional) if not present TX takes place in Mainnet
const isDevnet = false; // (Optional) if not present TX takes place in Mainnet
const priorityFeeParam = 1000000; // (Optional) if not present the default priority fee will be 50000

const collectionOpts: CreateCollectionOptions = {
collectionName: "",
Expand All @@ -146,6 +147,7 @@ const isDevnet = true; // (Optional) if not present TX takes place in Mainnet
const result = await agent.create3LandCollection(
collectionOpts,
isDevnet, // (Optional) if not present TX takes place in Mainnet
priorityFeeParam, //(Optional)
);
```

Expand All @@ -154,6 +156,7 @@ When creating an NFT using 3Land's tool, it automatically goes for sale on 3.lan
```typescript
const isDevnet = true; // (Optional) if not present TX takes place in Mainnet
const withPool = true; // (Optional) only present if NFT will be created with a Liquidity Pool for a specific SPL token
const priorityFeeParam = 1000000; // (Optional) if not present the default priority fee will be 50000
const collectionAccount = ""; //hash for the collection
const createItemOptions: CreateSingleOptions = {
itemName: "",
Expand All @@ -174,6 +177,7 @@ const result = await agent.create3LandNft(
createItemOptions,
isDevnet, // (Optional) if not present TX takes place in Mainnet
withPool
priorityFeeParam, //(Optional)
);

```
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@
"node": ">=22.0.0",
"pnpm": ">=8.0.0"
},
"keywords": ["solana", "agent", "ai", "solana agent kit", "sendai"],
"keywords": [
"solana",
"agent",
"ai",
"solana agent kit",
"sendai"
],
"author": "sendaifun",
"license": "Apache-2.0",
"dependencies": {
"@3land/listings-sdk": "^0.0.6",
"@3land/listings-sdk": "^0.0.7",
"@ai-sdk/openai": "^1.0.11",
"@bonfida/spl-name-service": "^3.0.7",
"@cks-systems/manifest-sdk": "0.1.59",
Expand All @@ -36,14 +42,14 @@
"@langchain/openai": "^0.3.16",
"@lightprotocol/compressed-token": "^0.17.1",
"@lightprotocol/stateless.js": "^0.17.1",
"@mercurial-finance/dynamic-amm-sdk": "^1.1.19",
"@metaplex-foundation/digital-asset-standard-api": "^1.0.4",
"@metaplex-foundation/mpl-core": "^1.1.1",
"@metaplex-foundation/mpl-token-metadata": "^3.3.0",
"@metaplex-foundation/mpl-toolbox": "^0.9.4",
"@metaplex-foundation/umi": "^0.9.2",
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
"@metaplex-foundation/umi-web3js-adapters": "^0.9.2",
"@mercurial-finance/dynamic-amm-sdk": "^1.1.19",
"@meteora-ag/alpha-vault": "^1.1.7",
"@meteora-ag/dlmm": "^1.3.0",
"@onsol/tldparser": "^0.6.7",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/agent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ export class SolanaAgentKit {
async create3LandCollection(
collectionOpts: CreateCollectionOptions,
isDevnet: boolean = false,
priorityFeeParam?: number,
): Promise<string> {
const optionsWithBase58: StoreInitOptions = {
privateKey: this.wallet.secretKey,
Expand All @@ -728,7 +729,11 @@ export class SolanaAgentKit {
optionsWithBase58.isMainnet = true;
}

const tx = await createCollection(optionsWithBase58, collectionOpts);
const tx = await createCollection(
optionsWithBase58,
collectionOpts,
priorityFeeParam,
);
return `Transaction: ${tx}`;
}

Expand All @@ -737,6 +742,7 @@ export class SolanaAgentKit {
createItemOptions: CreateSingleOptions,
isDevnet: boolean = false,
withPool: boolean = false,
priorityFeeParam?: number,
): Promise<string> {
const optionsWithBase58: StoreInitOptions = {
privateKey: this.wallet.secretKey,
Expand All @@ -753,6 +759,7 @@ export class SolanaAgentKit {
createItemOptions,
!isDevnet,
withPool,
priorityFeeParam,
);
return `Transaction: ${tx}`;
}
Expand Down
3 changes: 3 additions & 0 deletions src/langchain/3land/create_collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class Solana3LandCreateCollection extends Tool {
collectionDescription (required): the description of the collection
mainImageUrl (required): the image of the collection
coverImageUrl (optional): the cover image of the collection
priorityFeeParam (optional): default value is 50000, if tx doesnt land this param can help it land
`;

constructor(private solanaKit: SolanaAgentKit) {
Expand All @@ -29,6 +30,7 @@ export class Solana3LandCreateCollection extends Tool {
const collectionDescription = inputFormat?.collectionDescription;
const mainImageUrl = inputFormat?.mainImageUrl;
const coverImageUrl = inputFormat?.coverImageUrl;
const priorityFeeParam = inputFormat?.priorityFeeParam;

const collectionOpts: CreateCollectionOptions = {
...(collectionSymbol && { collectionSymbol }),
Expand All @@ -41,6 +43,7 @@ export class Solana3LandCreateCollection extends Tool {
const tx = await this.solanaKit.create3LandCollection(
collectionOpts,
!isMainnet,
priorityFeeParam,
);
return JSON.stringify({
status: "success",
Expand Down
3 changes: 3 additions & 0 deletions src/langchain/3land/create_single.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class Solana3LandCreateSingle extends Tool {
poolName (optional): the name of the pool
isMainnet (required): defines if the tx takes places in mainnet
withPool (optional): defines if minted edition will be tied to a liquidity pool
priorityFeeParam (optional): default value is 50000, if tx doesnt land this param can help it land
`;

constructor(private solanaKit: SolanaAgentKit) {
Expand All @@ -32,6 +33,7 @@ export class Solana3LandCreateSingle extends Tool {
const isMainnet = inputFormat.isMainnet;
const withPool = inputFormat.withPool;
const poolName = inputFormat.poolName;
const priorityFeeParam = inputFormat?.priorityFeeParam;

const collectionAccount = inputFormat.collectionAccount;

Expand Down Expand Up @@ -78,6 +80,7 @@ export class Solana3LandCreateSingle extends Tool {
createItemOptions,
!isMainnet,
withPool,
priorityFeeParam,
);
return JSON.stringify({
status: "success",
Expand Down
4 changes: 4 additions & 0 deletions src/tools/3land/create_3land_collectible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import {
export async function createCollection(
optionsWithBase58: StoreInitOptions,
collectionOpts: CreateCollectionOptions,
priorityFeeParam?: number,
) {
try {
const collection = await createCollectionImp(
optionsWithBase58,
collectionOpts,
priorityFeeParam,
);
return collection;
} catch (error: any) {
Expand All @@ -39,6 +41,7 @@ export async function createSingle(
createItemOptions: CreateSingleOptions,
isMainnet: boolean = false,
withPool: boolean = false,
priorityFeeParam?: number,
) {
try {
const landStore = isMainnet
Expand All @@ -52,6 +55,7 @@ export async function createSingle(
createItemOptions,
true, //isAI
withPool,
priorityFeeParam,
);
return singleEditionTx;
} catch (error: any) {
Expand Down
9 changes: 7 additions & 2 deletions test/tools/3land.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const agent = new SolanaAgentKit(
{ OPENAI_API_KEY: process.env.OPENAI_API_KEY! },
);

const isDevnet = true;
const isDevnet = false;

/****************************** CREATING COLLECTION ******************************** */

Expand All @@ -24,10 +24,13 @@ const collectionOpts: CreateCollectionOptions = {
mainImageUrl: "",
};

//const priorityFeeParam = 100000;

(async () => {
const collection = await agent.create3LandCollection(
collectionOpts,
isDevnet,
//priorityFeeParam,
);

console.log("collection: ", collection);
Expand All @@ -42,20 +45,22 @@ const createItemOptions: CreateSingleOptions = {
itemSymbol: "",
itemDescription: "",
traits: [{ trait_type: "", value: "" }],
price: 100000000, //100000000 == 0.1 sol,
price: 1000000, //100000000 == 0.1 sol,
splHash: "",
poolName: "",
mainImageUrl: "",
};

const withPool = true;
//const priorityFeeParam = 100000;

(async () => {
const result = agent.create3LandNft(
collectionAccount,
createItemOptions,
isDevnet,
withPool,
//priorityFeeParam,
);
console.log("result: ", result);
})();
Expand Down

0 comments on commit 776e94a

Please sign in to comment.