Как сделать смарт контракт для opensea
Перейти к содержимому

Как сделать смарт контракт для opensea

  • автор:

Зачем нужен смарт-контракт для выпуска NFT-коллекции

Существует 2 варианта выпуска NFT- коллекции.
Подробнее писал в статье Рынок NFT. Как все устроено.

  • Просто выпуск на маркетплейсе (чаще всего Opensea)
  • Drop коллекции (первая и вторая статьи о том, как сделать успешный Drop)

Если коллекция выпускается без Drop, то смарт контракт не нужен. Такой подход предполагает, что создатель коллекции сам оплачивает mint коллекции (создание NFT в блокчейне). Пользователь просто заходит на маркетплейс и грузит в блокчейн коллекцию, заплатив за это комиссию.

Выпуск коллекции без Drop-а:

  • В целом гораздо меньше затрат
  • Не нужно писать смарт контракт
  • Не нужно арендовать сервер
  • Не нужно делать сайт
  • Не нужно делать кнопку mint

  • За mint придется платить самим
  • Если самостоятельно платить за mint, то скорее всего будет выбран блокчейн не ETH, а это сильно снижает вероятность высоких продаж коллекции.
  • нет возможности автоматически распределять средства от продажи коллекции на несколько кошельков основателей проекта

Выпуск коллекции через Drop:

  • Пользователи сами платят за mint коллекции
  • Можно сделать коллекцию на несколько тысяч NFT. объем затрат не зависит от числа NFT в коллекции
  • Можно выпускать коллекцию на ETH — это сильно увеличивает объем рынка
  • Можно придумывать свою логику взаимодействия с аудиторией (аукционы, разбиение продаж на несколько этапов и проч.)
  • Можно в смарт контракте описать автоматическое распределение средств на несколько кошельков по определенному правилу

  • Есть риски, что вас взломают и все украдут
  • Нужно больше затрат на смарт- контракт, сайт, сервер, кнопку минт, придумывание логики.

Без Drop-a и без смарт контракта имеет смысл выпускать коллекцию тем, кто хочет попробовать что-то сделать на данном рынке и не готов инвестировать серьезные средства в проект.

Drop нужно делать, и смарт-контракт понадобится, если есть амбиции сделать крутой проект и есть инвестиции от $70k на проект.

Create a standard NFT smart contract and sell it on OpenSea

WP Smart Contracts

The ERC-721 standard for non-fungible tokens was proposed in 2018 to prove on-chain digital ownership of individual entities. Since then, the NFT markets have grown in popularity exponentially.

At the time of this writing, the most expensive NFT sold so far is CryptoPunk # 9998 [click to go to OpenSea] sold for $ 530 million (124,457 Ethers).

Some interesting facts about NFT are:

  • There are $10-$20 million worth of NFT sold in the blockchain every week.
  • Complete value of NFT sales in 2020 was $250 million.
  • Nonfungible.com surpassed a value of $2 billion in 2021
  • The collectibles market is the fastest growing.

NFT Ocean

OpenSea is the largest NFT market in the world. More than 200 thousand users moved more than $ 2 billion (420,000 Ethers) in the last month alone.

There’s no question that OpenSea is by far one of the biggest players in the NFT business today.

So, the purpose of this tutorial is to teach you the basics to create your own NFT Smart Contract in the easiest way possible and sell your collection on the biggest exiting NFT market.

Smart Contracts in WordPress

In this tutorial, we will show you how to create a standard ERC-721 smart contract using WordPress, without the need for coding or advanced Blockchain knowledge.

For this you will need:

  • A metamask account (metamask.io)
  • Get some coins in Ether or any other coin in side-chains
  • A WordPress site
  • Install the WPSmartContracts plugin

Mochi Smart Contract

Mochi is the Smart Contract flavor for NFT Standard Tokens in WPSmartContracts.

The Mochi Smart Contract has all the features of the ERC-721 specification, like:

  • Ownership
  • Transfer
  • Approval
  • Mint
  • Burn

The WPSmartContracts plugin allows you to define, implement and interact with the smart contract, but also store the images or media and NFT item data like attributes, category, name, etc.

Media Formats

NFT Items can represent any desired media, like:

  • Image: an image is a unique file like a piece of art, a picture, profile, etc. Formats are .png, .jpg or .gif
  • Video: a recording, animation, short movie, etc. For videos you can choose multiple files, but all files should correspond to same asset with different format, i.e. .mp4 and .ogv. This is because some video formats are more suitable than others on different devices.
  • Audio: a song, podcast, effects, etc. You can choose multiple files, but all files should correspond to same asset, i.e. .mp3 and .ogg.
  • Documents: this is a unique file that correspond to a property, license, loan, debt or any other document you need.

Deploy the Mochi Smart Contract

In order to create (and sell) your NFT, you must first create an NFT Collection, this is a Container Smart Contract that will maintain, manage and allow you and your customer to interact with your NFT items on the blockchain.

  • Ethereum: the giant of Smart Contracts, but unfortunately now gas fees in Ethereum are simple prohibitive. But fear not, there are other solutions, like
  • Polygon network (Matic): Polygon is a layer two scaling solution for building Ethereum-compatible blockchains, which means you can have the advantages of Ethereum without absurd high gas fees.
  • Binance Smart Chain (BSC): this is a side-blockchain built by the Binance Chain community and unlike Binance Chain, BSC is compatible with the Ethereum Virtual Machine (EVM).
  • xDai chain: is an Ethereum-based sidechain that uses a Proof-of-Stake mechanism and their native coin is pegged to the dollar. Making transactions cost less volatile.

