Dylan  Iqbal

Dylan Iqbal

1644223874

Build a Simple NFT Marketplace with Amazon Managed Blockchain

Simple NFT Marketplace

This project provides sample code to build a simple NFT (Non-Fungible Token) based marketplace with Amazon Managed Blockchain.

NFTs are cryptoassets in which each token is unique, and therefore able to create a relationship, or contract, between a specific unique token, and a specific asset - including physical asset, virtual asset and more. This contract allows ownership of a digital asset to be proven. For this reason, NFTs are also known as deeds.

While there are multiple standards for non-fungible tokens, this exercise will use the Ethereum Blockchain network, and ERC721 standard for non-fungible tokens.

To be able to create the required contracts, we will:

  1. Create a Node connected to a Blockchain network
  2. Manually Generate, verify and deploy a contract.
  3. Deploy an API to automate the process
  4. Create a Front End that utilizes the API
  5. Deploy the MarketPlace Front End

You will use the following tool set:

  • Git, and your OS Command Line
  • Node.js and npm
  • the AWS CLI and AWS Console
  • AWS CDK to deploy backend API (/provision)
  • Contract written in Solidity (/contract)
  • Marketplace web UI (/marketplace)

Do NOT use this codes in your production workloads.

Architecture

Architecture

Overview

All of the following documentation assumes that you are running on a UNIX based environment. If you do not have a UNIX based command execution environment, you can also use AWS Cloud9.

Quick Start

Install Dependencies

To get started run the following command in the root of this repository to install the required dependencies.

npm install

Set your AWS profile

The AWS profile currently active on your shell will be used to deploy the infrastructure, if no profile is specified, the default profile will be used.

To specify a profile other than default to be used, run the following command replacing my-profile with your profile name.

export AWS_PROFILE='my-profile'

Run the deploy script

Run the deploy script and follow any prompts by running the following command.

./deploy.js

Cleaning Up

⚠️ The peer node used in this example can cost as much as $0.174 per hour depending on your region. It is recommended to remove these resources once they are no longer being used.

To remove all of the resources created from this example, run the following command from the root of the repository.

npm run cleanup

This will use CDK to remove the infrastructure we deployed, as well as remove the deploy-settings.json file created by the deploy script.


Creating a node for Ethereum Testnet: Ropsten

Before you begin

Clone this repository to your workspace or local machine. You will use the code located in the specified directories at each step.

Creating your Amazon Blockchain Node

Note: The creation of the node can take up to 30 minutes.

To connect to the Ethereum network, we must create a node and connect it to the appropriate network. We will use Ropsten, also known as the Ethereum Testnet, which is a test network allowing for blockchain development testing before deployment on Mainnet.

This node will provide our endpoint to communicate with the Ethereum network.

To get started, create an Ethereum node in the AWS Console for Amazon Managed Blockchain.

For Blockchain Network, select Ethereum Testnet: Ropsten and use the remaining configuration default values that have already been populated then select Create Node as outlined in the image below.

Creating the node in the AWS Console

As mentioned, at this point, the actual creation of the node can take up to 30 minutes.

When the node creation is complete, click the node ID to open the node details page and copy the HTTP endpoint as pictured below, as it will be needed in our next step, to connect our code to the appropriate endpoint for the contract to be created.

Getting the HTTP endpoint


Deploy Contract

Next we will deploy the contract written in Solidity to Ethereum Testnet Ropsten. Solidity is an object-oriented, high level language for implementing smart contracts.

We will also be utilizing hardhat, an Ethereum development environment which runs on Node.js that allows you to run Solidity locally.

Perform all of the following steps in the command line of the /contract directory in your local project

What are we doing? In this step, we are installing the hardhat environment with Node.js and compiling the contracts. Note the contract defined in the /contract/contracts directory. We will deploy the contract using the deploy.js and deploy-amb.js scripts in the /contract/scripts directory.

Contract Overview

We will be deploying the contract with the filename of SimpleERC721. As the name implies, SimpleERC721 conforms to ERC721, an interface that can issue NFT tokens. The implementation inherits ERC721 from openzeppelin, but some have their own implementations. The implementation content can be found here.

Compile Contract

In your terminal or command line, make sure our current working directory is /contract/, we will start by installing the dependencies.

npm install

Then we will compile the contract using hardhat.

npx hardhat compile

After compiling, you should see directories contract/artifacts and contract/cache.

Testing (optional)

Note: If you would like to skip this step, proceed to Deploy to Ethereum Ropsten.

