owned this note
owned this note
Published
Linked with GitHub
# (Tokenized) NFT-based Repositories
## Repositories
A repository contains versioned source assets or build artifacts. Valist supports publishing Git, NPM, Docker, and binary assets.
Valist repositories implement the [ERC-721](https://ethereum.org/en/developers/docs/standards/tokens/erc-721/) interface to allow repositories to be managed, owned, and traded.
Releases are published using the [ERC-721 metadata extension](https://eips.ethereum.org/EIPS/eip-721). The token URI points to a file containing JSON structured metadata.
```json
{
"title": "Asset Metadata",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Identifies the asset to which this NFT represents"
},
"description": {
"type": "string",
"description": "Describes the asset to which this NFT represents"
},
"image": {
"type": "string",
"description": "A URI pointing to a resource with mime type image/* representing the asset to which this NFT represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive."
}
}
}
```
Every repository contains an immutable set of all release versions. Versions can be queried by using the contract methods below. The latest release will always be the current `tokenURI`.
```
versionCount(uint256 tokenId) (uint256)
versionNameByIndex(uint256 tokenId, uint256 index) (string memory)
versionURI(uint256 tokenId, string memory tokenVersion) (string memory)
```
Repository token IDs are generated by taking the [namehash](https://docs.ens.domains/contract-api-reference/name-processing) of a root domain and repository name. If this sounds familiar to how ENS node IDs are generated, that's because it is.
Valist repositories implement the ENS resolver interface allowing repositories to be resolved by name. For example `<repo>.<root>` will resolve to the repository `<repo>` owned by the `<root>` domain.
## NPM Example
This example will walk through the steps required to publish and install an NPM package with Valist. The package used in the example uses the `package.json` below.
```json
{
"name": "example",
"version": "0.0.1",
"description": "An example package"
}
```
To publish the package, set the registry to your Valist username and run the publish command. This will create an ENS subdomain `example.acme.valist` which will be used later to install the package.
```bash
npm publish --registry=https://acme.valist.io
```
To install the package, set the registry to your Valist username and run the install command. The registry address will be combined with the package name and resolved as `example.acme.valist`.
```bash
npm install example --registry=https://acme.valist.io
```
If you want to install the package from a different EVM compatible blockchain, append the chain shortname to the registry URL.
```bash
npm install example --registry=https://acme.mumbai.valist.io
```
Multiple registries can be combined by adding ENS TXT records for each registry. Each registry will be tried in the order they are entered until the package is resolved.
Below is an example of the TXT record for the subdomain `acme.valist`.
```
io.valist.npm=https://acme.mumbai.valist.io,https://registry.npmjs.org
```
Q: What happens when we install two packages from different registries in the same project?
npm install example-one --registry=https://acme.valist.io
npm install example-two --registry=https://acme.mumbai.valist.io
npm install react
npm install <-- this last command might be the issue, since it would try to resolve example-one and example-two from the default registry.
also, there might be cases where example-one could depend on example-two
## Multi Signature & DAOs
TODO: Yo Alec fill this in with security stuff
## Use Cases
Below are some example use cases for NFT based repositories.
### Git Pull-Requests
A pull-request that can be exchanged for payment when contributing to a repository or hackathon.
### Dockerized Applications
A Docker image that downloads and runs a tokenized application using the valist CLI to resolve a binary.