Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ Assign a smart contract to an existing SFS NFT with Thirdweb deployment

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Assign a smart contract to an existing SFS NFT with Thirdweb deployment


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

Thirdweb is a web3 platform that provides developers with tools to build, deploy, launch, and manage their applications and games. Some of these tools include pre-built smart contracts, SDKs, and APIs.

In this tutorial, youโ€™ll learn how to assign a smart contract to Mode Networkโ€™s SFS (Sequencer Fee Sharing) Contract by deploying with thirdweb.

Prerequisites

Before you continue with this tutorial you should:

  1. Aย  Metamask Account.

  2. Latest version of Node and Yarn

  3. A thirdweb account.

  4. Basic understanding of Solidity.

  5. Bridge Sepolia Eth with Mode Network.

  6. An SFS NFT token Id.

Sequencer Fee Sharing (SFS) on Mode Network

Sequencer Fee Sharing (SFS) stands out as a pivotal feature within the Mode network, empowering developers to earn a percentage of transaction fees originating from their smart contracts' activities. This section guides you through the process of leveraging SFS for your smart contract within the Mode ecosystem.

Registration and ERC 721 NFT

To kickstart the fee-sharing mechanism, your smart contract needs to be registered with Mode's SFS contract. This registration is the gateway to unlocking the benefits of fee-sharing. Upon successful registration, you'll receive an ERC 721 Non-Fungible Token (NFT). This unique token serves as your exclusive claim to transaction fees generated by your contract.

Transferable and Multipurpose SFS NFT

The SFS NFT isn't limited to a single smart contract. It's both transferable and versatile, allowing you to utilize it across multiple contracts or share it between existing contracts. Whether you deploy new smart contracts on Mode or manage multiple contracts under a single SFS NFT, this flexibility caters to your specific needs.

Fee Processing and Accumulation Period

As your smart contract operates within the Mode network, an off-chain component takes charge of processing transactions and calculating your share of fees. It's important to be aware of a two-week accumulation period during which fees accrue before being transferred to the SFS contract.

Claiming Rewards

Once the fees are successfully transferred to the SFS contract, you can easily claim your accumulated rewards. This process not only acknowledges your contribution to the network but also aligns with Mode's commitment to incentivizing innovation and utilization of smart contracts within the ecosystem.

Explore the SFS Contract Code

For a deeper understanding and exploration of the SFS contract code, please refer to the [complete SFS contract code here](link-to-SFS-contract-code). Sequencer Fee Sharing is designed to streamline and enhance your experience as a developer on Mode Network, ensuring that you're duly rewarded for your contributions.

Assigning smart contract to an existing SFS NFT

Letโ€™s take a look at the assign function in the SFS contract to understand how the assignment works.

Note that this is only a portion of the SFS contract, check here to see the complete code.

function assign(uint256 _tokenId) public onlyUnregistered returns (uint256) {

ย ย ย ย ย ย ย address smartContract = msg.sender;

ย ย ย ย ย ย ย if (!_exists(_tokenId)) revert InvalidTokenId();

ย ย ย ย ย ย ย emit Assign(smartContract, _tokenId);

ย ย ย ย ย ย ย feeRecipient[smartContract] = NftData({

ย ย ย ย ย ย ย ย ย ย ย tokenId: _tokenId,

ย ย ย ย ย ย ย ย ย ย ย registered: true,

ย ย ย ย ย ย ย ย ย ย ย balanceUpdatedBlock: block.number

ย ย ย ย ย ย ย });

ย ย ย ย ย ย ย return _tokenId;

ย ย ย }

This function takes _tokenId as an input parameter. Subsequently, it verifies the validity of the tokenId before emitting an Assign event. Following this event, the msg.sender (our smart contract) gets associated with the tokenId in the SFS. It updates the feeRecipient mapping with relevant information.

Here are a few points to keep in mind:

  • The assign function is declared as public, allowing an external smart contract to invoke it.

  • The assumption is that msg.sender represents a smart contract address, as this function is intended to be called by a smart contract.

  • The assign function does not generate an ownership NFT; instead, it links your smart contract to an existing SFS NFT.

  • The process of assigning a smart contract to an SFS NFT is a one-time operation.