The following command will run the tests defined under /contract/test.

npx hardhat test

Verify build locally (optional)

Note: If you would like to skip this step, proceed to Deploy to Ethereum Ropsten.

The following steps utilize two terminal (or command line) sessions, both running in the /contract directory. We will refer to the terminal sessions as "Terminal A" and "Terminal B". for the purpose of this step.

What are we doing? Use of the two terminall sessions will allow us to simulate our environments locally running a local JSON-RPC server in terminal A (or server terminal), and then interact with that server in via terminal B (or the user terminal) for testing purposes.

First, start the local JSON-RPC server by running the following commands in Terminal A.

npx hardhat node

Then run the following command in Terminal B to deploy the compiled SimpleERC721 to your local environment.

npx hardhat run --network localhost scripts/deploy.js

If successful, you should see the following output in Terminal B where 0x... is the address where the contract was deployed. Copy this address, as we will need it for the next step.

> Contract deployed at 0x5FbDB2315678afecb367f032d93F642f64180aa3

Next, we will use the hardhat interactive console to issue an NFT token to the SimpleERC721 contract that is defined in the contract/contracts directory.

Run the following command in Terminal B to start the hardhat interactive console.

npx hardhat console --network localhost

Once the console is running, paste the following code line by line into Terminal B and replace <contract address> with the address of the deployed contract we copied in the previous step.

const SimpleERC721 = await ethers.getContractFactory('SimpleERC721');
const contract = await SimpleERC721.attach('<contract address>');
await contract.newItem('dummy');

You have now issued a new NFT token. Normally, the 'dummy' value would be in URI format, but for verification purposes it is just a string.

The contract manages a unique ID value named tokenId internally. The tokenId is incremented each time an NFT is issued and has a one-to-one association with the NFT's URI. You can read from the Transaction log which tokenId was assigned, but for this demonstration we will just pull by the tokenId of 1, since we know only 1 has been created.

In Terminal B where we have our hardhat interactive console running, we will retrieve the token by ID by running the following.

await contract.tokenURI(1);

The console will output 'dummy' since that was the value we set in the previous step. You can now exit both Terminal A and Terminal B processes by pressing Ctrl + C twice.

Deploy to Ethereum Ropsten via Amazon Managed Blockchain

We can now deploy the contract to Ethereum Ropsten for testing.

First, the deploy script depends upon Environmental variables being set in order to connect with your Ethereum Blockchain node.

Set the Amazon Managed Blockchain HTTP endpoint to an environment variable in your terminal by running the following command. Replacing <my-endpoint> with the endpoint copied from the instructions in the previous page of Creating a node for Ethereum Testnet Ropsten.

export AMB_HTTP_ENDPOINT='<my-endpoint>'

Next, create an account for the owner to deploy the contract by executing the following command.

npx hardhat account

The Address in the output is the address needed to send the token, and the PrivateKey is the private key needed to sign the Transaction. Address is generated from PrivateKey, so it has a one-to-one relationship. Be sure to post this Address and PrivateKey somewhere as you will need them in subsequent steps.

Note: In a real world application, extreme caution should be taken with storing the PrivateKey to avoid any unauthorized access.

To deploy our contract, we have to pay the cost of gas in Ethereum. Therefore, we need Ropsten Ethereum (rETH), and we must deposit Ethereum on the Address we created above. There are several services that distribute Ethereum on the Ropsten network for testing purposes, known as Ropsten Ethereum Faucets.

You can use this faucet or Search with your favorite search engine for Ropsten Ethereum Faucet and use a faucet to deposit Ethereum to the Address we just created. You may consult Ethereum documentation for more information.

You must:

  1. Navigate to a provided rETH faucet and
  2. Enter the Address from the previous Address/PrivateKey pair

After the deposit is complete, run the following command to set up an account to deploy the contract.

Replace <0x...> with the contents of PrivateKey from the previous step.

The following assumes a bash shell. Use SET on Windows

export PRIVATE_KEY='<0x...>'

Next, set up AWS IAM permissions to connect to the Amazon Managed Blockchain if you don't have access already. If you want to create a new IAM user, attach the AmazonManagedBLockchainFullAccess policy. Set your AWS Access Key ID and AWS Secret Access Key in your environment variables as follows: Each <...> needs to be replaced with the appropriate value.

export AWS_ACCESS_KEY_ID='<...>'
export AWS_SECRET_ACCESS_KEY='<...>'

IMPORTANT: These access key environment variables must currently be set until aws-web3-http-provider/5 has been implemented.

