> For the complete documentation index, see [llms.txt](https://picardy-protocol.gitbook.io/picardy-protocol-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://picardy-protocol.gitbook.io/picardy-protocol-docs/builders-den/token-royalty-sale-factory.md).

# Token Royalty Sale Factory

The TokenRoyaltySaleFactory smart contract is a factory contract that allows the creation of TokenRoyaltySale contracts. A TokenRoyaltySale contract is a contract that allows the sale of royalties as an ERC20 token.

The factory contract maintains a mapping of TokenRoyaltySale contracts, indexed by the token royalty ID, as well as a mapping of TokenRoyaltyDetails, which holds details about the TokenRoyaltySale contracts. It also maintains a struct called RoyaltyDetails, which holds the percentage of royalties to be paid and the address of the party receiving the royalties.

### TokenRoyaltySaleFactoryV2

#### TokenRoyaltyDetails

```
struct TokenRoyaltyDetails {
  uint256 tokenRoyaltyId;
  uint256 askAmount;
  uint256 returnPercentage;
  address tokenRoyaltyAddress;
}
```

#### RoyaltyDetails

```
struct RoyaltyDetails {
  uint256 royaltyPercentage;
  address royaltyAddress;
}
```

#### createTokenRoyalty

```
function createTokenRoyalty(uint256 _askAmount, uint256 _returnPercentage, string creatorName, string name, address creator) external returns (address)
```

*Creats A ERC20 token royalty sale. contract is created using the Clones library*

**Parameters**

| Name               | Type    | Description                          |
| ------------------ | ------- | ------------------------------------ |
| \_askAmount        | uint256 | The total askinng amount for royalty |
| \_returnPercentage | uint256 | Percentage of royalty to sell        |
| creatorName        | string  |                                      |
| name               | string  |                                      |
| creator            | address |                                      |

#### updateRoyaltyDetails

```
function updateRoyaltyDetails(uint256 _royaltyPercentage) external
```

the function is used to update the royalty percentage.

*only hub admin can call this function*

**Parameters**

| Name                | Type    | Description                             |
| ------------------- | ------- | --------------------------------------- |
| \_royaltyPercentage | uint256 | the amount in percentage the hub takes. |

#### getRoyaltyDetails

```
function getRoyaltyDetails() external view returns (address, uint256)
```

#### getTokenRoyaltyAddress

```
function getTokenRoyaltyAddress(string creatorName, string name) external view returns (address)
```

#### getRoyaltySaleDetails

```
function getRoyaltySaleDetails(address _royaltySaleAddress) external view returns (struct TokenRoyaltySaleFactoryV2.TokenRoyaltyDetails)
```

#### getHubAddress

```
function getHubAddress() external view returns (address)
```

#### getLinkToken

```
function getLinkToken() external view returns (address)
```
