Skip to content

Commit

Permalink
feat: update metadata page (#353)
Browse files Browse the repository at this point in the history
* feat: update metadata page

Update the Metadata page according to dojoengine/dojo#2691.

* feat: add dojo profile config for IPFS

---------

Co-authored-by: glihm <[email protected]>
  • Loading branch information
remybar and glihm authored Nov 28, 2024
1 parent d200199 commit 8051712
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 9 deletions.
55 changes: 46 additions & 9 deletions docs/pages/framework/world/metadata.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,64 @@
# Metadata

Dojo supports associating offchain metadata with the world contract and other deployed contracts. This can provide additional context about the world, such as it's name, description, social links and other media. Enabling external services to easily index and distribute worlds and experiences built on them.
Dojo supports associating offchain metadata with the world and its resources. This can provide additional context about the world and their resources, such as their name, description, icon URI, ... Enabling external services to easily index and distribute worlds and experiences built on them.

## World Metadata
During migration, `sozo` will automatically manage metadata for you, uploading them to IPFS in `JSON` format and registering them in the world contract through the `ResourceMetadata` Dojo model. `sozo` does so by parsing the metadata defined in the Dojo profile configuration `dojo_<PROFILE>.toml`.

During migration, `sozo` will automatically manage the worlds metadata for you, uploading it to IPFS and setting it in the world contract. It does so by parsing the metadata defined in the projects `Scarb.toml`.
## World Metadata

To set a world metadata, create the following section in your `Scarb.toml`:
To set world metadata, create the following section in your `dojo_<PROFILE>.toml`:

```toml
[tool.dojo.world]
[world]
name = "example"
seed = "dojo_examples"
description = "example world"
icon_uri = "file://assets/icon.png"
cover_uri = "file://assets/cover.png"
website = "https://dojoengine.org"
socials.x = "https://twitter.com/dojostarknet"
```

The toolchain supports the `name`, `description`, `icon_uri`, `cover_uri`, `website` and `socials` attributes by default. `*_uri` attributes can point to an asset in the repo using the `file://` schema or to remote resouces using either `ipfs://` or `https://`. Arbitrary social links can be set by setting a key value on the `socials` attribute. For example, we could add a `socials.github = "..."`.
The toolchain supports the `name`, `description`, `icon_uri`, `cover_uri`, `website` and `socials` attributes by default.

`*_uri` attributes can point to an asset in the repo using the `file://` schema or to remote resouces using either `ipfs://` or `https://`. For local assets, `sozo` wil upload them to IPFS and replace the corresponding URIs by a IPFS URI.

Arbitrary social links can be set by setting a key value on the `socials` attribute. For example, we could add a `socials.github = "..."`.

## Resource Metadata

To set resource metadata, create the following section in your `dojo_<PROFILE>.toml`, using `[[models]]`, `[[contracts]]` or `[[events]]` depending on the type of the resource:

```toml
[[models]]
tag = "ns-Position"
description = "Position of the player in the world"
icon_uri = "file://assets/position_icon.png"

[[events]]
tag = "ns-Moved"
description = "emit when a player has moved"
icon_uri = "file://assets/moved_icon.png"

[[contracts]]
tag = "ns-actions"
description = "Available actions for a player in the world"
icon_uri = "file://assets/actions_icon.png"
```

For each type of resource, the toolchain supports the `description` and `icon_uri` attributes by default. The `name` of the resource, retrieved from its `tag`, is also stored in the resource metadata.

During migration, `sozo` will upload any local assets to IPFS, replace the corresponding URIs, upload the metadata JSON to IPFS, and set the `metadata_uri` for the world (resource `0`).
`*_uri` attributes can point to an asset in the repo using the `file://` schema or to remote resouces using either `ipfs://` or `https://`. For local assets, `sozo` wil upload them to IPFS and replace the corresponding URIs by a IPFS URI.

## Contract and Model Metadata
## Defining IPFS configuration in profile

The toolchain supports the following IPFS configuration options in the profile configuration file `dojo_<PROFILE>.toml`:

```toml
[env]
ipfs_config.url = "https://ipfs.infura.io:5001"
ipfs_config.username = "2EBrzr7ZASQZKH32sl2xWauXPSA"
ipfs_config.password = "12290b883db9138a8ae3363b6739d220"
```

It is possible for contract/model owners to set a `metadata_uri` for any contract. However, this specification has not yet been defined and it is not supported by the toolchain at this time.
If those configurations are not provided, metadata will not be uploaded to IPFS and a warning will be displayed.
24 changes: 24 additions & 0 deletions docs/pages/toolchain/sozo/project-commands/migrate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,30 @@ Commands:

<AccountOptions />

#### IPFS Options

If you provide your IPFS credentials, `sozo` can automatically upload metadata
of the world and its resources to IPFS, and register IPFS URIs to the `ResourceMetadata`
model of the world.

You can either provide these credentials through command-line arguments, through environment variables
or through your `dojo_<profile>.toml`.

`--ipfs-url` URL
&nbsp;&nbsp;&nbsp;&nbsp;The URL of the IPFS client to use.

&nbsp;&nbsp;&nbsp;&nbsp;_or `DOJO_IPFS_URL` environment variable, or `ipfs_url` in your profile configuration file._

`--ipfs-username` USERNAME
&nbsp;&nbsp;&nbsp;&nbsp;The username to use for the IPFS client.

&nbsp;&nbsp;&nbsp;&nbsp;_or `DOJO_IPFS_USERNAME` environment variable, or `ipfs_username` in your profile configuration file._

`--ipfs-password` PASSWORD
&nbsp;&nbsp;&nbsp;&nbsp;The password to use for the IPFS client.

&nbsp;&nbsp;&nbsp;&nbsp;_or `DOJO_IPFS_PASSWORD` environment variable, or `ipfs_password` in your profile configuration file._

#### Signer Options - Raw

<SignerOptionsRaw />
Expand Down

0 comments on commit 8051712

Please sign in to comment.