Finally, run the following command to deploy SimpleERC721 to Ethereum Ropsten via Amazon Managed Blockchain.

npx hardhat run --network amb scripts/deploy-amb.js

Note: Deployment time may take a while depending on network congestion

If deployed successfully, you will see an output similar to the following.

> Contract deployed at 0x...

Copy the contract address from the output and save it somewhere as you will need it in subsequent steps.

Note: The Address and PrivateKey of the account that deployed the contract will have owner priveleges on the contract and is normally a very important account when used in production.


Deploy API

Deploy the API with the CDK code in the /provision directory.

CDK Pre-requisites

Please refer to the AWS CDK Documentation for the basics of CDK.

To deploy with CDK, you need a profile with AWS IAM permissions and Node.js.

Installing AWS CDK

Execute the following command in the environment where Node.js can be executed to install the AWS CDK CLI.

npm install -g aws-cdk

If cdk --version runs successfully, the installation is complete.

Deploy Infrastructure

Switch to the /provision directory if you haven't already, then run the following to install dependencies.

npm install

If you are new to CDK, you need to bootstrap. Please execute the following command.

cdk bootstrap

You will need to install the dependencies in the provision/lambda directory as well. You can do this by running the following command.

cd lambda; npm install; cd -;

Then copy the compiled product of Contract (created in the previous section) to /lambda/contracts. Run the following command.

cp ../contract/artifacts/contracts/SimpleERC721.sol/SimpleERC721.json lambda/contracts/.

Next, because our CDK project is written in Typescript, we must build it before we can deploy it. Build the CDK project by running the following command.

npm run build

The CDK project uses variables to populate the AMB Endpoint and Contract Address. Therefore, before we can deploy the project, will set the required environment variables. AMB_HTTP_ENDPOINT is the HTTP endpoint of the node we created in the previous step Creating a node for Ethereum Testnet: Ropsten and CONTRACT_ADDRESS is the address of the contract we deployed in Deploy Contract. Replace the values in the following command with the values saved from previous steps and execute it.

export AMB_HTTP_ENDPOINT='https://<node id>.ethereum.managedblockchain.<region>.amazonaws.com'
export CONTRACT_ADDRESS='0x...'

Finally to deploy, execute the following command.

cdk deploy SimpleNftMarketplaceStack

After deployment is complete, you should see output values that look something like this.

> Outputs:
> SimpleNftMarketplaceStack.NftApiEndpoint8C6C6AD5 = https://********.execute-api.us-east-1.amazonaws.com/prod/
> SimpleNftMarketplaceStack.UserPoolClientId = 6en**************
> SimpleNftMarketplaceStack.UserPoolId = us-east-1_****

Save the output values for the API Gateway Endpoint, Cognito UserPool ID, and Client ID as they will be needed in the upcoming steps.


Testing The Front End (local)

We now want to launch the front end to verify all of our previous steps have been completed successfully. In this step, we will not be deploying the front end and only running it locally.

Perform all of the following steps in the /marketplace directory.

Launch

Run the following command to set the front end environment variables.

cat <<EOF > .env.local
VUE_APP_AWS_REGION=<region>
VUE_APP_API_ENDPOINT=<api-endpoint>
VUE_APP_USER_POOL_ID=<user-pool>
VUE_APP_USER_POOL_WEB_CLIENT_ID=<web-client>
EOF

Replacing the values enclosed in <> with the value as follows (omitting the <> in your own value):

PlaceholderSource
<region>The region you deployed your stack in previous steps
<api-endpoint>NftApiEndpoint output from Deploy API
<user-pool>UserPoolId output from Deploy API
<web-client>UserPoolClientId output from Deploy API

Then run the following command to install the dependencies for this element of the project.

npm install

Finally, run the following command to start the local webserver and listen on localhost:8080.

npm run serve

Go to your browser at http://localhost:8080. If the site loads without errors, everything from the previous steps have been completed successfully.

Create an account

When http://localhost:8080 loads, you will see a login page. In order to proceed here, you will need to create a new account. This will utilize Amazon Cognito to create and validate a new account, so you will need to do the following:

At the login screen, choose to create a new account using the 'No Account Create One' selection as shown. Sign in to your account

On the Create a new account screen, enter a Username, password, and a valid email address as you will need to verify with a verification code (sent to this email) to sign up.

What are we doing here? As part of the previous deployment, we created a cognito Identity User pool in Your AWS Account to control access to the marketplace. This information is only available to your account for authentication, therefore this information does not get used or shared externally in any way.

