16 Sep 2024

feedStories by BitTorrent Inc. on Medium

BTFS Protocol V3.1.0 Beta Is Now Live!

This update improves the security of the protocol, and the specifics are as follows:

1. Added password verification to Dashboard: This provides users with a higher level of protection, enhancing the security of data access.

2. Eliminated deprecated and seldom-used functionalities: This streamlines user experience and boosts system performance.

We stay dedicated to continuously refining the BTFS protocol with the aim of fostering the growth of decentralized networks. If you have any questions or suggestions, feel free to contact us at any time.

Resources for BTFS V3.1.0 Beta:

● Release notes for BTFS V3.1.0 Beta:https://github.com/bittorrent/go-btfs/tree/release_3.1.0

● BTFS Dashboard repo: https://github.com/bittorrent/btfs-dashboard

● BTFS official website: https://www.btfs.io

● BTFS SCAN: https://scan.btfs.io

● BTFS documentation: https://docs.btfs.io/docs

Find us on

Have any questions or want to engage with fellow BTFS users? Connect with us and be part of the community:

● Discord: https://discord.gg/tJ4fz6C6rw

● Medium: https://medium.com/@BitTorrent

● X (formerly Twitter): https://twitter.com/BitTorrent

About BTFS

The BitTorrent File System (BTFS) is both a protocol and a web application that provides a content-addressable peer-to-peer mechanism for storing and sharing digital content in a decentralized file system, as well as a base platform for decentralized applications (Dapp). The BTFS team has been working on the latest network operations and BTT market sentiment, etc., to make a series of dynamic adjustments such as upload prices and airdrop reward schemes.

16 Sep 2024 3:38am GMT

11 Sep 2024

feedStories by BitTorrent Inc. on Medium

Revolutionizing Digital Asset Trading: The Ultimate NFT Marketplace on BTTC

Welcome to the future of digital asset trading! Today, we are diving into the intricacies of a decentralized NFT marketplace built on the BitTorrent Chain (BTTC). This marketplace is designed to facilitate the trading of Non-Fungible Tokens (NFTs), integrating auction mechanisms, transaction fees, and robust security features. Whether you're a creator, collector, or trader, this contract provides a secure and transparent environment for all your NFT transactions.

The MarketPlace Contract: Your Gateway to Decentralized NFT Trading

The MarketPlace contract is a comprehensive solution for managing NFT transactions. It supports the creation and management of sell orders, bidding on NFTs, and the execution of trades. Let's break down the key components and functionalities of this contract.

State Variables and Structs

The contract defines several state variables and data structures to manage orders, bids, and administrative settings:

using SafeERC20 for IERC20;
uint256 private _orderIds;
uint256 private _bidIds;

address public _adminAddress = "<VAULT ADDRESS For Commission>";

// To store commission percentage for each mint
uint8 private _adminCommissionPercentage = 25;

// Mapping from token to the current ask for the token
mapping(uint256 => IUtils.Order) private _orders;

// Mapping from token to the current ask for the token
mapping(uint256 => IUtils.Bid) private _bids;

mapping(address => bool) public approvedCurrency;

mapping(address => bool) public approvedNfts;

uint256 private constant EXPO = 1e18;
uint256 private constant BASE = 1000 * EXPO;

Key Functions

Administrative Functions

These functions allow the admin to manage various aspects of the marketplace:

function setAdminAddress(address _newAdminWallet) external override returns (bool) {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Caller is not a admin");
require(_newAdminWallet != address(0), "Admin Wallet cannot be empty address");
emit UpdateAdminWallet(_adminAddress, _newAdminWallet);
_adminAddress = _newAdminWallet;
return true;
}
function setCommissionPercentage(uint8 _commissionPercentage) external override returns (bool) {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Caller is not a admin");
_adminCommissionPercentage = _commissionPercentage;
emit CommissionUpdated(_adminCommissionPercentage);
return true;
}
function updateCurrency(address _tokenAddress, bool _status) external override returns (bool) {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Caller is not a admin");
approvedCurrency[_tokenAddress] = _status;
return true;
}
function updateNFTContract(address _tokenAddress, bool _status) external override returns (bool) {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Caller is not a admin");
approvedNfts[_tokenAddress] = _status;
return true;
}

Order Management Functions

These functions handle the creation, management, and execution of orders:

