Create Link
A "link" is a component that links two things on Crossbell together. It can be a link between two characters, a character or a note, etc.
All links start from a character.
linkCharacter
This links a character to another character.
linkCharacter(fromCharacterId: BigNumberish, toCharacterId: BigNumberish, linkType: string, data?: string, overrides?: Overrides): Promise<Result<number, true>>
Usage
Character ID 42
follows Character ID 10
:
crossbell.linkCharacter(42, 10, "follow")
Parameters
fromCharacterId
- Type: BigNumberish
The ID of the character that is doing the linking.
toCharacterId
- Type: BigNumberish
The ID of the character that is being linked to.
linkType
- Type: string
The type of link. This can be any string, but it is recommended to use a short, descriptive string.
data
- Type: string
The data to be passed to the link module if the character has one.
Returns
interface Returns {
/* The ID of the linklist. */
data: number
transactionHash: string
}
createThenLinkCharacter
This creates a character for an target address and links the fromCharacter to it.
This should be only called when the target address doesn't have any character. When called on an address that already has a character, this will fail.
When called, this will create a new character for the target address and set the new character as the primary character for this address.
The new character's handle will be set to the address of the target address.
createThenLinkCharacter(fromCharacterId: BigNumberish, toAddress: string, linkType: string, overrides?: Overrides): Promise<Result<{ linklistId: number; toCharacterId: number; }, true>>
Usage
Character ID 42
follows Address 0x1234567890123456789012345678901234567890
who doesn't have a character:
crossbell.createThenLinkCharacter(42, "0x1234567890123456789012345678901234567890", "follow")
Parameters
fromCharacterId
- Type: BigNumberish
The ID of the character that is doing the linking.
toAddress
- Type: string
The address to create a character for and then link to. This address must not have a character.
linkType
- Type: string
The type of link. This can be any string, but it is recommended to use a short, descriptive string.
Returns
interface Returns {
/* The ID of the linklist. */
data: {
linklistId: number
toCharacterId: number
}
transactionHash: string
}
linkCharactersInBatch
This links a character to multiple characters with a given link type in batch.
This could be considered a bulk version of linkCharacter and createThenLinkCharacter.
linkCharactersInBatch(fromCharacterId: BigNumberish, toCharacterIds: BigNumberish[], toAddresses: string[], linkType: string, data?: string[], overrides?: Overrides): Promise<Result<number, true>>
Usage
Character ID 42
follows Character ID 10
and Address 0x1234567890123456789012345678901234567890
who doesn't have a character:
crossbell.linkCharactersInBatch(42, [10], ["0x1234567890123456789012345678901234567890"], "follow")
Parameters
fromCharacterId
- Type: BigNumberish
The ID of the character that is doing the linking.
toCharacterIds
- Type: BigNumberish[]
The IDs of the characters that are being linked to.
toAddresses
- Type: string[]
The addresses to create characters for and then link to. These addresses must not have a character.
linkType
- Type: string
The type of link. This can be any string, but it is recommended to use a short, descriptive string.
data
- Type: string[]
The data to be passed to the link module if the character has one. This is an array of data, one for each character.
Returns
interface Returns {
/* The ID of the linklist. */
data: number
transactionHash: string
}
linkNote
This links a character to a note.
linkNote(fromCharacterId: BigNumberish, toCharacterId: BigNumberish, toNoteId: BigNumberish, linkType: string, data?: string, overrides?: Overrides): Promise<Result<number, true>>
Usage
Character ID 42
likes Note ID 5
on Character ID 10
:
crossbell.linkNote(42, 10, 5, "like")
Parameters
fromCharacterId
- Type: BigNumberish
The ID of the character that is doing the linking.
toCharacterId
- Type: BigNumberish
The ID of the character that owns the note.
toNoteId
- Type: BigNumberish
The ID of the note that is being linked to.
linkType
- Type: string
The type of link. This can be any string, but it is recommended to use a short, descriptive string.
data
- Type: string
The data to be passed to the link module if the character has one.
Returns
interface Returns {
/* The ID of the linklist. */
data: number
transactionHash: string}
linkAddress
This links a character to an address.
linkAddress(fromCharacterId: string, toAddress: string, linkType: string, data?: string, overrides?: Overrides): Promise<Result<number, true>>
Usage
Character ID 42
follows Address 0x1234567890123456789012345678901234567890
:
crossbell.linkAddress(42, "0x1234567890123456789012345678901234567890", "follow")
Parameters
fromCharacterId
- Type: BigNumberish
The ID of the character that is doing the linking.
toAddress
- Type: string
The address that is being linked to.
linkType
- Type: string
The type of link. This can be any string, but it is recommended to use a short, descriptive string.
data
- Type: string
The data to be passed to the link module if the character has one.
Returns
interface Returns {
/* The ID of the linklist. */
data: number
transactionHash: string
}
linkAnyUri
This links a character to any URI.
linkAnyUri(fromCharacterId: BigNumberish, toUri: string, linkType: string, data?: string, overrides?: Overrides): Promise<Result<number, true>>
Usage
Character ID 42
likes the URI https://example.com
:
crossbell.linkAnyUri(42, "https://example.com", "like")
Parameters
fromCharacterId
- Type: BigNumberish
The ID of the character that is doing the linking.
toUri
- Type: string
The URI that is being linked to.
linkType
- Type: string
The type of link. This can be any string, but it is recommended to use a short, descriptive string.
data
- Type: string
The data to be passed to the link module if the character has one.
Returns
interface Returns {
/* The ID of the linklist. */
data: number
transactionHash: string}
linkErc721
This links a character to an ERC721 token.
linkErc721(fromCharacterId: string, toContractAddress: string, toTokenId: BigNumberish, linkType: string, data?: string, overrides?: Overrides): Promise<Result<number, true>>
Usage
Character ID 42
likes ERC721 Token ID 5
on Contract Address 0x1234567890123456789012345678901234567890
:
crossbell.linkErc721(42, "0x1234567890123456789012345678901234567890", 5, "like")
Parameters
fromCharacterId
- Type: BigNumberish
The ID of the character that is doing the linking.
toContractAddress
- Type: string
The address of the ERC721 contract.
toTokenId
- Type: BigNumberish
The ID of the token that is being linked to.
linkType
- Type: string
The type of link. This can be any string, but it is recommended to use a short, descriptive string.
data
- Type: string
The data to be passed to the link module if the character has one.
Returns
interface Returns {
/* The ID of the linklist. */
data: number
transactionHash: string}
linkLinklist
This links a character to a linklist.
linkLinklist(fromCharacterId: BigNumberish, toLinkListId: BigNumberish, linkType: string, data?: string, overrides?: Overrides): Promise<Result<number, true>>
Usage
Character ID 42
favorites Linklist ID 5
:
crossbell.linkLinklist(42, 5, "favorite")
Parameters
fromCharacterId
- Type: BigNumberish
The ID of the character that is doing the linking.
toLinkListId
- Type: BigNumberish
The ID of the linklist that is being linked to.
linkType
- Type: string
The type of link. This can be any string, but it is recommended to use a short, descriptive string.
data
- Type: string
The data to be passed to the link module if the character has one.
Returns
interface Returns {
/* The ID of the linklist. */
data: number
transactionHash: string}