Getting Started
crossbell
is a VanillaJS library containing everything you need to start working with Crossbell.
Installation
Install crossbell
.
npm i crossbell
Import Contract
Import crossbell
:
import { createContract } from 'crossbell'
const contract = createContract(window.ethereum)
Use Contract
Now we can use the contract to interact with the Crossbell protocol.
// Example Read API: Get a character by ID
const { data } = await contract.character.get({ characterId: 10 });
console.log(data);
// Example Write API: Create a new character for an address
try {
const result = await contract.character.create({
owner: '0x1234567890123456789012345678901234567890',
handle: 'Jason',
metadataOrUri: '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"
}
Want to learn more? Continue on reading the documentation.
You can start by reading the Guides, and learn the details of every API in the API Reference.