Now that we comprehend the workings of the assign function, let's proceed to set up our project and construct our smart contract.

Setting Up Our Project

To set up our project, we need to set up a few things.

1. Download the ThirdWeb CLI

To install thirdweb globally, open your terminal and run

npm i -g thirdweb

Now try running:

thirdweb --version

If the CLI is installed correctly you will be prompted to go to the installed version

2. Create a Local environment

Create a new project by running

npx thirdweb create contract

You will be prompted with a menu with different options for setting up your project. We will select โ€˜Empty Contractโ€™ and write our Smart Contract Code from scratch.

Once thirdweb is done building our project, weโ€™ll run

cd project-name && code .

To open with vscode.

3. Writing Our Smart Contract

Navigate to the "contracts" directory within your project. Specifically for this tutorial, we will be working with a straightforward Hello World Contract.

First, we added the SFS contract to our file with a register function. Then in the constructor, we invoked the assign function by initializing a new instance of our SFS contract and calling the assign method on it.

Weโ€™ll create a new file and call it: Contract.sol

And paste the below code into it.

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

//Here we created our SFS contract

contract SFS {
ย ย ย function assign(uint256 _tokenId) public returns (uint256) {}
}

contract HelloWorld {
ย ย ย string public greeting;
ย ย ย constructor() {
ย ย ย ย ย ย ย greeting = "Hello, World!";
ย ย ย ย ย ย ย SFS sfsContract = SFS(0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6);
ย ย ย ย ย ย ย sfsContract.assign(45);
ย ย ย }

ย ย ย function getGreeting() public view returns (string memory) {
ย ย ย ย ย ย ย return greeting;
ย ย ย }

ย ย ย function setGreeting(string memory newGreeting) public {
ย ย ย ย ย ย ย greeting = newGreeting;

ย ย ย }
}

Remember to change the ID (45) inside of sfsContract.assign(45) to the ID of your NFT. Save your file.

NOTE:

Mode SFS contact has a different address for Mainnet and Testnet and for this tutorial, weโ€™re deploying to Testnet so weโ€™re going to register to the Testnet's SFS contract.

Mainnet SFS Address: 0x8680CEaBcb9b56913c519c069Add6Bc3494B7020

Testnet SFS Address: 0xBBd707815a7F7eb6897C7686274AFabd7B579Ff6

Thirdweb requires an API key to monitor your smart contracts, check out this tutorial on creating a Thirdweb API Key to get it done.

Deploying Our Contract to Thirdweb

STEP 1

Navigate to the project root and run either of the following commands:

yarn deploy

or

npx thirdweb deploy

You will then be directed to your thirdweb dashboard.

Select Mode Testnet as the network of your choice.

STEP 2

Choose Mode Testnet as the network, click on deploy, confirm and then sign the transaction from Metamask to complete it.

If successful, you'll see a "Success" message.

Congratulations! You've deployed and assigned your contract to an existing NFT with Thirdweb. Feel free to explore your dashboard for code details, contract events, and more.

...



๐Ÿ“Œ Assign a smart contract to an existing SFS NFT with Thirdweb deployment


๐Ÿ“ˆ 140.06 Punkte

๐Ÿ“Œ How to Register a Smart Contract to Mode SFS with Thirdweb


๐Ÿ“ˆ 77.45 Punkte

๐Ÿ“Œ How to Register a Smart Contract to Mode SFS with Hardhat.


๐Ÿ“ˆ 45.55 Punkte

๐Ÿ“Œ How To Register a Smart Contract to the SFS with Foundry


๐Ÿ“ˆ 45.55 Punkte

๐Ÿ“Œ CVE-2023-1563 | SourceCodester Student Study Center Desk Management System 1.0 /admin/assign/assign.php id sql injection


๐Ÿ“ˆ 43.42 Punkte

๐Ÿ“Œ CVE-2023-1567 | SourceCodester Student Study Center Desk Management System 1.0 /admin/assign/assign.php sid cross site scripting


๐Ÿ“ˆ 43.42 Punkte

๐Ÿ“Œ I Built A Web3 Clone Of The Hill Climb Game Using Unity, ThirdWeb GamingKit, and ContractKit.


๐Ÿ“ˆ 31.9 Punkte

