Usage

  1. Clone project code.

bash git clone git@github.com:mirrorworld-universe/mirrorworld-sdk-rust.git cd mirrorworld-sdk-rust

  1. run.

bash cargo run

  1. test.

bash cargo test

Quick Setup

Install

```bash

/Cargo.toml

[dependencies] mirrorworld-sdk-rust = "0.1.5" ```

Setup

authentication && wallet

```bash use mirrorworldsdkrust::{ fetchuser, getnftdetails, gettoken, gettransactions, login, completesignup, signupemail, }; use mirrorworldsdkrust::{ setconfig, setapikey, }; use mirrorworldsdk_rust::wallet::{Wallet};

set global apikey

set_apikey("your apikey");

Completes user signup with email

let res = complete_signup({ LoginWithEmailParam { email: "your email", code: "your email code", password: "your password", } });

let response = if let Ok(Some(response)) = res { response } else { todo!() };

Completes user signup with email

signup_email("email@example.com");

set_config( "your token", "your apikey" );

GETChecks whether is authenticated or not and returns the user object if true

fetch_user();

Get wallet tokens.

get_token();

Fetches the wallet transactions for a user

get_transactions();

GET Fetch single NFT details

getnftdetails("nft address");

wallet

let KEY: &str = "your api key"; let TOKEN: &str = "your access token"; let SECRET_KEY: &str = "your secret key"

init wallet

let wallet = Wallet::new(KEY.tostring(), NetEnv::DEVNET, TOKEN.tostring(), SECRETKEY.tostring());

Transfer Token to another address

let result = wallet.transfer_spltoken(( "to publickey address", "amount" "mint address", "decimals", )).await.unwrap();

Transfer SOL to another address.

let result = wallet.transfer_sol(("to publickey address", "amount")).await.unwrap();

get wallet tokens

let result = wallet.get_tokens().await.unwrap();

get wallet transactions

let result = wallet.get_transactions().await.unwrap(); ```

marketplace

```bash use mirrorworldsdkrust::{marketplace::Marketplace, NetEnv}; use mirrorworldsdkrust::marketplace::GeneralPayload;

let KEY: &str = "your api key"; let TOKEN: &str = "your access token"; let SECRET_KEY: &str = "your secret key";

// init marketplace object, let market = Marketplace::new(KEY.tostring(), NetEnv::DEVNET, TOKEN.tostring(), SECRETKEY.tostring());

// create a collection let name: String = String::from("your collection name"); let symbol: String = String::from("your token symbol name"); let uri: String = String::from("you collection metadata uri") let response = market.createcollection(name, symbol, uri).await.unwrap(); if response.isnone() {
// your code } else { // your code }

// mint an nft let payload: GeneralPayload = GeneralPayload{ name: String::from("your nft name"), symbol: "your symbol".tostring(), url: "your nft metadta uri".tostring(), collectionmint: "your collection".tostring() }; let response = market.mint_nft(payload).await.unwrap();

// list an nft let mintaddress: String = String::from("your nft mint address"); let price: f64 = 0.5; // amount in SOL let auctionhouse: String = String::from(""); // your auction house address let response = market.listnft(mintaddress, price, auction_house).await.unwrap();

// buy an nft let mintaddress: String = String::from("your nft mint address"); let price: f64 = 0.5; // amount in SOL let response = market.buynft(mint_address, price).await.unwrap();

// update nft listing price let mintaddress: String = String::from("your nft mint address"); let price: f64 = 0.5; // amount in SOL let response = market.updatenftlisting(mintaddress, price).await.unwrap();

// cancel listing let mintaddress: String = String::from("your nft mint address"); let price: f64 = 0.5; // amount in SOL let response = market.cancelnftlisting(mintaddress, price).await.unwrap();

// transfer nft let mintaddress = String::from("your nft mint address"); let towalletaddress = String::from("to wallet address"); let response = market.transfernft(mintaddress, towallet_address).await.unwrap();

// fetch nfts by mint address let mut addresses = Vec::new(); addresses.push("nft mint address".tostring()); let limit: usize = 10; let offset: usize = 1; let response = market.fetchnftsbymint_address(addresses, limit, offset).await.unwrap();

// fetch nfts by creator address let mut addresses = Vec::new(); addresses.push("creator address".tostring()); let limit: usize = 10; let offset: usize = 1; let response = market.fetchnftsbycreator_address(addresses, limit, offset).await.unwrap();

// fetch nfts by update authorities let mut addresses = Vec::new(); addresses.push("update authorities address".tostring()); let limit: usize = 10; let offset: usize = 1; let response = market.fetchnftsbyupdate_authorities(addresses, limit, offset).await.unwrap();

// fetch nfts by owner address let mut addresses = Vec::new(); addresses.push("owner address".tostring()); let limit: usize = 10; let offset: usize = 1; let response = market.fetchnftsbyowner_addresses(addresses, limit, offset).await.unwrap();

// fetch nfts marketplace activity let address = String::from("nft mint address"); let response = market.fetchnftmarketplace_activity(address).await.unwrap(); ```