Create Character
A character is a distinct identity that enables interaction with the blockchain. In other words, it is the account that represents a user on the blockchain.
One user has one single crypto wallet. Each wallet (also referred to as an address) can contain multiple characters. Every character is associated with a single wallet.
You can learn more about characters in the Concept - Character section.
createCharacter
This creates a new character for an address and returns the ID of the newly created character. When it is the first character created for an address, the address is automatically set as the primary character.
createCharacter(owner: string, handle: string, metadataOrUri: string | CharacterMetadata, options?: PostNoteOptions, overrides?: Overrides): Promise<Result<number, true>>
Usage
const result = await contract.createCharacter(
'0x1234567890123456789012345678901234567890',
'Jason',
'ipfs://xxxx/metadata.json',
)
or:
const result = await contract.createCharacter(
'0x1234567890123456789012345678901234567890',
'Jason',
{ name: 'Jason', bio: 'I am Jason' },
)
Parameters
owner
- Type: string
The Ethereum address of the character owner.
handle
- Type: string
The handle of the character.
It must be unique among all characters.
It follows this regular expression: ^[a-z0-9\-\_]{3,32}$
, which means it can only contain lowercase letters, numbers, hyphens, and underscores, and must be between 3 and 32 characters long.
metadataOrUri
- Type: string | CharacterMetadata (opens in a new tab)
The metadata of the character. It can be either an URL string or a CharacterMetadata (opens in a new tab) object.
See more about character metadata in the Spec - Character Metadata section.
options
(optional)
options.linkModule
This sets the link module for the character.
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.createCharacter(
'0x1234567890123456789012345678901234567890',
'Jason',
'ipfs://xxxx/metadata.json',
{
linkModule: {
address: '0x1234567890123456789012345678901234567890',
data: ['0x1234567890123456789012345678901234567890', 10],
},
},
)
Returns
interface Returns {
data: number // characterId
transactionHash: string
}