function setOrder(address _nftContract, uint256 _tokenId, address _currency, uint256 _askAmount, uint256 _expiryTime)
whenNotPaused
external
override
{
_orderIds += 1;

require(approvedNfts[_nftContract], "NFT is not approved by admin");
require(approvedCurrency[_currency], "Currency is not approved by admin");
require(_askAmount > 0, "Ask Amount Cannot be Zero");
require(_expiryTime > block.timestamp, "Expiry Time cannot be in Past");
ERC721 nftContract = ERC721(_nftContract);
require(nftContract.ownerOf(_tokenId) == msg.sender, "You are not owner of Token Id");
bool isAllTokenApproved = nftContract.isApprovedForAll(_msgSender(), address(this));
address approvedSpenderOfToken = nftContract.getApproved(_tokenId);
require((isAllTokenApproved || approvedSpenderOfToken == address(this)), "Market Contract is not allowed to manage this Token ID");

uint256 currentOrderId = _orderIds;
IUtils.Order storage order = _orders[currentOrderId];

order.orderId = currentOrderId;
order.sender = _msgSender();
order.askAmount = _askAmount;
order.currency = _currency;
order.nftContract = _nftContract;
order.tokenId = _tokenId;
order.expiryTime = _expiryTime;
order.orderStatus = IUtils.OrderStatus.OPEN;
order.createdAt = block.timestamp;
order.updatedAt = block.timestamp;

emit OrderCreated(currentOrderId, order);
}
function getOrder(uint256 _orderId) external override view returns (IUtils.Order memory) {
return _orders[_orderId];
}
Cancel Order: Allows the order creator or an admin to cancel an open order.
function cancelOrder(uint256 _orderId) whenNotPaused external override returns (bool) {
IUtils.Order storage order = _orders[_orderId];

require(order.sender != address(0), "Invalid Order Id");
require(order.orderStatus == IUtils.OrderStatus.OPEN, "Order status is not Open");
bool hasAdminRole = hasRole(DEFAULT_ADMIN_ROLE, _msgSender());
require(order.sender == _msgSender() || hasAdminRole, "You Don't have right to cancel order");

order.orderStatus = IUtils.OrderStatus.CANCELED;
emit OrderRemoved(_orderId, order);
return true;
}
function completeOrder(uint256 _orderId) whenNotPaused external override returns (bool) {
IUtils.Order storage order = _orders[_orderId];

require(order.sender != address(0), "Invalid Order Id");
require(order.orderStatus == IUtils.OrderStatus.OPEN, "Order status is not Open");
IERC20 token = IERC20(order.currency);
ERC721 nft = ERC721(order.nftContract);
require(block.timestamp <= order.expiryTime, "Order is expired");
require(token.balanceOf(_msgSender()) >= order.askAmount, "Not enough funds available to buy");
require(token.allowance(_msgSender(), address(this)) >= order.askAmount, "Please Approve Tokens Before You Buy");

uint256 _amountToDistribute = order.askAmount;
uint256 adminCommission = (_amountToDistribute * (_adminCommissionPercentage * EXPO)) / (BASE);
uint256 _amount = _amountToDistribute - adminCommission;

token.safeTransferFrom(_msgSender(), _adminAddress, adminCommission);
token.safeTransferFrom(_msgSender(), order.sender, _amount);
nft.transferFrom(order.sender, _msgSender(), order.tokenId);

order.orderStatus = IUtils.OrderStatus.COMPLETED;
order.recipient = _msgSender();
emit OrderCompleted(order.orderId, order);
return true;
}

Bid Management Functions

These functions handle the creation, management, and execution of bids:

function addBid(address _nftContract, uint256 _tokenId, address _currency, uint256 _bidAmount, uint256 _expiryTime)
whenNotPaused
external
override
{
_bidIds += 1;

require(approvedNfts[_nftContract], "NFT is not approved by admin");
require(approvedCurrency[_currency], "Currency is not approved by admin");
require(_bidAmount > 0, "Bid Amount Cannot be Zero");
require(_expiryTime > block.timestamp, "Expiry Time cannot be in Past");

ERC721 nft = ERC721(_nftContract);
require(nft.ownerOf(_tokenId) != msg.sender, "You Can't Bid on your Own Token");

IERC20 token = IERC20(_currency);
require(token.balanceOf(_msgSender()) >= _bidAmount, "Not enough funds available to add bid");
require(token.allowance(_msgSender(), address(this)) >= _bidAmount, "Please Approve Tokens Before You Bid");

uint256 currentBidId = _bidIds;
IUtils.Bid storage bid = _bids[currentBidId];

bid.bidId = currentBidId;
bid.sender = _msgSender();
bid.bidAmount = _bidAmount;
bid.currency = _currency;
bid.nftContract = _nftContract;
bid.tokenId = _tokenId;
bid.expiryTime = _expiryTime;
bid.bidStatus = IUtils.OrderStatus.OPEN;
bid.createdAt = block.timestamp;
bid.updatedAt = block.timestamp;

emit BidAdded(currentBidId, bid);
}
function cancelBid(uint256 _bidId) whenNotPaused external override returns (bool) {
IUtils.Bid storage bid = _bids[_bidId];

require(bid.sender != address(0), "Invalid Bid Id");
require(bid.bidStatus == IUtils.OrderStatus.OPEN, "Bid status is not Open");
bool hasAdminRole = hasRole(DEFAULT_ADMIN_ROLE, _msgSender());

ERC721 nft = ERC721(bid.nftContract);
require(bid.sender == _msgSender() || nft.ownerOf(bid.tokenId) == _msgSender() || hasAdminRole, "You Don't have right to cancel bid");

bid.bidStatus = IUtils.OrderStatus.CANCELED;
emit BidRemoved(_bidId, bid);
return true;
}
function acceptBid(uint256 _bidId) whenNotPaused external override returns (bool) {
IUtils.Bid storage bid = _bids[_bidId];

require(bid.sender != address(0), "Invalid Bid Id");
require(bid.bidStatus == IUtils.OrderStatus.OPEN, "Bid status is not Open");
require(block.timestamp <= bid.expiryTime, "Bid is expired");

IERC20 token = IERC20(bid.currency);
ERC721 nft = ERC721(bid.nftContract);
require(nft.ownerOf(bid.tokenId) == msg.sender, "You are not owner of Token Id");

require(token.balanceOf(bid.sender) >= bid.bidAmount, "Bidder doesn't have Enough Funds");
require(token.allowance(bid.sender, address(this)) >= bid.bidAmount, "Bidder has not Approved Tokens");

bool isAllTokenApproved = nft.isApprovedForAll(_msgSender(), address(this));
address approvedSpenderOfToken = nft.getApproved(bid.tokenId);
require((isAllTokenApproved || approvedSpenderOfToken == address(this)), "Market Contract is not allowed to manage this Token ID");

uint256 _amountToDistribute = bid.bidAmount;
uint256 adminCommission = (_amountToDistribute * (_adminCommissionPercentage * EXPO)) / (BASE);
uint256 _amount = _amountToDistribute - adminCommission;

nft.transferFrom(_msgSender(), bid.sender, bid.tokenId);
token.safeTransferFrom(bid.sender, _adminAddress, adminCommission);
token.safeTransferFrom(bid.sender, _msgSender(), _amount);

bid.bidStatus = IUtils.OrderStatus.COMPLETED;
bid.recipient = _msgSender();
emit BidAccepted(bid.bidId, bid);
return true;
}

