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:
- Property Tokens address
- Royaly amount
- Dev Kit JS
- Polygon/Arbitrum and their testnets
- Ethereum
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
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@devprotocol/i-s-tokens/contracts/interfaces/ISTokensManagerV2.sol";
contract usingstokenInterface {
ISTokensManagerV2 internal STokenQuery;
/**
* Network: Polygon Mainnet
* Address: 0x89904De861CDEd2567695271A511B3556659FfA2
*/
constructor() {
STokenQuery = ISTokensManagerV2(0x89904De861CDEd2567695271A511B3556659FfA2);
}
/**
* @dev Sets a resale royalty for the passed Property Tokens's STokens
* @param _propertyaddress Property address of particular property to set royalty for
* @param _royalty Royalty value (between 0 to 100)
* @return uint24 latest royalty value of a particular property's STokens
*/
function sTokenroyalty(
address _propertyaddress,
uint256 _royalty
) public
returns(uint24){
STokenQuery.setSTokenRoyaltyForProperty(_propertyaddress, _royalty);
uint24 newRoyalty = STokenQuery.royaltyOf(_propertyaddress);
return newRoyalty;
}
// similarly you can call other functions from the interface
}
See Ecosystem Addresses for lockup contract addresses.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@devprotocol/i-s-tokens/contracts/interfaces/ISTokensManager.sol";
import "@devprotocol/protocol/contracts/interface/IAddressConfig.sol";
contract usingstokenInterface {
IAddressConfig public addressConfig;
constructor(address _addressConfig) public {
addressConfig = IAddressConfig(_addressConfig);
}
/**
* @dev Sets a resale royalty for the passed Property Tokens's STokens
* @param _propertyaddress Property address of particular property to set royalty for
* @param _royalty Royalty value (between 0 to 100)
* @return uint24 latest royalty value of a particular property's STokens
*/
function sTokenroyalty(
address _propertyaddress,
uint256 _royalty
) public
returns(uint24){
ISTokensManager STokenQuery = ISTokensManager(addressConfig.lockup());
STokenQuery.setSTokenRoyaltyForProperty(_propertyaddress, _royalty);
uint24 newRoyalty = STokenQuery.royaltyOf(_propertyaddress);
return newRoyalty;
}
// similarly you can call other functions from the interface
}
See Ecosystem Addresses for lockup contract addresses.