Selahaddin64 / NCD-Waste-Management

Waste management smart contract for Near Protocol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Waste Management - Near Protocol

Produce waste, register, transfer and recycle it! This project developed in Patika.dev's Near Bootcamp. Here is Loom video : https://www.loom.com/share/8e90d36905b54e79b9cbfb6de1388a07

Roles

  • Producer / Can produce waste
  • Recycler / Can recycle waste

Functions

Producer / You need to be a Producer to produce waste.

-beProducer(company:string, sector: string)  // Call function
-findProducerById(id:u32)                    // View function
-findProducers(offset: u32, limit: u32=10)   // View function         

Recycler / You need to be a Recycler to recycle waste.

-beRecycler(name:AccountId, type:string)      // Call function
-findRecyclersById(id:u32)                    // View function        
-findRecyclers(offset:u32, limit:u32=10)      // View function         

Waste

-produce(name:string, desc:string, deposit:u8) // Call function
-transfer(id:u32, recycler:string)             // Call function
-recycle(id:u32)                               // Call function       
-findWasteById(id:u32)                         // View function                          
-findWastes(offset: u32, limit:u32=10)         // View function   

Build and devDeploy

yarn
yarn build:release
near dev-deploy ./build/release/waste.wasm
export CONTRACT=<AccountId>
echo $CONTRACT

Functions Usage

BeProducer

near call $CONTRACT beProducer '{"company": "TOGG", "sector": "Automotive"}' --accountId producer1.testnet

View Producer By ID

near view $CONTRACT findProducerById '{"id": ProducerID }'

View Producers

near view $CONTRACT findProducers '{"offset" : 0 }'

BeRecycler

near call $CONTRACT beRecycler '{"name" : "RECYCLERID", "type": "mixed"}' --accountId recycler.testnet

View Recycler by Id

near view $CONTRACT findRecyclersById '{"id" : RecyclerID}'

View Recyclers

near view $CONTRACT findRecyclers '{"offset" : 0}'

Produce Waste

near call $CONTRACT produce '{"name": "TestWaste", "desc":"Metal", "deposit": 1 }' --accountId producer1.testnet --amount 1

Transfer Waste

near call $CONTRACT transfer '{"id" : WasteID , "recycler" : "RecyclerAccountID"}' --accountId producer1.testnet

Recycle Waste

near call $CONTRACT recycle '{"id": WasteID}' --accountId recycler.testnet

View Waste by ID

near view $CONTRACT findWasteById '{"id": WasteID}'

View Wastes

near view $CONTRACT findWastes '{"offset" : 1, "limit" : 10}'

About

Waste management smart contract for Near Protocol


Languages

Language:TypeScript 91.7%Language:JavaScript 8.3%