๐Ÿ“Œ Challenges and Solutions in Using ThirdWeb


๐Ÿ“ˆ 31.9 Punkte

๐Ÿ“Œ Secure your blockchain smart contract via smart contract auditing


๐Ÿ“ˆ 31.2 Punkte

๐Ÿ“Œ Was bedeutet "SFS"? Bedeutung und Verwendung


๐Ÿ“ˆ 29.95 Punkte

๐Ÿ“Œ SFS: Die Bedeutung des Social Media Begriffs erklรคrt


๐Ÿ“ˆ 29.95 Punkte

๐Ÿ“Œ How to write NFT smart contract in 2023


๐Ÿ“ˆ 29.41 Punkte

๐Ÿ“Œ ACCESSING NFT SMART CONTRACT CODE


๐Ÿ“ˆ 29.41 Punkte

๐Ÿ“Œ Get your business on board the NFT fast train with Tatumโ€™s NFT Express


๐Ÿ“ˆ 27.62 Punkte

๐Ÿ“Œ Why decentralized storage matters for NFT metadata and your next NFT collection


๐Ÿ“ˆ 27.62 Punkte

๐Ÿ“Œ Easily Create An NFT App Using The New Infura NFT SDK TypeScript


๐Ÿ“ˆ 27.62 Punkte

๐Ÿ“Œ Krypto-Hit: Elon Musk macht sich mit NFT-Song รผber NFT lustig


๐Ÿ“ˆ 27.62 Punkte

๐Ÿ“Œ Crooks stole $375k from Premint NFT, it is one of the biggest NFT hacks ever


๐Ÿ“ˆ 27.62 Punkte

๐Ÿ“Œ NFT-Holders only: Das ist die Idee hinter einem NFT-Restaurant in Florida


๐Ÿ“ˆ 27.62 Punkte

๐Ÿ“Œ Mastercard: Ex-NFT-Projektleiter verkauft NFT seiner Kรผndigung


๐Ÿ“ˆ 27.62 Punkte

๐Ÿ“Œ NFT 101: What Is NFT Perps Trading?


๐Ÿ“ˆ 27.62 Punkte

๐Ÿ“Œ Web3 backend and smart contract development for Python developers Musical NFTs part 17: Deployment time!


๐Ÿ“ˆ 27.44 Punkte

๐Ÿ“Œ IDEMIA and INTERPOL renew existing contract to deliver fingerprint and facial recognition system


๐Ÿ“ˆ 25.71 Punkte

๐Ÿ“Œ CVE-2022-35621 | Evoh NFT EvohClaimable Contract Transfer access control


๐Ÿ“ˆ 24.27 Punkte

๐Ÿ“Œ Cross-Contract Ricochet Attacks & Off-Chain-On-Chain Manipulation of Billion Dollar NFT Collections


๐Ÿ“ˆ 24.27 Punkte

๐Ÿ“Œ Create Deployment Using โ€œkubectl create deploymentโ€


๐Ÿ“ˆ 23.67 Punkte

๐Ÿ“Œ Virginia 'Broadband Deployment Act' Would Kill Municipal Broadband Deployment


๐Ÿ“ˆ 23.67 Punkte

๐Ÿ“Œ Virginia 'Broadband Deployment Act' Would Kill Municipal Broadband Deployment


๐Ÿ“ˆ 23.67 Punkte

๐Ÿ“Œ Why Should I Assign Subscriptions


๐Ÿ“ˆ 21.71 Punkte

๐Ÿ“Œ Kingsoft WPS Office 10.1.0.7106/10.2.0.5978 kso.dll WStr::assign denial of service


๐Ÿ“ˆ 21.71 Punkte

๐Ÿ“Œ New US Bill Wants to Assign State Cybersecurity Coordinators


๐Ÿ“ˆ 21.71 Punkte

๐Ÿ“Œ assign-deep up to 0.4.6 on Node.js Object privilege escalation


๐Ÿ“ˆ 21.71 Punkte

๐Ÿ“Œ Choosing which subscription ID to assign


๐Ÿ“ˆ 21.71 Punkte

๐Ÿ“Œ Choosing which subscription ID to assign


๐Ÿ“ˆ 21.71 Punkte











matomo