Class Contract

This class is used to interact with the contract.

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.

    • Optionaloptions: Partial<ContractOptions>

    Returns Contract

    The Contract instance.

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

Properties

cbt: CbtContract = ...
cbtContract: {}
character: CharacterContract = ...
contract: {}
csb: CsbContract = ...
link: LinkContract = ...
linklistContract: {}
linkModule: LinkModuleContract = ...
mintModule: MintModuleContract = ...
miraContract: {}
newbieVillaContract: {}
note: NoteContract = ...
operator: OperatorContract = ...
peripheryContract: {}
publicClient: {}
revision: RevisionContract = ...
tips: TipsContract = ...
tipsContract: {}
tipsWithConfigContract: {}
tipsWithFee: TipsWithFeeContract = ...
tipsWithFeeContract: {}
walletClient: {}

Accessors

MMNEPVFCICPMFPCPTTAAATR