The Catalog class gives a developer direct read / write access to a specified instance of the Catalog Protocol.
constructor(
signerOrProvider: Signer | Provider,
chainId: number,
contractAddress?: string,
)
The constructor requires two arguments:
- signerOrProvider
- chainID
The constructor will use the signerOrProvider
to determine if the Catalog Instance is readOnly
or readAndWrite
capable.
If a signer
is passed in then the Catalog instance will be able to invoke both read and write functions.
If only a provider
is passed in then the Catalog instance can only invoke readOnly methods.
The constructor will use the chainID
to look up the officially supported Catalog Protocol addresses and return a Catalog instance connected the protocol
If the chainId does not exist in chainIdToNetworkName
the constructor will raise.
The constructor can optionally accept one parameters to override
the official supported Catalog Protocol address. This override is particularly useful for development on a local blockchain.
import { Catalog } from '@catalogworks/cdk'
import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()
const catalog = new Catalog(wallet, 1)
const root = await catalog.fetchMerkleRoot()
import { Catalog } from '@catalogworks/cdk'
import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()
const catalog = new Catalog(wallet, 4)
const root = await catalog.fetchMerkleRoot()
When using a local blockchain you must specify override for contractAddress
. This should point to the address of a deployed Catalog Shared creator contract on your local blockchain.
import { Catalog } from '@catalogworks/cdk'
import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()
const catalog = new Catalog(wallet, 50, inputAddress)
const root = await catalog.fetchMerkleRoot()
Fetch the contentURI
of a given token.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID for the token whose content uri is being fetched |
Fetch the metadataURI
of a given token.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID for the token whose metadata uri is being fetched |
Fetch the creator
of a piece of media.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID for the token whose creator is being fetched |
Fetch the current payoutAddress
of a given token.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID for the token whose current royalty payout address is being fetched |
Fetch the current RoyaltyInfo
of a given token.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID for the token whose current royalty info is being fetched |
salePrice | BigNumberish | The input sale price of the token. |
Fetch the current metadataURI
for a given token.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose metadata uri is being fetched |
Fetch the current MerkleRoot
for the given contract.
Name | Type | Description |
---|---|---|
N/A | N/A | N/A |
Fetch the token balance for a given address on an instance of the Catalog shared creator contract.
Name | Type | Description |
---|---|---|
owner | string | The address of the account whose balance is being fetched |
Fetch the owner of a given token on an instance of the Catalog shared creator contract.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID for the token whose owner is being fetched |
Fetch the current owner
for the given Catalog contract.
Name | Type | Description |
---|---|---|
N/A | N/A | N/A |
Fetch the approved account for the specified token.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID for the token whose approved address is being fetched |
Fetch if the specified operator is approved for all tokens owned by the specified owner
Name | Type | Description |
---|---|---|
owner | string | An address on the Catalog shared creator contract |
operator | string | An address on the Catalog shared creator contract |
Mint a new token from the Catalog shared creator contract.
Name | Type | Description |
---|---|---|
tokenData | TokenData | The data represented by this token, including royalty info |
proof | Proof | The valid bytes32[] proof for the input tokenData.creator address |
Update the contentURI
of a given token.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID for the token whose content uri is being updated |
Update the metadataURI
of a given token.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID for the token whose metadata uri is being updated |
Update the RoyaltyInfo
of a given token.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID for the token whose royalty info is being updated |
royaltyPayoutAddress | string | The input address for the token whose royalty info is being updated |
Update the MerkleRoot
of a given contract instance.
Name | Type | Description |
---|---|---|
merkleRoot | BytesLike | The bytes32 merkle root to be updated |
Burn a Catalog token.
Name | Type | Description |
---|---|---|
tokenId | BigNumberish | The ID for the token to burn |
Grant approval to the specified address for the specified token on an instance of the Catalog shared creator contract.
Name | Type | Description |
---|---|---|
to | string | The address being granted approval for the token |
tokenId | BigNumberish | The ID for the token |
Grant approval for all token owner by msg.sender on an instance of the Catalog shared creator contract.
Name | Type | Description |
---|---|---|
operator | string | The address of the account the approvalForAll is being set |
approved | boolean | Whether or not the operator address is being granted approval |
Transfers the specified token to the specified to address on an instance of the Catalog shared creator contract.
Name | Type | Description |
---|---|---|
from | string | The from address of the token transfer |
to | string | The to address of the token transfer |
tokenId | BigNumberish | The ID for the token being transferred |
Transfers specified token to the specified address if and only if it adheres to the ERC721-Receiver Interface
Name | Type | Description |
---|---|---|
from | string | The from address of the token transfer |
to | string | The to address of the token transfer |
tokenId | BigNumberish | The ID for the token being transferred |