{"id":13455391,"url":"https://github.com/candypay/nft-sdk","last_synced_at":"2025-03-24T08:32:20.809Z","repository":{"id":45143234,"uuid":"513105061","full_name":"candypay/nft-sdk","owner":"candypay","description":"🏄‍♂️ CandyPay NFT SDK lets you effortlessly create NFT minting functions for Candy Machine v2 collections. ","archived":false,"fork":false,"pushed_at":"2022-11-03T16:28:18.000Z","size":477,"stargazers_count":29,"open_issues_count":1,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-09-18T14:13:51.564Z","etag":null,"topics":["blockchain","candy-machine","candy-machine-v2","nft","sdk","solana","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@candypay/sdk","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/candypay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-12T10:53:57.000Z","updated_at":"2024-07-30T08:44:11.000Z","dependencies_parsed_at":"2022-09-26T16:20:20.797Z","dependency_job_id":null,"html_url":"https://github.com/candypay/nft-sdk","commit_stats":null,"previous_names":["candypay/sdk"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/candypay%2Fnft-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/candypay%2Fnft-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/candypay%2Fnft-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/candypay%2Fnft-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/candypay","download_url":"https://codeload.github.com/candypay/nft-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221947553,"owners_count":16906145,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","candy-machine","candy-machine-v2","nft","sdk","solana","typescript"],"created_at":"2024-07-31T08:01:04.799Z","updated_at":"2024-10-28T22:30:59.240Z","avatar_url":"https://github.com/candypay.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# `@candypay/sdk`\n\nCandyPay SDK lets you effortlessly create NFT minting functions for Candy Machine v2 collections. Simulate minting transactions for multiple use-cases like NFT collection launch, gasless mint and many more on Solana Blockchain!\n\n## Installation\n\n```bash\nnpm install @candypay/sdk @project-serum/anchor\n```\n\n## Setup\n\nThe entry point to the SDK is a `CandyPay` instance that will give you access to its API.\n\n```ts\nimport { CandyPay } from \"@candypay/sdk\";\n\nconst candypay = new CandyPay();\n```\n\n## Candy Machine module\n\nThe `candyMachine` module can be accessed via `candypay.candyMachine()` and provides the following methods:\n\n- [mint](#mint)\n- [gasless](#gasless)\n\n### `mint`\n\nThe `mint` method returns the transaction object with the all the required instructions for minting a Candy Machine v2 in the default way, where the end-user would pay the gas fees.\n\n**Parameters**:\n\n- `network`: The cluster where the transaction would take place i.e either `mainnet-beta` or `devnet`\n- `candyMachineId`: The address of the Candy Machine\n- `user`: The public key of the end-user\n- `rpc_url` (optional): Custom RPC URL\n\n**Response**:\n\n- `transaction`: The transaction object containing all the required instructions\n- `blockhash`: Blockhash which is being used in the transaction\n- `lastValidBlockHeight`: The last valid block height after which the transaction is declared expired\n- `signers`: Array of signers which should be passed while sending the transaction to the network\n- `mint`: The mint keypair which is used to sign the transaction\n\n**Example**:\n\n```ts\nimport { CandyPay } from \"@candypay/sdk\";\nimport * as anchor from \"@project-serum/anchor\";\nimport dotenv from \"dotenv\";\nimport base58 from \"bs58\";\n\ndotenv.config();\n\nconst sdk = new CandyPay();\nconst connection = new anchor.web3.Connection(\n  \"https://metaplex.devnet.rpcpool.com\"\n);\nconst CANDY_MACHINE_ID = new anchor.web3.PublicKey(\n  \"GrVSy3ZRbuw5ACbwSEMsj9gULk9MW7QPK1TUYcP6nLM\"\n);\nconst PAYER = anchor.web3.Keypair.fromSecretKey(\n  base58.decode(process.env.PAYER_SECRET_KEY!)\n);\n\nconst { transaction, mint } = await sdk.candyMachine.mint({\n  candyMachineId: CANDY_MACHINE_ID,\n  network: \"devnet\",\n  user: PAYER.publicKey,\n});\n\nconst signature = await anchor.web3.sendAndConfirmTransaction(\n  connection,\n  transaction,\n  [PAYER, mint]\n);\n\nconsole.log(`Signature - ${signature}`);\n```\n\n### `gasless`\n\nThe `gasless` method returns the transaction object with the all the required instructions for minting a Candy Machine v2 in the gasless way, where the end-user doesn't need pay the gas fees.\n\n**Parameters**:\n\n- `network`: The cluster where the transaction would take place i.e either `mainnet-beta` or `devnet`\n- `candyMachineId`: The address of the Candy Machine from which the NFT would to be minted\n- `payer`: The public key of the wallet which would pay the gas fees of the transaction\n- `user`: The public key of the end-user\n- `rpc_url` (optional): Custom RPC URL\n\n**Response**:\n\n- `transaction`: The transaction object containing all the required instructions\n- `blockhash`: The blockhash which is being used in the transaction\n- `lastValidBlockHeight`: The last valid block height after which the transaction is declared expired\n- `signers`: Array of signers which should be passed while sending the transaction to the network\n- `mint`: The mint keypair which is used to sign the transaction\n\n**Example**:\n\n```ts\nimport { CandyPay } from \"@candypay/sdk\";\nimport * as anchor from \"@project-serum/anchor\";\nimport dotenv from \"dotenv\";\nimport base58 from \"bs58\";\n\ndotenv.config();\n\nconst sdk = new CandyPay();\nconst connection = new anchor.web3.Connection(\n  \"https://metaplex.devnet.rpcpool.com\"\n);\n\nconst CANDY_MACHINE_ID = new anchor.web3.PublicKey(\n  \"GrVSy3ZRbuw5ACbwSEMsj9gULk9MW7QPK1TUYcP6nLM\"\n);\nconst PAYER = anchor.web3.Keypair.fromSecretKey(\n  base58.decode(process.env.PAYER_SECRET_KEY!)\n);\nconst USER = new anchor.web3.PublicKey(\n  \"2S9jKJEGKoVxR3xkEfFyGVrLwJj1H8xYjqtSP5LAX97x\"\n);\n\nconst { transaction, mint } = await sdk.candyMachine.gasless({\n  candyMachineId: CANDY_MACHINE_ID,\n  network: \"devnet\",\n  payer: PAYER.publicKey,\n  user: USER,\n});\n\nconst signature = await anchor.web3.sendAndConfirmTransaction(\n  connection,\n  transaction,\n  [PAYER, mint]\n);\n\nconsole.log(`Signature - ${signature}`);\n```\n\n## NFT module\n\nThe `nft` module can be accessed via `candypay.nft()` and provides the following methods:\n\n- [`airdrop`](#airdrop)\n\n### airdrop\n\nThe `airdrop` method allows you to airdrop certain NFT without having to create an NFT beforehand.\n\n**Parameters**:\n\n- `payer`: The public key of the wallet which would pay gas fees of the transaction\n- `owner`: The public key of user to whom the NFT would be airdropped\n- `network`: The cluster where the transaction would take place i.e either `mainnet-beta`, `devnet` or `testnet`\n- `metadata`: The metadata regarding the NFT\n- `rpc_url`: Custom RPC URL\n\n**Response**:\n\n- `signature`: The signature of the NFT airdrop transaction\n- `accounts`: The accounts related to the NFT airdrop transaction i.e mint account, metadata account, master edition account and token account\n- `blockhash`: The blockhash which is being used in the transaction\n\n**Example**:\n\n```ts\nimport { CandyPay } from \"@candypay/sdk\";\nimport * as anchor from \"@project-serum/anchor\";\nimport dotenv from \"dotenv\";\nimport base58 from \"bs58\";\n\ndotenv.config();\n\nconst PAYER = anchor.web3.Keypair.fromSecretKey(\n  base58.decode(process.env.PAYER_SECRET_KEY!)\n);\nconst USER = new anchor.web3.PublicKey(\n  \"2S9jKJEGKoVxR3xkEfFyGVrLwJj1H8xYjqtSP5LAX97x\"\n);\n\nconst sdk = new CandyPay();\n\nconst { signature } = await sdk.nft.airdrop({\n  metadata: {\n    name: \"DeGod\",\n    uri: \"https://metadata.degods.com/g/4924.json\",\n    symbol: \"DEGOD\",\n    collection: null,\n    sellerFeeBasisPoints: 1000,\n    creators: [\n      {\n        address: PAYER.publicKey,\n        share: 100,\n      },\n    ],\n    uses: null,\n  },\n  network: \"devnet\",\n  owner: USER,\n  payer: PAYER,\n});\n\nconsole.log(`Signature - ${signature}`);\n```\n\n## Using the SDK with Next.js\n\nUsing our SDK with Next.js can sometimes run in build time error cause of [Anchor](https://npmjs.com/package/@project-serum/anchor) library using the node native \"fs\" module. We highly recommend adding this export in `next.config.js` file before deployment:\n\n```js\nmodule.exports = {\n  webpack: (config, { isServer }) =\u003e {\n    if (!isServer) {\n      config.resolve.fallback.fs = false;\n    }\n    return config;\n  },\n};\n```\n\n## Get in Touch\n\n- Twitter: [@candypayfun](https://twitter.com/candypayfun)\n- Discord: [Join Now](https://discord.com/invite/VGjPXWUHGT)\n- Email: [hello@candypay.fun](mailto:hello@candypay.fun)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcandypay%2Fnft-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcandypay%2Fnft-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcandypay%2Fnft-sdk/lists"}