SDK
crossbell.js
Contract API
Note
Update Note

Update Note

After you have created a note, you can update it.

setNoteUri

This sets (overwrites) the URI of the note.

setNoteUri(characterId: BigNumberish, noteId: BigNumberish, metadataOrUri: string | NoteMetadata, overrides?: Overrides): Promise<Result<{ metadata: NoteMetadata; uri: string; }, true>>

Usage

contract.setNoteMetadata(
  42, // characterId
  5, // noteId
  'https://example.com/new-metadata.json', // metadata uri
)

or:

contract.setNoteMetadata(
  42, // characterId
  5, // noteId
  {
    name: 'New Name',
    content: 'New Description',
  }, // metadata content
)
⚠️

The new metadata will overwrite the old metadata, so if you only want to update a single field, you'll need to fetch the existing metadata first and merge it with the new metadata. Otherwise, you'll lose the other fields. If you want to update a part of fields, you can use the changeNoteMetadata method instead.

Parameters

characterId

  • Type: BigNumberish

The ID of the character that owns the note.

noteId

  • Type: BigNumberish

The ID of the note to update.

metadataOrUri

The new metadata for the note. This can be either a string URI or a NoteMetadata object.

Returns

interface Returns {
  data: {
    metadata: NoteMetadata
    uri: string
  }
  transactionHash: string
}

Alternative: setNoteMetadata

This is the same as setNoteUri, but it only takes a NoteMetadata object instead of a string.

setNoteMetadata(characterId: BigNumberish, noteId: BigNumberish, metadata: NoteMetadata, overrides?: Overrides): Promise<Result<{ metadata: NoteMetadata; uri: string; }, true>>

changeNoteMetadata

This changes a part of fields of the note's metadata by merging the new metadata with the existing metadata.

changeNoteMetadata(characterId: BigNumberish, noteId: BigNumberish, modifier: ((metadata?: NoteMetadata) => NoteMetadata), overrides?: Overrides): Promise<Result<{ metadata: NoteMetadata; uri: string; }, true>>

Usage

contract.changeNoteMetadata(
  42, // characterId
  5, // noteId
  (metadata) => ({
    ...metadata,
    name: 'New Name',
    content: 'New Description',
  }), // modifier
)

Parameters

characterId

  • Type: BigNumberish

The ID of the character that owns the note.

noteId

  • Type: BigNumberish

The ID of the note to update.

modifier

A function that takes the existing metadata and returns the new metadata.

Returns

interface Returns {
  data: {
    metadata: NoteMetadata
    uri: string
  }
  transactionHash: string
}