One of the features you can implement using the Rarible SDK is the ability to add a front-end fee to your application and monetize. This article will guide you through the process of implementing this feature.
Any application can put custom fees in listings or bids which are made by application's users. So when this order get executed on-chain, these fees are transferred automatically to respective addresses.
Prerequisite
Follow our Getting started guide to install needed libraries and instantiate SDK.
Implementing Front-End Fee
To implement a front-end fee, you'll need to interact with the relevant functions through the SDK. This typically involves specifying the fee percentage and the recipient address.
Here we show how to list item and specify frontend-fee:
// Replace X with contract address and Y with token id of the NFT to list
const orderId = await sdk.order.sell({
itemId: toItemId("ETHEREUM:X:Y"),
amount: 1,
currency: toCurrencyId("ETHEREUM:native"),
price: "0.5",
originFees: [{
account: toUnionAddress("ETHEREUM:0xxxxx"), // Address of the fee reciver
value: 1000 // Part of the funds to be taken as fees (in basis points. so 1000 means 10%)
}]
})
This code fragment show how to use field originFees
to specify array of fee receivers. You can do the same with bid, buy and acceptBid functions