Skip to content

eAAts/eAAts-api-server

Repository files navigation

eaats-api-server

in this repo we use module

  • web3 Stroage(FileCoin)
  • the Graph
  • chainlink functions

run in local

  1. make an env file with
npm install
npm start
  1. fill form in .env with each private key

.env

PRIVATE_KEY=
RPC_URL_MUMBAI=https://polygon-mumbai.infura.io/v3/
RPC_URL_MATIC=https://polygon-mainnet.infura.io/v3/
NETWORK=TEST
CONSUMER_ADDRESS_MUMBAI=
SUBSCRIPTION_ID_MUMBAI=
CONSUMER_ADDRESS_MATIC=
SUBSCRIPTION_ID_MATIC=
WEB3STORAGE_TOKEN=
  • in order to fill .env form you need private key of

Subgraph API with the graph USING THE GRAPH

site : https://thegraph.com/studio/

http://localhost:3000/query?entityName=<entityName>&first=<first>&skip=<skip>

Usable entityName

  • orderCreateds
  • orderJoineds
  • orderDeliveryStarteds
  • deliveryCompleteds

uploading review data with web3 storage USING FILECOIN

image uploaded manually using nftstorage (filecoin) site : https://nft.storage

and metadata upladed with api using web3.storage module (filecoin) site : https://web3.storage/ module : https://www.npmjs.com/package/web3.storage

  const obj =
  {"name": "eAAts", "description" :`${description}`, "image": `https://${cid}.ipfs.nftstorage.link/`,
  "attributes": [
    {
      "trait_type": "BestMenu", 
      "value": `${vlaue1}`
    }, 
    {
      "trait_type": "Rating", 
      "value": `${value2}`
    },
    {
      "trait_type": "Level", 
      "value": `${value2}`
    }, 

NFT contract

after we uploaded metadat in ipfs we used it in nft https://mumbai.polygonscan.com/address/0x9EF14100F950d5335301a2d4E8Cc4776cC0115c4#writeContract

this is tokenURI example in IPFS

https://bafybeibmwpmwoxve3rlw5eutzwrrbypqoj6lctxgyx533jwmcem4vragga.ipfs.nftstorage.link/metadata.json

this is our collection in open sea https://testnets.opensea.io/collection/eaats

Filecoin Metadata API

Overview

This API allows users to store metadata associated with an image CID on the Filecoin network using the web3.storage capabilities.

Prerequisites

Before you start, make sure you have installed the necessary packages:

npm install web3.storage 

API

GET /store This endpoint allows you to store metadata related to a specific image CID.

Request Parameters:

cid: The CID of the image. (required)
description: A description associated with the image. (required)
menu: The menu/type related to the image. (required)
ratings: Ratings given to the image. (required)

Example Usage:

GET /store?cid=bafkreib3ip2x6tfpy5jnneh64yrle25wozvgsr6fqhqxfs2rt2uilzlkpy&description=The%20hamburger%20was%20delicious&menu=hamBurger&ratings=10

Flowchart Understand the flow of storing metadata with this Mermaid flowchart:

sequenceDiagram
Client->>+API: GET /store?cid=<CID>&description=<Description>&menu=<Menu>&ratings=<Ratings>
API->>+Web3.Storage: Create Metadata from Params
Web3.Storage->>+IPFS: Store Metadata.json
IPFS-->>-Web3.Storage: Return Metadata CID
Web3.Storage-->>-API: Return Metadata CID
API-->>-Client: Return Metadata CID
Loading

Chainlink Function Calls API Documentation

Overview

This API utilizes Chainlink to invoke on-chain functions and then decodes the resulting Chainlink response data.

Prerequisites

npm install express ethers @chainlink/functions-toolkit dotenv

API

GET / This endpoint invokes Chainlink functions with the provided parameters and returns the decoded Chainlink response data.

Request Parameters:

tokenAddress: Address of the token. (required)
amount: Amount for the function call. (required)
targetChainId: Target blockchain network ID. (required)

Example:

GET /?tokenAddress=0x123456...&amount=10&targetChainId=137

Response: Decoded Chainlink response data.

Sequence Diagram

sequenceDiagram
participant Client
participant API
participant Chainlink

Client->>API: GET / with parameters (tokenAddress, amount, targetChainId)
API->>Chainlink: callSourceCode(tokenAddress, amount, targetChainId)
Chainlink->>API: Returns transaction details and requestId
API->>Chainlink: decodeData(requestId)
Chainlink->>API: Returns decoded response
API->>Client: Return decoded Chainlink data
Loading

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages