Myria Samples App
Typescript application that shows how to interact with the `myria-core-sdk` library
Overview
Myria Samples App is a Typescript application that shows how to interact with the myria-core-sdk library.
The code samples provided in this project will help create new Myria projects, launch collections, and mint assets on the Myria Chain.
Prerequisites
Setup
1. Clone the repository
https://github.com/thisonedev/vault.git2. Enter myria-samples-app directory
cd myria-samples-app3. Install dependencies
yarn4. Provide environment variables
Rename the.env.example file into .env and provide the required configuration values:
# common
PUBLIC_KEY= <public key of the owner's Ethereum wallet>
PRIVATE_KEY= <private key of the owner's Ethereum wallet>
STARK_KEY= <stark key derived from the owner's Ethereum wallet>
# collection
CONTRACT_ADDRESS= <contract address deployed on Ethereum for a given collection>
METADATA_API_URL= <metadata API URL that returns JSON metadata schema for a given collection>
PROJECT_ID= <id of the project to which the collection will be added>
# mint
TOKEN_URI= <URL path to the mintable asset metadata>
TOKEN_ID= <unique identifier of a given asset, should be an incremental numeric value starting from 1>Running the app
1. Common
1.1 Generate a Stark Key
Generates a Stark Key derived from a given Web3 private key.
Requirements:
- Provide
PRIVATE_KEYenvironment variable
npm run generate-stark-key2. Projects
2.1 Create a project
Creates a project on Myria.
Requirements:
- Provide the
CONTRACT_ADDRESSenvironment variable - Replace params values with your project details:
name- the project namecompanyName- the company name that will be working on the projectcontactEmail- the contact email
npm run create-project2.2 Get project list
Returns a list of projects created on Myria.
npm run get-project-list2.3 Get project details
Returns details of a given Myria project by its id.
Requirements:
- Replace projectId value with your project id
npm run get-project-details2.4 Update a project
Update the project by its id.
Requirements:
- Provide the
PROJECT_IDenvironment variable - Replace params values with new project details:
name- new project namecompanyName- new company name that will be working on the projectcontactEmail- new contact email
npm run update-project3. Collections
3.1 Create a collection
Creates a collection on Myria.
Requirements:
- Provide
CONTRACT_ADDRESS,METADATA_API_URL,PUBLIC_KEY,PROJECT_ID,STARK_KEYenvironment variables - Replace params values with your collection details:
name- collection namedescription- collection description
npm run create-collection3.2 Create a metadata schema
Creates a metadata schema for existing collections on Myria.
Requirements:
- Provide
CONTRACT_ADDRESSandSTARK_KEYenvironment variables - Replace metadataSchema values with your metadata schema details. Each object of the array contains the following properties:
name- the name of the metadata schema attribute. Should matchtrait_typein the Opensea metadata schematype- the type of the metadata schema attribute. Acceptsenum,string, andnumber. In most cases, you should useenumfilterable- the flag that defines if the attribute should be filterable on the Myria marketplace. Acceptstrueorfalse
npm run create-metadata-schema3.3 Get the collection list
Returns a list of collections created on Myria.
Requirements:
- Replace params values with your request parameters:
limit- the max number of items per requestpage- the page number. Each page will contain the number of items based on thelimitisHot- the flag that defines if the returned items are listed as hot on the Myria marketplace
npm run get-collection-list3.4 Get collection by id
Returns details of a given Myria collection by its id.
Requirements:
- Replace collectionId value with your collection id
npm run get-collection-by-id3.5 Get collection by public id
Returns details of a given Myria collection by its public id.
Requirements:
- Replace publicId value with your collection public id
npm run get-collection-by-public-id4. Mint transactions
4.1 Create ERC721 mint transaction
Create an ERC721 mint transaction of a given asset on Myria.
Requirements:
- Provide
STARK_KEY,CONTRACT_ADDRESS,TOKEN_URI,TOKEN_IDenvironment variables - Replace feePercentage value with a royalty fee percentage for secondary sales
- Replace description value with a description for your asset
npm run create-erc721-mint-transaction4.2 Mint multiple ERC721 assets
Mint multiple ERC721 assets on Myria. There are two options you can use to achieve the same result.
Option 1
The first option represents multiple createMintTransactionERC721 calls. The number of calls equals the number of assets you need to mint.
Requirements:
- Provide
STARK_KEY,CONTRACT_ADDRESS,METADATA_API_URL,PUBLIC_KEYenvironment variables - Replace feePercentage value with a royalty fee percentage for secondary sales
- Replace startTokenId value with a starting token id
- Replace endTokenId value with an ending token id
npm run create-bulk-erc721-mint-transactionOption 2
The second option represents a single bulkMintableNftERC721 call that mints an array of assets passes as the assets parameter. It's recommended to use less than 100 items at a time with this option.
Requirements:
- Provide
STARK_KEY,CONTRACT_ADDRESS,METADATA_API_URL,PUBLIC_KEYenvironment variables - Replace feePercentage value with a royalty fee percentage for secondary sales
- Replace startTokenId value with a starting token id
- Replace endTokenId value with an ending token id
npm run create-bulk-erc721-mint-transaction-v24.2 Get mint transaction details
Returns details of a given mint transaction by its id.
Requirements:
- Provide
STARK_KEY,CONTRACT_ADDRESS,TOKEN_URI,TOKEN_IDenvironment variables - Replace transactionId value with desired mint transaction id
npm run get-mint-transaction-details4.3 Get mint transactions by Stark Key
Returns a list of mint transactions by a given Stark Key.
Requirements:
- Provide
STARK_KEYenvironment variable
npm run get-mint-transactions-by-stark-key5. Assets
5.1 Get assets by id
Returns details of a given Myria asset by its id.
Requirements:
- Replace assetId value with your asset id
npm run get-asset-by-id5.2 Get assets by Stark Key
Returns assets by its Stark Key.
Requirements:
- Provide
STARK_KEYenvironment variable
npm run get-assets-by-stark-key5.3 Get assets by a public key
Returns all assets minted by a given public key.
Requirements:
- Provide
PUBLIC_KEYenvironment variable
npm run get-assets-by-public-key5.4 Get asset vault details
Returns details of a given asset vault by its asset id.
Requirements:
- Provide
STARK_KEYenvironment variable - Replace assetId value with your asset id
npm run get-asset-vault-details5.5 Refresh asset metadata
Refresh metadata for a given asset by its asset id
Requirements:
- Provide
STARK_KEYenvironment variable - Provide
ASSET_IDenvironment variable
npm run refresh-asset-metadata