Class Contract

This class is used to interact with the contract.

Example

import { createContract } from 'crossbell'

// Create a new contract instance with metamask provider
const provider = window.ethereum
const contract = createContract(provider)
await contract.walletClient.requestAddresses()
// Example API: Create a new character for an address
try {
const result = await contract.character.create(
'0x1234567890123456789012345678901234567890',
'Jason',
'ipfs://xxxx/metadata.json',
)
console.log(result.data) // '42' (characterId)
console.log(result.transactionHash) // '0xabcdef...'
} catch (e) {
console.error(e.message) // e.g. "execution reverted: Web3Entry: HandleExists"
}

Hierarchy (view full)

Constructors

  • This creates a new Contract instance to interact with.

    Parameters

    • providerOrPrivateKey: undefined | `0x${string}` | EIP1193Provider

      The provider or private key to connect to the contract.

    • Optional options: Partial<ContractOptions>

    Returns Contract

    The Contract instance.

    Example: Connect with Metamask

    import { Contract } from 'crossbell'
    const provider = window.ethereum // the metamask provider
    const contract = new Contract(provider)

    Example: Connect with Private Key

    import { Contract } from 'crossbell'
    const privateKey = '0xabcdef0123456789012345678901234567890123456789012345678901234'
    const contract = new Contract(privateKey)

    Example: Connect with a Readonly Contract

    import { Contract } from 'crossbell'
    const contract = new Contract() // readonly contract

Properties

cbt: CbtContract = ...
cbtContract: {}

Type declaration

    character: CharacterContract = ...
    contract: {}

    Type declaration

      csb: CsbContract = ...
      link: LinkContract = ...
      linkModule: LinkModuleContract = ...
      linklistContract: {}

      Type declaration

        mintModule: MintModuleContract = ...
        miraContract: {}

        Type declaration

          newbieVillaContract: {}

          Type declaration

            note: NoteContract = ...
            operator: OperatorContract = ...
            peripheryContract: {}

            Type declaration

              publicClient: {}

              Type declaration

                revision: RevisionContract = ...
                tips: TipsContract = ...
                tipsContract: {}

                Type declaration

                  tipsWithConfigContract: {}

                  Type declaration

                    tipsWithFee: TipsWithFeeContract = ...
                    tipsWithFeeContract: {}

                    Type declaration

                      walletClient: {}

                      Type declaration

                        Accessors

                        Generated using TypeDoc