At the moment of writing OpenSea only supports Ethereum and Polygon

Once you have the network of your choice, you can go to your WordPress site and follow this steps to deploy your Smart Contract.

  • Login into your WordPress install
  • Login into Metamask in your desired Ethereum network
  • Click “NFT Collection” — “Add new”
  • Choose the flavor: ”Mochi”
  • Fill in the following fields: title, description, featured image
  • Fill in the smart contract definition: symbol and name (this is the symbol and name representing you smart contract, the whole collection)
  • “Who can mint?”: this defines who can create items on your smart contract, in this case you are the only creator, so choose “Only contract owner” can mint.

There are two fees when you are deploying:

  • The WPSmartContrcats fee. Which you can check here: https://wpsmartcontracts.com/pricing/
  • The gas fee. Except for the Ethereum network, gas fees tend to be very low.

Please note that if you are using Metamask to calculate gas rates and you do not have sufficient funds in your account, the rates may be over-calculated. Make sure you have sufficient funds to get an accurate gas fee estimation.

Always test first

A piece of advise: first implement your smart contracts to test networks, this is totally free and you can get the full experience of interacting and managing your NFT smart contract. If you are satisfied with the results, and only then, implement your smart contracts on the main network.

How to Create and Deploy an NFT Smart Contract

This block post will show how to create and deploy your NFT to Opensea market place. An NFT can represent anything of value, it can be a character in a game, a digital art, title deeds of an apartment and so forth.

Openzeppelin has implemented code for the ERC1155 standard. The ERC1155 standard is a contract interface that is used for both fungible tokens and NFT.

Before writing our NFT smart contract we should save our image to IPFS (InterPlanetary File System). IPFS is used to save digital media on the blockchain.

Uploading NFT Media File

The media file for the NFT smart contract will be saved on nft.storage . Navigate to the to Nft Storage. We can save our NFT media file on IPFS. Login using your Github account or use your email to sign up for the service.

Click on upload button and you will be presented with the a screen that looks like the image below.

Image description

If you want to upload just one file you can click on the upload button to do that but if you have a directory of files you will need to upload them as a CAR . A CAR is a Content Addressed Archive that allows you to pre-compute the root CID for your assets.

Since we will most likely be uploading a directory of files lets proceeds to Upload CAR.

Image description

Click to open the directory and select the NFT’s Assets files. Click on the download button to download the CAR file. Go back to the site NFT Storage and upload the CAR file to upload your assets to IPFS.

Uploading NFT Metadata

The next step is to upload the metadata that will be read by Opensea. A metadata file is a JSON file that contains a JSON object with the description of the assets.

Sample JSON Object

Exit fullscreen mode

The location of the assets is got from NFT Storage. Click on the Actions button of the uploaded asset.

Image description

A dropdown is displayed. Click on View URL. Clicking on the View URL button takes you to a page where all the images that was uploaded via CAR is listed. Click on the link to show the image on the browser. Copy the image link and use it as the image value of the JSON file.

you should name your images using numbers like: 1.png , 2.png ; so it will be easy to retrieve the image location.

You will have to upload one JSON file for each image assets uploaded. Also name your JSON file using numbers like 1.json , 2.json and so forth.

We need to upload the metadata file to IPFS using the same method we used for the upload of the image file. Make a CAR file of the content of the directory of JSON metadata and upload the CAR file to IPFS via NFT Storage.

Create the Smart Contract

Exit fullscreen mode

We are making use of OpenZeppelin implementation for ERC1155. At the top of the file we imported the ERC1155.sol file, we also imported an utility contract file that is used for concatenating strings together. Our contract inherits from the ERC1155 contract.

We defined four constant variables which we initialized with values from 1 to 4. The URL of the metadata of the assets is passed to the constructor of ERC1155.

Exit fullscreen mode

Notice the id in curly braces . This id represents the number that we named the JSON file. For each minted NFT, the contract will call the function uri to get the complete location of the metadata. We are calling the _mint function to mint 100 copies each of the four types of NFT we have and assigned them to msg.sender .

Our custom implementation of the uri function concatenates the id of the NFT with its base URL and returns the complete URL of the NFT metadata.

Deploy your contract to a blockchain testnet and copy the contract address and proceed to the testnet of Opensea and search using the deployed NFT contract address. Your NFT contract and its image will be displayed on Opeansea.

Creating your first NFT smart contract

This tutorial will walk you through the many different components of building, deploying, and selling a non-fungible contract on Ethereum's testnet that can be traded on OpenSea.

The tutorial assumes you have some familiarity with coding, but are brand new to the world of Web3 and smart contracts. We will be using the following dependencies in the tutorial:

These tools are only some of the current community favorites so we will be using them to encourage best practices. There are many great alternatives to these tools that can also be used, and we are always open to feedback on better practices and improvements.

As we dive into new concepts in this tutorial, we will review definitions that might be new to you coming into Web3 and offer guidance on how to provide the best user experience possible for users of your smart contract. By the end of the tutorial, you will have a deployed NFT contract on the Rinkeby network, a beautifully set up collection on OpenSea, and some NFTs within that collection ready to sell on OpenSea.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *