Create Note
A character can create notes.
A note is typically an article published on the blockchain.
postNote
This creates a note.
postNote(characterId: BigNumberish, metadataOrUri: string | NoteMetadata, __namedParameters?: PostNoteOptions, overrides?: Overrides): Promise<Result<{ noteId: number; }, true>>
Usage
contract.postNote(
42,
"https://example.com/note.json",
);
The "https://example.com/note.json"
is the URI of the note metadata.
Parameters
characterId
- Type: BigNumberish
The ID of the character that creates the note.
metadataOrUri
- Type: string | NoteMetadata
The uri or metadata of the note.
Example:
contract.postNote(
42, // character ID
"https://example.com/note.json",
);
contract.postNote(
42, // character ID
{
title: "My Note",
content: "This is my note.",
tags: ["note", "example"],
},
);
options
(optional)
options.locked
(optional)
- Type: boolean
Whether the note is locked. Default: false
When a note is locked, it can't be updated anymore.
contract.postNote(
42,
"https://example.com/note.json",
{ locked: true },
);
options.linkModule
(optional)
This sets the link module for the note.
options.linkModule.address
- Type: string
The contract address of the link module.
options.linkModule.data
- Type: string
The data to be passed to the link module.
contract.postNote(
42,
"https://example.com/note.json",
{
linkModule: {
address: "0x1234567890123456789012345678901234567890",
data: ["0x1234567890123456789012345678901234567890", 10]
},
},
);
options.mintModule
(optional)
This sets the mint module for the note.
options.mintModule.address
- Type: string
The contract address of the mint module.
options.mintModule.data
- Type: string
The data to be passed to the mint module.
contract.postNote(
42,
"https://example.com/note.json",
{
mintModule: {
address: "0x1234567890123456789012345678901234567890",
data: ["0x1234567890123456789012345678901234567890", 10]
},
},
);
Returns
interface Retruns {
data: {
noteId: number
}
transactionHash: string
}
postNoteForNote
This creates a note for a note. This is useful for creating a note that is a reply to another note.
postNoteForNote(characterId: BigNumberish, metadataOrUri: string | NoteMetadata, targetCharacterId: BigNumberish, targetNoteId: BigNumberish, __namedParameters?: PostNoteOptions, overrides?: Overrides): Promise<Result<{ noteId: number; }, true>>
Usage
For example, if you (characterId: 42
) want to create a note that is a reply to a note with ID 1
from character with ID 64
, you can do:
contract.postNoteForNote(
42, // character ID
"https://example.com/note.json", // note metadata
64, // target character ID
1, // target note ID
);
Parameters
It shares the same parameters as postNote
except for the following:
targetCharacterId
- Type: BigNumberish
The ID of the character that created the note that is being replied to.
targetNoteId
- Type: BigNumberish
The ID of the note that is being replied to.
Returns
It shares the same return value as postNote
.
postNoteForAnyUri
This creates a note for any URI. This is useful for creating a note that is a comment on a URI.
postNoteForAnyUri(characterId: BigNumberish, metadataOrUri: string | NoteMetadata, targetUri: string, __namedParameters?: PostNoteOptions, overrides?: Overrides): Promise<Result<{ noteId: number; }, true>>
Usage
For example, if you (characterId: 42
) want to create a note that is a reply to a URI https://example.com
, you can do:
contract.postNoteForAnyUri(
42, // character ID
"https://example.com/note.json", // note metadata
"https://another-website.com/paper.pdf", // target URI
);
Parameters
It shares the same parameters as postNote
except for the following:
targetUri
- Type: string
The URI that is being commented on.
Returns
It shares the same return value as postNote
.