Eth Deposit

After you have verified your account, click the "Account" button in the upper right- hand corner of the page where you will see the following information:

  • Address: Public Address
  • Balance: The balance of deposited Ethereum
  • Private Key: The private key of the wallet. Display by pressing the "Retrieve" button

A certain amount of Ethereum is required to create and transfer NFTs. Therefore, you need to deposit a test Ethereum to the address shown on the website as you did in Deploy Contract.

Once the deposit is complete, reload the Account page until the balance shown is greater than 0.

Creating an NFT

Click the "Home" button in the upper left to move to the first page, and press "Create NFT" to move to the NFT creation page. Upload an appropriate image file, enter a title and description, and press "CREATE". When the creation is completed, you will automatically be taken to the NFT details page.

Confirmation and transfer of NFT

The NFT details page shows the title, description, and owner's address you've set. The owner is initially the creator of the NFT and the owner is the user who is able to transfer the NFT.

Specify an appropriate address (example: 0xE36409e343896a10078500E4a8314375c3B0c24b) to transfer the NFT to at the bottom, and execute.

When the transfer is complete, the page will automatically reload and you can see that the owner has a different address and your current user is no longer able to transfer since they no longer own the NFT.

The page also shows whether the token is displayed in the marketplace (boolean), the creator of the NFT (the account that receives the royalty), and the royalty percentage. The owner of the token can set the price and publish it on the marketplace. Published tokens can be purchased by accounts other than the owner.


Front End Deployment (optional)

In this step we will deploy the front end using our CDK application. This step assumes that the CDK pre-requisites from Deploy API have already been completed.

Perform all of the following steps in the /marketplace and /provision directories.

Front End Build

To build the front end, run the following command in the /marketplace directory.

npm run build

If the /marketplace/dist directory is created, it was succesful.

Front End Deployment

Next we will deploy /marketplace/dist to S3 using CDK, making the content accessible from CloudFront.

Switch to the /provision directory and run the following command.

cdk deploy SimpleNftMarketplaceFrontendStack

Deployment is now complete. If you access the CloudFront endpoint from the CDK outputs in the terminal and the page loads without errors, it was successful.

Download Details: 
Author: aws-samples
Source Code: https://github.com/aws-samples/simple-nft-marketplace 
License: MIT
 

#aws #nft #blockchain #nonfungibletoken #ethereum

What is GEEK

Buddha Community

Build a Simple NFT Marketplace with Amazon Managed Blockchain

How to build an NFT marketplace ASAP?

Do you want to know how to build nft marketplace in just 1 week that can help clients to manage, store, and sell your NFTs globally? If yes, then you are at the right place. Call Antier Solutions’ subject matter experts today.
https://www.antiersolutions.com/nft-marketplace-development-company/
Email Us : info@antiersolutions.com
Contact us: +91 98550 78699 (India) , +1 (315) 825 4466 (US)
3111 East Tahquitz Canyon Way, Suite 140, Palm Springs, CA 92262

#build nft marketplace #create an nft marketplace #how to build nft marketplace #how to create a nft marketplace #how to build an nft marketplace #create your own nft platform

How to make an NFT marketplace like a pro?

Do you want to know how to make an NFT marketplace like an expert? If yes, then Antier Solutions can help you out. We deploy and develop world’s best NFT marketplace. Visit us now!
https://www.antiersolutions.com/nft-marketplace-development-company/
Email Us : info@antiersolutions.com
Contact us: +91 98550 78699 (India) , +1 (315) 825 4466 (US)
3111 East Tahquitz Canyon Way, Suite 140, Palm Springs, CA 92262

#build nft marketplace #create an nft marketplace #create nft marketplace #create own nft marketplace #how to build an nft marketplace #how to build nft marketplace

Build an exquisite blockchain business with a professional NFT Marketplace Developer

The NFT marketplace development has great value and demand in the blockchain market. It has integrated smart contracts present in the NFT marketplace platform for managing the overall flow of transactions without any delay. The professional NFT marketplace platform developers are highly skilled in providing worthwhile projects for investors. The NFT marketplace developers are in huge demand in the real world after the NFTs disrupted the entire blockchain industry.

The NFT marketplace development is well structured and built using the latest blockchain technology to attract global users. It is completely decentralized in the NFT marketplace platform to eliminate the need for intermediaries like banks to benefit the users with fewer gas fees and wait times. The investment towards NFT marketplace platform developers helps investors to build sturdy NFT projects with high-end features to reap profits in the future.

