Templates Overview
Overview
Currently, the oBuilder creates Ownables with different feature sets for the users. Each different feature requires a different Ownable template for the internal LTO based flow of cosm/wasm Smart Contract compilation to reflect the required functionality.
Example of different functionalities
Template 1: Ownable with a picture, thumbnail, name, description, keywords, owner
Template 2: Ownable with a picture, thumbnail, name, description, keywords, owner + rwacontract.html (resides in parallel to the index.html file under assets directory)
Template 3: (feature not enabled yet) Ownable with a picture, thumbnail, name, description, keywords, owner + audio file and/or short movie file
Templates folder structure
All templates are structured as Rust-based smart contracts with web assets:
Template Modifications
Placeholder system overview
The templates use a placeholder system where specific tags in the code are replaced during the ownable creation process. These placeholders allow customization of the ownable's appearance, metadata, and functionality.
Placeholders by File
Cargo.toml
Contains package metadata placeholders:
PLACEHOLDER1_NAME - Package name (e.g., "ownable_my_artwork")
PLACEHOLDER1_DESCRIPTION - Package description
PLACEHOLDER1_VERSION - Package version
PLACEHOLDER1_AUTHORS - Package authors
PLACEHOLDER1_KEYWORDS - Package keywords (as array)
assets/index.html
Contains display/visual placeholders:
PLACEHOLDER2_TITLE - Title displayed in the browser tab
PLACEHOLDER2_IMG - Image file path for displaying the main image
examples/schema.rs
Contains code module reference placeholders:
PLACEHOLDER3_MSG - Module path for message types
PLACEHOLDER3_STATE - Module path for state types
src/contract.rs
Contains contract identity placeholders:
PLACEHOLDER4_CONTRACT_NAME - Name of the smart contract
PLACEHOLDER4_TYPE - Type identifier for the ownable
PLACEHOLDER4_DESCRIPTION - Detailed description
PLACEHOLDER4_NAME - Display name
How Modifications Work
The user changes the different PLACEHOLDER in the template file used to create the Ownable and the ownable will be unique to the user specified variables:
For example, when a user creates an Ownable with an image named "artwork.webp" with title "My Digital Artwork":
PLACEHOLDER2_TITLE becomes "My Digital Artwork"
PLACEHOLDER2_IMG becomes "artwork.webp"
Other placeholders must be changed by the user in the same manner
This template system allows the same base templates to create unique ownables with different content, metadata, and appearance while maintaining consistent smart contract functionality.
Placeholder Mapping Example
The oBuilder e.g. uses the following placeholder ownableData.json to create the Ownables. The user should use a similar approach.
Template Differences:
Template 1: Basic template with standard assets
Template 2: Enhanced template with additional HTML file (rwacontract.html)
Template 3: Alternative templates with different assets such as audio or short video files (Not yet implemented)
More coming up...!
Last updated