- Sui v0.21.0
Checkout our:
- Contract on the Sui Explorer
- Official Documentation
- Developer Documentation
A new approach to NFTs.
Origin-Byte is an ecosystem of tools, standards and smart contracts designed to make life easier for Web3 Game Developers and NFT creators. From simple artwork to complex gaming assets, we want to help you reach the public, and provide on-chain market infrastructure.
The ecosystem is partitioned into three critical components:
- The NFT standard, encompassing the core
Nft
,Collection
, andSafe
types, controlling the lifecycle and properties of each NFT. - Primary markets, encompassing
Marketplace
,Listing
, and numerous markets which control the initial minting of NFTs. - Secondary markets, encompassing principally the
Orderbook
which allows you to trade existing NFTs.
This codebase requires installation of the Sui CLI.
$ sui move build
to build the available move modules$ sui move test
to run the move tests./bin/publish.sh
to publish the modules on localnet or devnet
To deploy an NFT collection you will need to create a SUI Move contract, which plugs into our protocol.
We provide an example on how to build such collection in the examples folder. Additionally below follows an example of an NFT Collection, the SUIMARINES!
module gutenberg::suimarines {
use std::string::{Self, String};
use sui::url;
use sui::balance;
use sui::transfer;
use sui::tx_context::{Self, TxContext};
use nft_protocol::nft;
use nft_protocol::tags;
use nft_protocol::royalty;
use nft_protocol::display;
use nft_protocol::creators;
use nft_protocol::inventory::{Self, Inventory};
use nft_protocol::royalties::{Self, TradePayment};
use nft_protocol::collection::{Self, Collection, MintCap};
/// One time witness is only instantiated in the init method
struct SUIMARINES has drop {}
/// Can be used for authorization of other actions post-creation. It is
/// vital that this struct is not freely given to any contract, because it
/// serves as an auth token.
struct Witness has drop {}
fun init(witness: SUIMARINES, ctx: &mut TxContext) {
let (mint_cap, collection) = collection::create(
&witness, ctx,
);
collection::add_domain(
&mut collection,
&mut mint_cap,
creators::from_address(tx_context::sender(ctx))
);
// Register custom domains
display::add_collection_display_domain(
&mut collection,
&mut mint_cap,
string::utf8(b"Suimarines"),
string::utf8(b"A unique NFT collection of Suimarines on Sui"),
);
display::add_collection_url_domain(
&mut collection,
&mut mint_cap,
sui::url::new_unsafe_from_bytes(b"https://originbyte.io/"),
);
display::add_collection_symbol_domain(
&mut collection,
&mut mint_cap,
string::utf8(b"SUIM")
);
let royalty = royalty::new(ctx);
royalty::add_proportional_royalty(
&mut royalty,
nft_protocol::royalty_strategy_bps::new(100),
);
royalty::add_royalty_domain(&mut collection, &mut mint_cap, royalty);
let tags = tags::empty(ctx);
tags::add_tag(&mut tags, tags::art());
tags::add_collection_tag_domain(&mut collection, &mut mint_cap, tags);
transfer::transfer(mint_cap, tx_context::sender(ctx));
transfer::share_object(collection);
}
/// Calculates and transfers royalties to the `RoyaltyDomain`
public entry fun collect_royalty<FT>(
payment: &mut TradePayment<SUIMARINES, FT>,
collection: &mut Collection<SUIMARINES>,
ctx: &mut TxContext,
) {
let b = royalties::balance_mut(Witness {}, payment);
let domain = royalty::royalty_domain(collection);
let royalty_owed =
royalty::calculate_proportional_royalty(domain, balance::value(b));
royalty::collect_royalty(collection, b, royalty_owed);
royalties::transfer_remaining_to_beneficiary(Witness {}, payment, ctx);
}
public entry fun mint_nft(
name: String,
description: String,
url: vector<u8>,
attribute_keys: vector<String>,
attribute_values: vector<String>,
_mint_cap: &MintCap<SUIMARINES>,
inventory: &mut Inventory,
ctx: &mut TxContext,
) {
let nft = nft::new<SUIMARINES, Witness>(
&Witness {}, tx_context::sender(ctx), ctx
);
display::add_display_domain(
&mut nft,
name,
description,
ctx,
);
display::add_url_domain(
&mut nft,
url::new_unsafe_from_bytes(url),
ctx,
);
display::add_attributes_domain_from_vec(
&mut nft,
attribute_keys,
attribute_values,
ctx,
);
inventory::deposit_nft(inventory, nft);
}
}
and in your Move.toml
, define the following dependency:
[dependencies.NftProtocol]
git = "https://github.com/Origin-Byte/nft-protocol.git"
# v0.16.0
rev = "484ffaca16d561d8123c14138770fa99fe5591af"