A Simple Rust NFT API + Smart Contract

Overview

Rust NFT API

Purpose

Rust NFT API is a simple RESTful API developed in Rust that offers functionalities for creating, retrieving, and listing Non-Fungible Tokens (NFTs) on the Ethereum blockchain, along with managing their off-chain metadata.

Requirements

Before setting up the Rust NFT API, ensure you have the following components ready:

  1. Ethereum Node: An Ethereum test node, such as Ganache, for local blockchain simulation.
  2. IPFS: IPFS Desktop or similar for off-chain data storage, to test locally.
  3. Smart Contract Deployment Tool: Remix IDE or another tool for deploying the Smart Contract to the Ethereum blockchain.

Setup

Follow these steps to set up and run the Rust NFT API:

1. Start Ganache

Launch Ganache to initiate a local Ethereum blockchain node.

2. Deploy the Smart Contract

Using Remix IDE or your preferred tool, deploy the MyNFT.sol smart contract located in the contract folder of this project.

3. Start the IPFS Node

Run your IPFS node to handle off-chain metadata storage. If using IPFS Desktop, simply open the application.

4. Configure Environment Variables

Edit the .env file in the project's root directory to set the necessary environment variables:

`ETH_NODE_URL=http://localhost:8545 CONTRACT_ABI_PATH=./MyNFT.json MOCK_PRIVATE_KEY=69440d76b64f2418574043fbd79f3d4f56c293290c3056fc18b62b12013db7e7 # This is a placeholder for testing

TEST_OWNER_ADDRESS= TEST_TOKEN_ID=1 # Default to 1 TEST_CONTRACT_ADDRESS=`

5. Build the Project

Compile the project using Cargo:

bashCopy code

cargo build

6. Run Tests

Execute the project's test suite to verify the setup:

bashCopy code

cargo test

If any tests fail, revisit the previous setup steps to troubleshoot.

7. Run the Application

Start the Rust NFT API server by providing the deployed smart contract's address as a command-line argument (matching the TEST_CONTRACT_ADDRESS in .env):

bashCopy code

cargo run -- <Deployed_Smart_Contract_Address>

8. Interact with the API

Access the Swagger UI at http://localhost:3010/swagger-ui to interact with the API through a graphical interface or use your preferred tool to call the API endpoints directly.


Additional Notes

  • Ensure Ganache and the IPFS node are running before starting the Rust NFT API server.
  • The MOCK_PRIVATE_KEY provided in the .env example is for demonstration purposes only. Never use real private keys in your development environment or commit them to version control.
  • For any issues or contributions, feel free to open an issue or a pull request in the repository.
You might also like...
Smart Contract for Terra Name Service

TERRA NAME SERVICE CONTRACTS Terra Name Service is to create easy-to-remember names for your Terra address like ‘dokwon.ust’ instead of ‘terra1...whez

Emerging smart contract language for the Ethereum blockchain.

Emerging smart contract language for the Ethereum blockchain.

Vectis - Smart Contract Wallet

A smart contract wallet project to add functionality for users of DApps to manage their keys by allowing for recovery and account freeze, whilst preserving user control, and enabling relayer capability for gas provisioning

Heimdall is an advanced Ethereum smart contract toolkit for forensic and heuristic analysis.
Heimdall is an advanced Ethereum smart contract toolkit for forensic and heuristic analysis.

Heimdall is an advanced EVM toolkit which aims to make dealing with smart contracts on EVM based chains easier. Installation & Usage Heimdall's update

The Ink! smart contract SDK for XVM interface

Ink! XVM SDK The Ink! smart contract SDK for XVM interface. This SDK contains contract wrappers and all middleware code to make XVM development easy.

MevWallet is a smart contract wallet that allows the user to capture MEV from Searchers, or create MEV on purpose.

MevWallet MevWallet is a smart contract wallet that allows the user to capture MEV from Searchers, or create MEV on purpose. This repo contains the so

An EVM low-level language that gives full control over the control flow of the smart contract.

Meplang - An EVM low-level language Meplang is a low-level programming language that produces EVM bytecode. It is designed for developers who need ful

A brand-new multi-scenarios smart contract compiler framework

The Smart Intermediate Representation The Smart Intermediate Representation(short for IR) project is a new compiler framework intended for smart contr

My attempt at learning Solana program (smart contract) development through RareSkill's Solana course.

60-days-of-solana My attempt at learning Solana program (smart contract) development through RareSkill's Solana course. Originally, I was trying to cr

Owner
Luis Soares
Luis Soares
The NFT smart contract powering xyz on Terra

xyz NFT Contract This repository contains the core NFT smart contract that implements xyz, a base layer for metaverses on the Terra blockchain. The xy

null 16 Sep 25, 2022
Example NFT marketplace project using ink! smart contract.

NFT Marketplace project This contract is an example for the NFT marketplace implementation. License Apache 2.0 ??️ How to use - Contracts ?? Build Use

Swanky dApps 8 Jan 18, 2023
A smart-contract api and client for revm

revmup A smart contract and client API for revm. Features: Auto-generate contracts that interact directly with revm without needing ethers provider Co

Dave Bryson 17 Aug 6, 2023
Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana (WIP) ⛏👷🚧⚠️

Solana BPF Boilerplate Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana This boilerplate provides the following. Si

ono 6 Jan 30, 2022
A simple example demonstrating cross-contract calls in CosmWasm smart contracts

Cross-contract calls This tutorial demonstrates cross-contract calls with CosmWasm v1. Overview An end user calls the reservation contract to register

csli Tools 3 Sep 12, 2022
Smart Contract built in Rust to run inside Cosmos SDK module on all chains that enable it

CoinSwap is a Smart Contract that is built on the terra blockchain and can be used to swap cryptocurrencies such as LUNA, UST, TerraUSD, Anchor, Mirror Protocol, LUNI and other CW20 tokens. The Project also contains a smart contract which works as a analysis tool for the gas fees on the Terra Blockchain.

Prajjwal Chittori 9 Oct 11, 2022
clockchain is a system for benchmarking smart contract execution times across blockchains.

Clockchain Clockchain is a research tool for benchmarking smart contract execution times across blockchains using Arcesco-- a block-chain agnostic ins

Zeke Medley 7 Oct 3, 2022
Testing a smart contract on the Solana blockchain

Environment Setup Install Rust from https://rustup.rs/ Install Solana from https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-to

Maurice 1 Oct 25, 2021
clockchain is a system for benchmarking smart contract execution times across blockchains.

Clockchain Clockchain is a research tool for benchmarking smart contract execution times across blockchains using Arcesco-- a block-chain agnostic ins

zeke 7 Oct 3, 2022
An example smart contract that builds on top of xyz

xyz Guestbook Tutorial Contract This repository contains an example smart contract that illustrates how to build on top of the xyz NFT contract. This

null 5 Apr 4, 2022