SDK
crossbell.js
Contract API
Operator
Grant Operator

Grant Operator

A user can grant operator (another address) to a character or a note. This allows the operator to perform certain actions on the character or note.

grantOperatorPermissionsForCharacter

This grants permissions to an operator for a character.

Each character can have multiple operators. An operator can be any address. It can then be used to operate transactions in behalf of the character's owner.

Each time an operator is granted permissions, its previous permissions are overwritten.

Usage

For example, the character 42 can be granted permissions to 0x1234567890123456789012345678901234567890 to LINK_NOTE, UNLINK_NOTE and POST_NOTE:

contract.grantOperatorPermissionsForCharacter(
  42, // characterId
  '0x1234567890123456789012345678901234567890', // operator
  ['LINK_NOTE', 'UNLINK_NOTE', 'POST_NOTE'] // permissions
)

Now the operator can perform the following actions on behalf of the character:

Parameters

characterId

  • Type: BigNumberish

The ID of the character who wants to grant permissions to an operator.

operator

  • Type: string

The address of the operator.

permissions

  • Type: string[]

The permissions to grant to the operator.

You can see the list of permissions in the Specs - Permissions section.

To completely remove an operator, pass an empty array ([]) to the permissions parameter.

Returns

interface Returns {
  transactionHash: string
}

grantOperatorsForNote

This grants permission to an operator for a note.

Each note can have multiple operators. An operator can be any address. It can then be used to operate transactions in behalf of the note's owner.

Each time an operator is granted permissions, its previous permissions are overwritten.

Usage

contract.grantOperatorsForNote(
  42, // characterId
  5, // noteId
  ['0x1234567890123456789012345678901234567890'], // allowlist
  [] // blocklist
)

Now the operator can perform the following actions on behalf of the note:

Parameters

characterId

  • Type: BigNumberish

The ID of the character who owns the note.

noteId

  • Type: BigNumberish

The ID of the note.

allowlist

  • Type: string[]

The list of addresses that are allowed to operate on the note.

blocklist

  • Type: string[]

The list of addresses that are not allowed to operate on the note. This list takes precedence over the allowlist.

Returns

interface Returns {
  transactionHash: string
}