Getting Started
crossbell.js
is a VanillaJS library containing everything you need to start working with Crossbell.
Installation
Install crossbell.js
.
npm i crossbell.js
Import Contract
Import crossbell.js
:
import { Contract } from 'crossbell.js'
const contract = new Contract(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.getCharacter(10);
console.log(data);
// Example Write API: Create a new character for an address
try {
const result = await contract.createCharacter(
'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"
}
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.