Skip to main content

Collection - Smart Contract

Learn how to create a Myria collection.

info

Please note, in the Staging environment you can create five collections and 50,000 mint transactions per collection per month. If you want to create collections for your project in the Production environment, or you need to increase those limits, please contact our team. Be sure to include your project id in the request message.

Prerequisites

1. Deploy a contract

First, deploy an Ethereum smart contract that implements the mintFor function. If the deployment is successful, you will get the associated contract address, which you will need to create a new collection.

tip

There's no need to write any Solidity code. The example provided below contains everything required to deploy your contract.

1.1 Get the Alchemy key

Web3 developers consume data via RPC calls from one of the nodes on the network. Hosting nodes is expensive. That's why it's common to use third-party services like Alchemy or Infura.

This guide will use Alchemy as an example. Once you set up and log into your account, create a new app, and choose the network to work with as follows:

alchemy-create-account

After you set up the app, reveal your Alchemy key by selecting VIEW KEY near the name of your app. Copy and save the HTTPS key. You'll need to use it in further steps.

alchemy-key

1.2 Fund your Web wallet

Code deployments to the Ethereum blockchain require ETH to pay associated fees.

The example below uses Sepolia and requires test ETH on the Sepolia testnet. You can request test funds from Sepolia faucet by Alchemy.

To request a Sepolia faucet, switch to the Sepolia network in your MetaMask, copy and paste your wallet address and click Send me ETH. As a result, you should see tokens in your wallet as follows:

  1. Access to the sepolia faucet page. faucet-result

  2. Register/Login to input your wallet address to topup Sepolia faucet token. faucet-result

info

If the Alchemy faucet is down, you can use backup options: Faucet 2, Faucet 3

When you install MetaMask the first time, it may have test networks disabled. To enable those, use the following steps:

metamask-testnet

1.3 Clone the repository

git clone https://github.com/MyriaPlatform/myria-smart-contract.git

1.4 Open your contract in Visual Studio Code

vscode-contract

1.5 Setup the project

To set up the project, first install the dependencies:

yarn

Then, rename the .env.example into .env and change the variables as follows:

  • API_URL - the RPC URL on the corresponding network (testnet or mainnet)
  • PRIVATE_KEY - the private key of your Web3 wallet
  • PUBLIC_KEY - the public key of your Web3 wallet
  • STARKEX_ADDRESS - StarkEx Myria contract:
    • Goerli Testnet (staging): 0xF82C423a30E317f34f9b0997627F2F9c5d239Ad9 (Deprecated)
    • Sepolia Testnet (staging): 0xe99aFF31AD367Dcc45c60b237a2Ef096507d6095 (Latest supported)
    • Ethereum Mainnet (production): 0x3071BE11F9e92A9eb28F305e1Fa033cD102714e7

1.6 Deploy the contract

Finally, run the deploy.js script to deploy the contract:

yarn deploy-erc721

1.7 Get your contract address

If the deployment is successful, you will get the contract address and transaction hash to check transaction details. Copy and save this address somewhere. You'll need to use it later.

If you want more details about the contract, wallet, or blockchain transactions, you can use one of the blockchain explorers, such as Etherscan.

Here's an example of deployed contract address on the Sepolia testnet: 0x0aa86cfdd39a50f23c0aae930503f3ac149e0c47.

etherscan-deploy