> For the complete documentation index, see [llms.txt](https://docs.chiliz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chiliz.com/tr/gelistir/gelismis/nft-ile-calisma/rarible-ile-minting.md).

# Rarible ile Minting

Rarible, birçok EVM ağında NFT uygulamaları oluşturmak için SDK'lar ve API'ler sağlayan çok zincirli bir NFT protokolü ve pazaryeridir.

NFT basımı için [Rarible Multichain SDK](https://docs.rarible.org/reference/getting-started), kendi veya paylaşılan koleksiyonlara basım yapmanızı ve anında satış emirleri oluşturmanızı sağlar.

Rarible SDK IPFS yüklemesini yönetmediğinden, buradaki örneklerimizde [Pinata](https://pinata.cloud/) IPFS barındırma hizmeti olarak kullanılmaktadır. JWT anahtarı almak için bir Pinata hesabına ihtiyacınız olacaktır.

Ayrıca şunlara da ihtiyacınız olacak:

* Chiliz Chain'de önceden deploy edilmiş bir ERC-721 sözleşmesi. Chiliz Chain'de kendiniz bir [OpenZeppelin ERC-721 sözleşmesi](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol) deploy etmeniz gerekir. [Remix IDE](https://remix.ethereum.org/) bunu yapabileceğiniz tarayıcı tabanlı bir IDE sunar. Bir blok gezgini kullanarak sözleşmeyi doğrulamayı unutmayın!
* Bir Rarible API anahtarı. Nasıl edinileceği için başlangıç kılavuzlarına bakın:

{% embed url="<https://docs.rarible.org/docs/rarible-protocol>" %}

Rarible SDK'yı kullanmak için birkaç kurulum yapmamız gerekir:

```bash
npm i @rarible/sdk @rarible/types ethers dotenv pinata
```

{% hint style="warning" %}
Diğer bölümlerde kullandığımız `viem`'e alternatif olan `ethers` kullandığımıza dikkat edin.\
Gerçekten de [Rarible, geliştiricilere](https://docs.rarible.org/reference/getting-started#interacting-with-evm-wallets) Web3 cüzdanlarıyla çalışmak için ethers.js veya web3.js kullanmalarını öneriyor — ve [web3.js](https://web3js.org/#/) [Mart 2025'te kullanımdan kaldırıldı](https://blog.chainsafe.io/web3-js-sunset/), bu da `ethers`'ı fiili tercih haline getirdi.
{% endhint %}

## NFT Koleksiyonu Basımı

Önce .env dosyanızı oluşturun:

```
# Chiliz RPC
RPC_URL=https://spicy-rpc.chiliz.com       # veya Mainnet RPC'si
PRIVATE_KEY=0xabc...                       # basım yapan anahtarı (yalnızca sunucu tarafında)

# Rarible
RARIBLE_API_KEY=your_rarible_api_key
COLLECTION_ADDRESS=0xYourCollectionOnChiliz
SUPPLY=1                                   # 1 = ERC-721, >1 = ERC-1155

# Pinata
PINATA_JWT=eyJhbGciOi...                   # Panodan Pinata JWT
PINATA_GATEWAY=your-subdomain.mypinata.cloud

# Medya / meta veri girdileri
IMAGE_PATH=./art/image.png
NAME=My Chiliz NFT
DESCRIPTION=Minted on-chain via Rarible SDK

```

Tercih ettiğimiz iş akışı şöyledir:

1. Medyayı Pinata aracılığıyla IPFS'e yükleme
2. Meta veri dosyasını oluşturma ve yükleme
3. Rarible SDK + zincir üstü basım

İşte ilham alabileceğiniz tam örnek komut dosyası:

{% code overflow="wrap" lineNumbers="true" fullWidth="true" %}

```bash
import 'dotenv/config'
import fs from 'fs'
import path from 'path'
import { Wallet, JsonRpcProvider } from 'ethers'
import { createRaribleSdk } from '@rarible/sdk'
import { toCollectionId, toUnionAddress } from '@rarible/types'
import { PinataSDK } from 'pinata'

function guessMime(p: string) {
  const ext = path.extname(p).toLowerCase()
  if (ext === '.png') return 'image/png'
  if (ext === '.jpg' || ext === '.jpeg') return 'image/jpeg'
  if (ext === '.webp') return 'image/webp'
  if (ext === '.gif') return 'image/gif'
  if (ext === '.mp4') return 'video/mp4'
  if (ext === '.webm') return 'video/webm'
  return 'application/octet-stream'
}

async function main() {
  // Medyayı IPFS'e yükle
  const pinata = new PinataSDK({
    pinataJwt: process.env.PINATA_JWT!,
  })

  const mediaPath = process.env.IMAGE_PATH!
  const mediaBlob = new Blob([fs.readFileSync(mediaPath)], { type: guessMime(mediaPath) })
  const mediaFile = new File([mediaBlob], path.basename(mediaPath), { type: guessMime(mediaPath) })

  const mediaUpload = await pinata.upload.public.file(mediaFile)
  const imageUri = `ipfs://${mediaUpload.cid}`
  // console.log('imageUri:', imageUri)

  // Meta veri dosyasını oluştur ve yükle
  const metadata = {
    name: process.env.NAME!,
    description: process.env.DESCRIPTION!,
    image: imageUri,
    // animation_url: "ipfs://<cid>/video.mp4",
    // attributes: [{ trait_type: "Tier", value: "Gold" }],
  }
  const metaUpload = await pinata.upload.public.json(metadata)
  const metadataUri = `ipfs://${metaUpload.cid}`
  // console.log('metadataUri:', metadataUri)

  // Rarible zincir üstü basımı
  const provider = new JsonRpcProvider(process.env.RPC_URL!)
  const wallet = new Wallet(process.env.PRIVATE_KEY!, provider)
  const sdk = createRaribleSdk(wallet, 'prod', { apiKey: process.env.RARIBLE_API_KEY! })

  // Union ID'leri "<BLOCKCHAIN>:<address>" formatını kullanır — burada BLOCKCHAIN "CHILIZ"'dır
  const collectionId = toCollectionId(`CHILIZ:${process.env.COLLECTION_ADDRESS}`)
  const creator = toUnionAddress(`CHILIZ:${wallet.address}`)

  const { transaction, itemId } = await sdk.nft.mint({
    collectionId,
    uri: metadataUri,
    supply: Number(process.env.SUPPLY || 1), // 721 için 1, 1155 için >1
  })

  const { hash } = await transaction.wait()
  console.log('Minted item:', itemId, 'tx:', hash)
}

main().catch((e) => (console.error(e), process.exit(1)))

```

{% endcode %}

## NFT Koleksiyonunun Tembel Basımı

Tembel Basım, bir NFT'yi satışa çıkarmadan önce peşin basım maliyetini ödemek istemeyenler için bir seçenektir. NFT'lerini satın alınmak üzere listeleyebilir, ardından yalnızca satın alındığında veya transfer edildiğinde basabilirler. Gas ücretleri böylece basım sürecinin bir parçası haline gelir ve alıcı tarafından ödenir.

Kısacası, tembel basım NFT'yi blockchain'e yalnızca biri satın aldığında yerleştirmek anlamına gelir, öncesinde değil.

Doğru tanımlanmış bir .env dosyasına ihtiyacınız olacak:

```
# Chiliz RPC / cüzdan
RPC_URL=https://spicy-rpc.chiliz.com
PRIVATE_KEY=0xabc...                         # yaratıcı anahtarı (gizli tutun)

# Rarible
RARIBLE_API_KEY=your_rarible_api_key
COLLECTION_ADDRESS=0xYourCollectionOnChiliz   # ERC-721 veya ERC-1155

# Pinata
PINATA_JWT=eyJhbGciOi...                      # Panodan Pinata JWT
PINATA_GATEWAY=your-subdomain.mypinata.cloud  # isteğe bağlı (önizlemeler için)

# Medya / meta veri
IMAGE_PATH=./art/image.png
NAME=My Chiliz NFT
DESCRIPTION=Lazy-minted on Rarible (Chiliz)
SUPPLY=1                                      # 721 için 1; 1155 baskıları için >1

```

Ve projenizi tembel basmak için örnek kod:

{% code overflow="wrap" lineNumbers="true" fullWidth="true" %}

```typescript
import 'dotenv/config'
import fs from 'fs'
import path from 'path'
import { Wallet, JsonRpcProvider } from 'ethers'
import { createRaribleSdk } from '@rarible/sdk'
import { toCollectionId, toUnionAddress } from '@rarible/types'
import { PinataSDK } from 'pinata'

function guessMime(p: string) {
  const ext = path.extname(p).toLowerCase()
  if (ext === '.png') return 'image/png'
  if (ext === '.jpg' || ext === '.jpeg') return 'image/jpeg'
  if (ext === '.webp') return 'image/webp'
  if (ext === '.gif') return 'image/gif'
  if (ext === '.mp4') return 'video/mp4'
  if (ext === '.webm') return 'video/webm'
  return 'application/octet-stream'
}

async function main() {
  // Medyayı IPFS'e yükle
  const pinata = new PinataSDK({
    pinataJwt: process.env.PINATA_JWT!,
  })

  const mediaPath = process.env.IMAGE_PATH!
  const mediaBlob = new Blob([fs.readFileSync(mediaPath)], { type: guessMime(mediaPath) })
  const mediaFile = new File([mediaBlob], path.basename(mediaPath), { type: guessMime(mediaPath) })
  const mediaUp = await pinata.upload.public.file(mediaFile)
  const imageUri = `ipfs://${mediaUp.cid}`

  const metadata = {
    name: process.env.NAME!,
    description: process.env.DESCRIPTION!,
    image: imageUri,
    // animation_url: "ipfs://<cid>/video.mp4",
    // attributes: [{ trait_type: "Tier", value: "Gold" }],
  }
  const metaUp = await pinata.upload.public.json(metadata)
  const metadataUri = `ipfs://${metaUp.cid}`

  // Rarible tembel basımı
  const provider = new JsonRpcProvider(process.env.RPC_URL!)
  const wallet = new Wallet(process.env.PRIVATE_KEY!, provider)
  const sdk = createRaribleSdk(wallet, 'prod', { apiKey: process.env.RARIBLE_API_KEY! })
  const collectionId = toCollectionId(`CHILIZ:${process.env.COLLECTION_ADDRESS}`)
  const creator = toUnionAddress(`CHILIZ:${wallet.address}`)

  // Tembel basımı hazırla ve gönder (zincir dışı öğe; alıcı satın alımda basar)
  const prepared = await sdk.nft.mint.prepare({ collectionId })
  const result = await prepared.submit({
    uri: metadataUri,
    supply: Number(process.env.SUPPLY || 1),     // 721 için 1; 1155 için >1
    lazyMint: true,                              // Evet, tembel yapın lütfen
    creators: [{ account: creator, value: 10000 }], // %100 cüzdanınıza gider
    royalties: [],                               // örn. [{ account: creator, value: 500 }] %5 için
  })

  // console.log('Lazy itemId:', result.itemId)
}

main().catch((e) => (console.error(e), process.exit(1)))

```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.chiliz.com/tr/gelistir/gelismis/nft-ile-calisma/rarible-ile-minting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
