Skip to main content

ERC-721 royalty

In Dev Protocol, ERC-721 tokens indicate a staking position for any of Property Tokens, have a specially extended interface, and are referred to as sTokens.

Set Royalty for STokens

Royalty is a percentage value used to calculate the royalty-amount against the sale value of an NFT

ERC20 owners or simply the property Author can set the royalty by executing the setSTokenRoyaltyForProperty function of STokenManager contract.

setSTokenRoyaltyForProperty function takes 3 arguments:

  1. Property Tokens address
  2. Royaly amount
import { clientsSTokens } from '@devprotocol/dev-kit'
import { whenDefined } from '@devprotocol/util-ts'
import type { BaseProvider } from '@ethersproject/providers'

// This function Sets a resale royalty for the passed Property Tokens's STokens & returns latest royalty value of a particular property's STokens
export default async (provider: BaseProvider) => {
const clients = await clientsSTokens(provider)
const sToken = whenDefined(clients, ([l1, l2]) => l1 ?? l2)
const set = await whenDefined(sToken, (contract) =>
contract.setSTokenRoyaltyForProperty(
// Property address
'0xDbc05b1eCB4fdaEf943819C0B04e9ef6df4bAbd6',
// Royalty value (between 0 to 100) (using 2 decimals - 10000 = 100, 0 = 0)
'10'
)
)
await set.wait()

const royalty = await whenDefined(sToken, (contract) =>
contract.royaltyOf(
// Property address
'0xDbc05b1eCB4fdaEf943819C0B04e9ef6df4bAbd6'
)
)
return royalty
}