Advantages offered in the NFT marketplace platform:

  • Investors can gain immediate liquidity and earn high ROI as passive income from the NFT marketplace platform for their business growth.
  • The NFT marketplace platform maintains high transparency over user transactions details to gain their trust.
  • It has integrated multi-level security protocols like 2-factor authentication, DDOS protection, and Escrow protection to prevent various hacks and attacks.
  • The NFT marketplace platform has integrated digital wallets for users to store, display and sell their NFTs.
  • It is an open-source network in the NFT marketplace platform for anyone to access seamlessly, irrespective of their wealth or social background.

The NFT marketplace platform is currently trending in the digital world that paved the way for investors to explore the benefits offered for their business growth. Investors can hire professional NFT marketplace developers from Blockchain App Factory to build featured NFT marketplace platforms using the latest cutting-edge technology at an affordable price.

#nft marketplace developer #nft marketplace #nft marketplace platform #nft marketplace development #blockchain

Build your blockchain business with advanced NFT Marketplace Development Solutions

The NFT marketplace development solutions are in great demand that disrupted the entire blockchain market after its launch. It lit the way for investors and startups to explore the benefits for their business growth. It allows the investors to display their creative collectibles like artworks, music albums, and virtual gaming assets for promotion and sell them in the future through fixed-price or bid for an auction to earn profits.

The NFT marketplace development has an interoperable feature that allows investors to exchange their non-fungible tokens (NFTs) on various marketplaces or virtual environments. It has integrated smart contracts present in the NFT marketplace platform to manage the overall operations of transactions without any interruption. It benefits the investors to gain high returns in the future for investing towards the NFT marketplace development.

Advantages of NFT Marketplace Development:

  • Investors can earn profits from the NFT marketplace development through various service charges like minting, transactions, and listing.
  • The NFT marketplace development maintains high transparency over user transaction details to gain their trust.
  • It has an integrated digital wallet present in the NFT marketplace platform for users to store, display, create and buy or sell NFTs.
  • The NFT marketplace platform offers investors customizable options to alter changes based on user requirements.
  • It is an open-source network that allows anyone to access the NFT marketplace platform instantly, irrespective of their wealth or social status.

The NFT marketplace development is the future that is expanding more opportunities for upcoming generations to make profitable investments for generating high revenues. Investors can connect with the world’s leading Blockchain App Factory to get NFT marketplace development solutions with high-end features at an affordable price to top the global market.

#nft marketplace development solutions #nft marketplace #nft marketplace development #nft #blockchain

jack browny

jack browny

1622545399

How to create an NFT marketplace ?

If you are a business visionary or a startup, why should you begin a NFT marketplace for business? At that point this is the primary inquiry that would strike a chord - “How to make a NFT marketplace?”

1.To begin with, you will have to think about the lawful strategies prior to starting your NFT marketplace creation:

2.First you have to create a corporate organization and provide clear and valuable information about your organization and must need a legal licence.

3.Then you have to create terms and conditions for your company.

4.Make sure that you have to create your privacy policy and other policies clearly.

5.Next you have to allocate the IP allocation, content consideration, authenticity, and security laws in place.

Now let us look over how to create NFT marketplace:

1.Install metamask browser as it just has a safe pixura browser settings that is based on ethereum.

2.Make a valid smart contract for your marketplace.

3.Go to the administrator board and add a few collectibles to your NFT marketplace. This should be possible by adding tokens made on the ERC721 token norm.

4.You can alter your collectibles by altering them on the marketplace by topping off about creation, standard picture and collection icon.

5.Subsequent to saving, revive your marketplace, at that point you can see your collectible in your marketplace.

6.You can set the cost of the token in ETH by utilizing the Metamask exchange.

7.Empower the marketplace usefulness to incite deals. You can likewise permit the vendors to list their token in your marketplace.

If you are looking to develop your own NFT marketplace with experts?
WeAlwin Technologies is a highly recommended NFT marketplace development company to provide highly qualified NFT marketplace software to launch your NFT marketplace within 7-10 business days.

Get the best and error-free NFT marketplace software from WeAlwin Technologies now to instantly launch your marketplace like rarible.

Get a free demo of NFT marketplace !!

Reach our experts via,

Whatsapp/Telegram: 9994044929
Skype:live: info_945986
Mail-id: sales@alwin.io

#nft marketplace #create nft token #how to create nft #nft marketplace development #nft marketplace platform #nft marketplace script