> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rawchunks.space/llms.txt
> Use this file to discover all available pages before exploring further.

# Royalties program

> Read the token configuration and license split, and understand the settlement instruction.

Royalties settles license payments in the configured token. Use [Remix instruction 4](/web3/programs/remix#instruction-4-buy-license) to buy a license and record its rights.

## Payment split

License payments send 80% to the recorded creator and 20% to the configured treasury. In atomic units:

```javascript theme={null}
const treasuryFee = price * 2_000n / 10_000n;
const creatorShare = price - treasuryFee;
```

Integer division rounds the treasury fee down; the creator receives the remainder. A price of `1_000_001` splits into `800_001` for the creator and `200_000` for the treasury.

## Token configuration

Read the Royalties config PDA derived from `['royalties']` under the Royalties program ID. Its [account layout](/web3/programs/accounts#configuration-accounts) contains the treasury and token mint. The verified devnet mint uses six decimals and the classic SPL Token Program.

All payment token accounts must use that mint. The payer signs for its token account, the creator token account belongs to the original creator, and the treasury token account belongs to the configured treasury.

## Instruction 1: distribute payment

The data layout is:

| Field | Encoding |
| - | - |
| Discriminator | First byte `1` |
| `songId`, `licensePrice` | Two u64 integers, little-endian |
| Expected creator | Optional 32-byte address; Remix supplies it |

Accounts, in order: **payer** (writable signer), **payer token account** (writable), **creator token account** (writable), **treasury token account** (writable), **Royalties config** (readonly), **SPL Token Program** (readonly).

This instruction transfers the split directly from the payer's token account. It does not create a license record. Remix supplies the original's price and creator when purchasing rights.

A zero amount returns without a token transfer. A wrong mint, treasury recipient or supplied creator rejects a priced transfer. The program logs `LicensePaymentDistributed` with the song ID, amount and both shares.

## Other instructions

| First byte | Operation | Permission |
| - | - | - |
| `0` | Initialize config with treasury and mint | Creates config once |
| `2` | Set token mint | Administrator |
| `3` | Set treasury | Administrator |
| `4` | Transfer administrator | Current administrator |

These configuration operations use the program's existing authority. Your product reads the selected deployment's configuration before constructing payment accounts.

[Royalties program source](https://github.com/rawchunks/blockchain/tree/main/programs/programs/royalties) · [Deployed programs](/web3/programs/deployed-programs)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.