calendar_today
July 26, 2024
July 26, 2024
|
schedule
4
min read
Our first dApp on Sui
AppChains
Backend
Blockchain Infrastructure
Blockchain Integration
Frontend
Infrastructure
Smart Contracts

Transitioning from developing on MultiversX to Sui was a challenge that exceeded our expectations. Despite our experience with EVM and Solana, Sui’s unique Object Model presented new hurdles. Unlike MultiversX, Solana, or Ethereum Virtual Machine-based chains, Sui’s model treats everything as transferable objects, including your SUI balance, which is an Object of type Coin.

For those interested in the full, detailed version of our journey, you can find it on our Medium page.

To build our dApp on Sui, we first had to understand the Sui blockchain and then develop smart contracts and the frontend dApp. Our goal was to leverage Sui’s distinct features to create an efficient and user-friendly NFT marketplace. This project was not just about creating a functional dApp but also about expanding our knowledge and skills.

Particularities, Move, Documentation, Problems & Tools

Sui’s novel approach treats everything as objects that can be transferred or modified, making token ownership native. This differs significantly from Ethereum Virtual Machine-based chains, where each token is tracked by a different smart contract. Sui’s object-based model enables parallel transaction processing without consensus, enhancing performance. However, shared objects act like a global state requiring consensus, leading to higher gas costs and slower latency.

Move

Move, the language used for writing smart contracts on Sui, is similar to Rust and employs an Ownership model where variables are “consumed” when calling other functions unless references are used. The documentation provides a comprehensive guide on writing Move packages, including tests and publishing, although advanced information can be hard to find.

Documentation

While Sui’s documentation explains core concepts and provides examples, it lacks structure, making it challenging to find advanced information. For instance, the concept of storing state for a module using a shared object is not clearly explained. We used a shared object of a type Marketplace to store our contract information, but the differences between public and address-owned objects, and when to use them, were not clear.

Problems to Overcome

To develop our NFT marketplace, we needed a way to store all the listings for easy access and deletion later. Sui’s collection types were insufficient for our needs, prompting us to implement custom logic. In the end, we used Sui’s Dynamic Object Fields and Table structures to store data efficiently without affecting gas costs.

Step-by-Step Implementation of Our NFT Marketplace on Sui

The smart contract was deployed on testnet, and the following features were implemented in the dApp:

1. Displaying all listed NFTs: We retrieved the contents of the marketplace object using JSON-RPC calls.

2. NFT listing: We gathered user inputs like price and marketplace object ID to create listings.

3. Listed NFT details: We provided a detailed view of each NFT, allowing users to buy, bid, or cancel listings.

4. Buying a listed NFT: This involved transferring the NFT to the buyer upon purchase.

5. Canceling a listed NFT: Only the owner of the listing could cancel it.

6. Bidding on an NFT: Users could place bids, which were recorded in the marketplace.

7. Displaying all bids: We displayed all bids for a specific NFT on its details page.

8. Canceling a bid: Only the bid owner could cancel their bid.

9. Accepting a bid: The NFT owner could accept bids, transferring the NFT to the highest bidder.

Additional Thoughts

Developing on Sui has been an enlightening experience. Sui’s object-centric model offers new ways to manage data in dApps, enhancing performance. The built-in standards like the Coin standard provided a solid framework, and despite some initial challenges with documentation, we successfully built a functional NFT marketplace.

Conclusion

Our journey with Sui wasn’t without challenges, but it was definitely rewarding. Moving from platforms to Sui meant we had to rethink our approach and learn new concepts. But this effort paid off — we’ve successfully built a functional NFT marketplace and learned a lot along the way.

Looking ahead, we’re committed to exploring new possibilities and pushing the boundaries of what’s achievable with Sui. This journey is just beginning, and we can’t wait to see where it leads us.

Full source code can be found here: GitHub

DEMO dApp: Sui Demo

Placeholder

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.