Skip to content

EvelinaBuiciag/myria-ts-samples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Myria TS Samples

Overview

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

  1. Web3 Wallet: public and private key
  2. Stark Key
  3. Deployed Contract
  4. Metadata API URL

Setup

1. Clone the repository

git clone https://gitlab.com/myriaworld/myrianet/blockchain/myria-ts-samples.git

2. Enter myria-ts-samples directory

cd myria-ts-samples

3. Install dependencies

yarn

4. 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:

  1. Provide PRIVATE_KEY environment variable
npm run generate-stark-key

2. Projects

2.1 Create a project

Creates a project on Myria.

Requirements:

  1. Provide the CONTRACT_ADDRESS environment variable
  2. Replace params values with your project details:
  • name - the project name
  • companyName - the company name that will be working on the project
  • contactEmail - the contact email
npm run create-project

2.2 Get project list

Returns a list of projects created on Myria.

npm run get-project-list

2.3 Get project details

Returns details of a given Myria project by its id.

Requirements:

  1. Replace projectId value with your project id
npm run get-project-details

2.4 Update a project

Update the project by its id.

Requirements:

  1. Provide the PROJECT_ID environment variable
  2. Replace params values with new project details:
  • name - new project name
  • companyName - new company name that will be working on the project
  • contactEmail - new contact email
npm run update-project

3. Collections

3.1 Create a collection

Creates a collection on Myria.

Requirements:

  1. Provide CONTRACT_ADDRESS, METADATA_API_URL, PUBLIC_KEY, PROJECT_ID, STARK_KEY environment variables
  2. Replace params values with your collection details:
  • name - collection name
  • description - collection description
npm run create-collection

3.2 Create a metadata schema

Creates a metadata schema for existing collections on Myria.

Requirements:

  1. Provide CONTRACT_ADDRESS and STARK_KEY environment variables
  2. 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 match trait_type in the Opensea metadata schema
  • type - the type of the metadata schema attribute. Accepts enum, string, and number. In most cases, you should use enum
  • filterable - the flag that defines if the attribute should be filterable on the Myria marketplace. Accepts true or false
npm run create-metadata-schema

3.3 Get the collection list

Returns a list of collections created on Myria.

Requirements:

  1. Replace params values with your request parameters:
  • limit - the max number of items per request
  • page - the page number. Each page will contain the number of items based on the limit
  • isHot - the flag that defines if the returned items are listed as hot on the Myria marketplace
npm run get-collection-list

3.4 Get collection by id

Returns details of a given Myria collection by its id.

Requirements:

  1. Replace collectionId value with your collection id
npm run get-collection-by-id

3.5 Get collection by public id

Returns details of a given Myria collection by its public id.

Requirements:

  1. Replace publicId value with your collection public id
npm run get-collection-by-public-id

4. Mint transactions

4.1 Create ERC721 mint transaction

Create an ERC721 mint transaction of a given asset on Myria.

Requirements:

  1. Provide STARK_KEY, CONTRACT_ADDRESS, TOKEN_URI, TOKEN_ID environment variables
  2. Replace feePercentage value with a royalty fee percentage for secondary sales
  3. Replace description value with a description for your asset
npm run create-erc721-mint-transaction

4.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:

  1. Provide STARK_KEY, CONTRACT_ADDRESS, METADATA_API_URL, PUBLIC_KEY environment variables
  2. Replace feePercentage value with a royalty fee percentage for secondary sales
  3. Replace startTokenId value with a starting token id
  4. Replace endTokenId value with an ending token id
npm run create-bulk-erc721-mint-transaction

Option 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:

  1. Provide STARK_KEY, CONTRACT_ADDRESS, METADATA_API_URL, PUBLIC_KEY environment variables
  2. Replace feePercentage value with a royalty fee percentage for secondary sales
  3. Replace startTokenId value with a starting token id
  4. Replace endTokenId value with an ending token id
npm run create-bulk-erc721-mint-transaction-v2

4.2 Get mint transaction details

Returns details of a given mint transaction by its id.

Requirements:

  1. Provide STARK_KEY, CONTRACT_ADDRESS, TOKEN_URI, TOKEN_ID environment variables
  2. Replace transactionId value with desired mint transaction id
npm run get-mint-transaction-details

4.3 Get mint transactions by Stark Key

Returns a list of mint transactions by a given Stark Key.

Requirements:

  1. Provide STARK_KEY environment variable
npm run get-mint-transactions-by-stark-key

5. Assets

5.1 Get assets by id

Returns details of a given Myria asset by its id.

Requirements:

  1. Replace assetId value with your asset id
npm run get-asset-by-id

5.2 Get assets by Stark Key

Returns assets by its Stark Key.

Requirements:

  1. Provide STARK_KEY environment variable
npm run get-assets-by-stark-key

5.3 Get assets by a public key

Returns all assets minted by a given public key.

Requirements:

  1. Provide PUBLIC_KEY environment variable
npm run get-assets-by-public-key

5.4 Get asset vault details

Returns details of a given asset vault by its asset id.

Requirements:

  1. Provide STARK_KEY environment variable
  2. Replace assetId value with your asset id
npm run get-asset-vault-details

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.1%
  • Shell 0.9%