Collection - Smart Contract
Learn how to create a Myria collection.
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
- Basic Javascript and Typescript knowledge
- Web IDE such as VS Code
- Latest NodeJs
- Web3 wallet address and Stark Key
- Typescript project created here or a new one with similar structure
- Registered Myria developer account and project
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.
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:
- Sepolia Testnet (Recommendation)
- Goerli Testnet (Deprecated)
- Ethereum Mainnet
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.
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.
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.
1.2 Fund your Web wallet
Code deployments to the Ethereum blockchain require ETH to pay associated fees.
- Sepolia Testnet (Recommendation)
- Goerli Testnet (Deprecated)
- Ethereum Mainnet
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:
Access to the sepolia faucet page.
Register/Login to input your wallet address to topup Sepolia faucet token.
When you install MetaMask the first time, it may have test networks disabled. To enable those, use the following steps:
The example below uses Goerli and requires test ETH on the Goerli testnet. You can request test funds from Goerli faucet by Alchemy.
To request a Goerli faucet, switch to the Goerli 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:
When you install MetaMask the first time, it may have test networks disabled. To enable those, use the following steps:
The example below uses Ethereum mainnet as an example. When you deploy contracts to the mainnet, you need real ETH that you can purchase from one of the crypto exchanges (Binance, FTX, etc.)
1.3 Clone the repository
git clone https://github.com/MyriaPlatform/myria-smart-contract.git
1.4 Open your contract in Visual Studio Code
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 walletPUBLIC_KEY
- the public key of your Web3 walletSTARKEX_ADDRESS
- StarkEx Myria contract:- Goerli Testnet (staging):
0xF82C423a30E317f34f9b0997627F2F9c5d239Ad9
(Deprecated) - Sepolia Testnet (staging):
0xe99aFF31AD367Dcc45c60b237a2Ef096507d6095
(Latest supported) - Ethereum Mainnet (production):
0x3071BE11F9e92A9eb28F305e1Fa033cD102714e7
- Goerli Testnet (staging):
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
.