bash
git clone git@github.com:mirrorworld-universe/mirrorworld-sdk-rust.git
cd mirrorworld-sdk-rust
bash
cargo run
bash
cargo test
```bash
[dependencies] mirrorworld-sdk-rust = "0.1.0" ```
```bash use mirrorworldsdkrust::{ fetchuser, getnftdetails, gettoken, gettransactions, login, completesignup, signupemail, }; use mirrorworldsdkrust::{ setconfig, set_apikey, };
set_apikey("your apikey");
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!() };
signupemail("liuyangchina@126.com");
set_config( "your token", "your apikey" );
fetch_user();
get_token();
get_transactions();
getnftdetails("nft address");
transfer_spltoken(( "sol address", amount "sol address", amount ));
transfer_sol(( "sol address", amount )); ```
```bash use mirrorworldsdkrust::{marketplace::Marketplace, NetEnv}; use mirrorworldsdkrust::marketplace::GeneralPayload;
let KEY: &str = "your api key"; let TOKEN: &str = "your access token";
// init marketplace object, let market = Marketplace::new(KEY.tostring(), NetEnv::DEVNET, TOKEN.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
}
// create a sub collection let name: String = String::from("your sub collection"); let symbol: String = String::from("you sub collection token symbol"); let uri: String = String::from("your sub collection metadata uri"); let parentcollection: String = String::from("your parent collection"); // you can got this from the above api let response = market.createsubcollection(name, symbol, uri, parentcollection).await.unwrap();
// 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(); ```