# zNS Data Store Schemas
## Message Schemas
There is a unified schema for all messages that are used.
Messages have different types, each type may extend the schema.
### Base Message
This is the base schema, all messages share this data at a minimum.
```json
interface BaseMessage {
event: string, // This is the type of message, e.g. "Create Domain", "Create Bid", etc.
timestamp: Date, // Time that the message was created
version: number // The version of this JSON.
}
```
### zNS Messages
#### Domain Messages
This is the schema of a message from a Domain Event. Domain events include when the domain is created, transferred, or the royalty has changed.
```json
interface DomainCreatedMessage { // When a new domain or subdomain is created by a user
event: "DomainCreated",
timestamp: Date,
version: number,
blockNumber: number,
logIndex: number,
data: {
id: string, // id of the domain
parentId: string, // id of the parent domain if a parent exists, otherwise 0
name: string, // label of the full domain string, e.g. "wilder.kittens.fun"
label: string, // name of the domain or subdomain, e.g. "fun"
owner: string // address of the creator of this new domain
}
}
interface DomainTransferredMessage { // When an existing domain's owner changes.
event: "DomainTransferred",
timestamp: Date,
version: number,
blockNumber: number,
logIndex: number,
data: {
id: string,
from: string, // "from" address in transfer
to: string, // "to" address in transfer
}
}
interface DomainRoyaltyChangedMessage {
event: "DomainRoyaltyChanged",
timestamp: Date,
version: number,
blockNumber: number,
logIndex: number,
data: {
id: string,
amount: string // the updated domain royalty amount
}
}
```
#### DomainMetadata Messages
This is the schema of a message from a DomainMetadata Event. Domain Metadata events include when the metadata of a domain is locked, unlocked, or changed.
```json
interface DomainMetadataLockedMessage {
event: "DomainMetadataLocked",
timestamp: Date,
version: number,
blockNumber: number,
logIndex: number,
data: {
id: string,
locker: string, // address of the account that locked the metadata
}
}
interface DomainMetadataUnlockedMessage {
event: "DomainMetadataUnlocked",
timestamp: Date,
version: number,
blockNumber: number,
logIndex: number,
data: {
id: string
}
}
interface DomainMetadataChangedMessage {
event: "DomainMetadataChanged",
timestamp: Date,
version: number,
blockNumber: number,
logIndex: number,
data: {
id: string,
uri: string // URI to the updated metadata information
}
}
```
### zAuction Messages
#### Bid Messages
This is the schema of a message from a Bid Event in zAuction. Bid events include when a new bid is created, an existing bid is canceled, or an existing bid is accepted.
```json
interface BidPlacedMessage {
event: "BidPlaced",
timestamp: Date,
version: number,
blockNumber: number,
logIndex: number,
data: {
nftId: string,
account: string,
auctionId: string,
bidAmount: string,
minimumBid: string,
contractAddress: string,
startBlock: string,
expireBlock: string,
tokenId: string,
signedMessage: string,
date: number
}
}
interface BidCancelledMessage {
event: "BidCancelled",
timestamp: Date,
version: number,
blockNumber: number,
logIndex: number,
data: {
account: string,
auctionId: string
}
}
interface BidAcceptedMessage {
event: "BidAccepted",
timestamp: Date,
blockNumber: number,
logIndex: number,
data: {
auctionId: string,
bidder: string,
seller: string,
amount: string,
nftAddress: string,
tokenId: string,
expireBlock: string
}
}
```
### Staking Messages
```json
interface DomainStakingRequestPlacedMessage {
event: "DomainStakingRequestPlaced",
timestamp: Date,
version: number,
blockNumber: number,
logIndex: number,
data: {
requestId: string, // Used to track the request
parentId: string, // The ID of the parent domain if applicable
offeredAmount: string, // amount to be staked
requestUri: string, // metadata
name: string,
requestor: string, // address of the account making a request
domainToken: string, // The hex address of the domain to be staked
}
}
interface DomainStakingRequestApprovedMessage {
event: "DomainStakingRequestApproved",
timestamp: Date,
version: number,
blockNumber: number,
logIndex: number,
data: {
requestId: string // green light, domain not minted yet though
}
}
interface DomainStakingRequestFulfilledMessage {
event: "DomainStakingRequestFulfilled",
timestamp: Date,
version: number,
blockNumber: number,
logIndex: number,
data: {
requestId: string,
parentID: string,
name: string,
domainId: string,
domainToken: string,
recipient: string
}
}
```