Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"type: docs" #399

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
"type: docs"
  • Loading branch information
VitalyLyaper committed Oct 31, 2022
commit 09585d13d22360c8a1122af0681df3539e7fcef8
50 changes: 50 additions & 0 deletions docs/reference/buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Buy NFT with Rarible Protocol
description: How to buy NFT using Rarible Multichain Protocol
---

# Prerequisites

To buy NFT with Rarible Protocol you should have order id for NFT you are interested in - you can get order id with [Rarible API](search-capabilities.md)

You can buy NFTs with Rarible Multichain Protocol on different blockchains.

--8<-- "docs/snippets/preparation-sdk.md"

# Buy an NFT

You can buy any NFTfor which sell order is created

Use `buy` function:

```typescript
import { createRaribleSdk } from "@rarible/sdk"
import { toOrderId} from "@rarible/types"

async function buyNft(orderId: string) {
const sdk = createRaribleSdk(wallet, "dev")

// Get order info
const buy = await sdk.order.buy({
toOrderId(orderId),
})
// buy: {
// baseFee: number
// maxAmount: BigNumber
// multiple: boolean
// submit: Function
// supportsPartialFill: boolean
// }

// Send transaction
const result = await buy.submit(
amount: 1, //amount of NFTs you want to buy
)
// result: IBlockchainTransaction
}
```

* `orderId` — Id of NFT sale order, has format `${blockchain}:${orderId}`. For example, `ETHEREUM:0x19f487016770542dc6137b06499a4f7b42c9580f12d85d6347964b03b7682143`
* `amount` — amount of NFT tokens you want to buy

See more information about usage Protocol SDK on [https://github.com/rarible/sdk](https://github.com/rarible/sdk)
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ nav:
- "Mint": "reference/mint.md"
- "Sell Order": "reference/order.md"
- "Mint and Sell": "reference/mint-and-sell.md"
- "Buy NFT": "reference/buy.md"
- "Create and Accept Bid": "reference/bid.md"
- "Transfer": "reference/transfer.md"
- "Burn": "reference/burn.md"
Expand Down