Conclusion

The MarketPlace contract is a comprehensive solution for managing NFT transactions. By leveraging the power of smart contracts, it ensures transparency, security, and efficiency in the trading process. Whether you're minting new NFTs, bidding on unique digital assets, or managing a marketplace, this contract provides the tools you need to succeed in the dynamic world of blockchain-based digital assets.

Github URL:
https://github.com/adeelch9/bttc-examples/tree/master/projects/nft-marketplace

Bonus Section: Diving Deeper into BTTC Smart Contracts

We've only scratched the surface of what's possible with smart contracts on the BitTorrent Chain. For those eager to take their blockchain development skills to the next level, we've got a treasure trove of resources waiting for you in our GitHub repository!

🚀 Explore the Full Project

Head over to our BTTC Examples GitHub Repository to discover a wealth of additional content and features:

  1. Complete Contract Code: While we've covered the main functions, the repository contains the full smart contract code, including any methods we didn't have space to discuss here.
  2. Deployment Scripts: Ever wondered how to deploy your smart contracts to the BTTC network? We've got you covered with ready-to-use deployment scripts that make the process a breeze.
  3. Comprehensive Tests: Writing tests for smart contracts is crucial for ensuring their reliability and security. Our repository includes a suite of tests that demonstrate best practices in smart contract testing.
  4. Multiple Projects: Beyond the contract we've discussed today, you'll find a variety of other smart contract examples, from simple to advanced, showcasing different aspects of blockchain development on BTTC.
  5. Documentation: Detailed README files and inline comments provide additional context and explanations, making it easier to understand and modify the code for your own projects.

🛠️ Getting Started

To make the most of these resources:

  1. Clone the repository: git clone https://github.com/adeelch9/bttc-examples.git
  2. Navigate to the project directory of your choice
  3. Follow the setup instructions in the project's README
  4. Experiment with the contracts, run tests, and try deploying to a testnet

🌟 Why This Matters

By exploring the full repository, you'll gain:

- A deeper understanding of smart contract development

- Hands-on experience with deployment and testing

- Exposure to best practices in blockchain development

- Inspiration for your own BTTC projects

Whether you're a beginner looking to learn or an experienced developer seeking to refine your skills, our BTTC Examples repository is your gateway to mastering smart contract development on the BitTorrent Chain.

Happy trading, and may your NFTs find their perfect homes!

11 Sep 2024 5:21am GMT

10 Sep 2024

feedStories by BitTorrent Inc. on Medium

BitTorrent Weekly Report | 09.02–09.08

Founded with a leading peer-to-peer sharing technology standard in 2004, BitTorrent, Inc. is a consumer software company based in San Francisco. Its protocol is the largest decentralized P2P network in the world, driving 22% of upstream and 3% of downstream traffic globally.

Its flagship desktop and mobile products, BitTorrent and µTorrent, enable users to send large files over the internet, connecting legitimate third-party content providers with users. With over 100 million active users, BitTorrent products have been installed on over 1 billion devices in over 138 countries worldwide.

Since November 2018, TRON (TRX), Binance (BNB), and Bitcoin (BTC) holders have the opportunity to purchase one-year subscriptions of BitTorrent or µTorrent products, including Ads Free and Pro for Windows. Pro includes anti-virus and anti-malware screening, file converting and playability in HD. Users can visit bittorrent.com or utorrent.com to learn more.

10 Sep 2024 7:04am GMT