Schemas
The @erc725/erc725.js
library contains a range of standard LSP ERC725 JSON schemas.
Schemas allow erc725.js to know how to decode and encode data written in an ERC725Y smart contract.
A quick reference for keys used in schema definitions can be seen below
name
: An arbitrary namekey
: The sha3 hash of the namekeyType
: One of the supported erc725 keyTypesvalueType
: The type of the content data in store for decodingvalueContent
: The described content type for parsing
Standard LSP Schemas
The most common schemas of LUKSO Standard Proposals are available to import. These are typed automatically with the Typescript type ERC725JSONSchema[]
for when instantiating new ERC725(...)
from Typescript projects.
import {
LSP1Schema,
LSP3Schema,
LSP4Schema,
LSP4LegacySchema,
LSP5Schema,
LSP6Schema,
LSP8Schema,
LSP9Schema,
LSP10Schema,
LSP12Schema,
LSP17Schema,
} from '@erc725/erc725.js/schemas';
const erc725js = new ERC725(LSP12Schema);
The raw JSON schemas are also available for import from the schemas/
folder.
Current provided LSPs JSON schemas are:
LSP1UniversalReceiverDelegate.json
LSP3ProfileMetadata.json
LSP4DigitalAssetLegacy.json
LSP4DigitalAsset.json
LSP5ReceivedAssets.json
LSP6KeyManager.json
LSP8IdentifiableDigitalAsset.json
LSP9Vault.json
LSP10ReceivedVaults.json
LSP12IssuedAssets.json
LSP17ContractExtension.json
You can import the raw JSON as follow:
import LSP3 from '@erc725/erc725.js/schemas/LSP3ProfileMetadata.json';
import LSP5 from '@erc725/erc725.js/schemas/LSP5ReceivedAssets.json';
// ...
// Later use them on instantiation
const myErc725Contract = new ERC725js(LSP3, address, web3.currentProvider);
// You can retrieve the current loaded schema via
myErc725Contract.options.schemas;