ERC721SmartToken — ERC721 Token with ERC20 Adapter (2024)

ERC721SmartToken — ERC721 Token with ERC20 Adapter (3)

ERC721SmartToken contract implements non-fungible tokens based on ERC721 standard that also supports ERC20interface. The main idea is to create a token that can be both non-fungible and has transferable value.

Inside ERC721 contract each not fungible token represented as a NFT structure where there is a member element called value.

struct NFT {
uint256 value; // NFT value
string metadata; // ... metadata: IPFS path
uint256 kind; // ... type
uint256 level; // ... activities level
uint256 state; // ... state
}

This element holds ERC20 token inside ERC721 token.

To work with ERC721 token as normal ERC20 token we need to create a ERC20Adapter that implements standard ERC20 methods, as for example balanceOf method.

function balanceOf(address _owner) public view returns (uint256)

But in our case due to ERC721 structure for each _owner there can be many non-fungible tokens belong to this particular address. To select particular token for ERC20 compatible operations like transfer token value to another address we need to implement new methods that will accept address and token ID as parameters.

function approveFrom(uint256 _fromId, address _spender, uint256 _toId, uint256 _value) public returns (bool success)

This method calls ERC20Controller method implemented by ERC721SmartToken contract that will use the following mappings to store information abount NFT tokens:

mapping (address => mapping (address => uint256)) public allowanceIds; // transfer allowance
mapping (address => mapping (address => uint256)) public allowanceAmt; // transfer allowance

Now we can use ERC20 standard methods transfer and transferFrom to transfer values between two NFT tokens.

ERC20Controller implements defaultId methods that provides a default NFT id for the _owner address.

function defaultId(address _owner) internal returns (uint256 id);

So, we can use ERC20 standard method approve to approve transfer between two NFT default tokens for msg.senderand _spender.

REGA Risk Sharing GitHub

Get Best Software Deals Directly In Your Inbox

ERC721SmartToken — ERC721 Token with ERC20 Adapter (4)
ERC721SmartToken — ERC721 Token with ERC20 Adapter (2024)

FAQs

What is the difference between ERC20 and ERC-721 tokens? ›

The key difference between ERC20 and ERC721 tokens lies in their fungibility. ERC20 tokens are fungible and represent a uniform asset, while ERC721 tokens are non-fungible and symbolize a set of unique assets.

How to create ERC-721 token? ›

4 Steps to Create an ERC721 Token on Kaleido
  1. Step 1: Create a Kaleido Account. If you haven't already, sign up for a Kaleido account here. ...
  2. Step 2: Create a Blockchain Network. To get started, create a blockchain network. ...
  3. Step 3: Create a Token Pool. ...
  4. Step 4: Create Your Token. ...
  5. Step 5: Transfer Your NFT to Metamask.
Feb 13, 2024

What is the difference between ERC-721 and ERC-1155? ›

ERC-721 is popular for creating NFTs, enabling the representation of unique digital assets such as artwork, collectibles, and in-game items. ERC-1155 provides flexibility by supporting multiple token types in a single contract, making it suitable for complex token ecosystems like gaming platforms.

What is the difference between ERC20 and ERC1155? ›

ERC1155 was created in 2018 to allow for both fungible and non-fungible tokens to exist on a single contract. ERC20 tokens are fungible, which means each token is identical and interchangeable. Examples include cryptocurrencies like DAI and USDC. ERC721 tokens are non-fungible, meaning each token is unique.

Does each ERC-721 token have its own address? ›

ERC-721 Functions​

ownerOf: This function returns the address of the owner of a specific token. Each ERC721 token is unique, represented by an ID. This function allows users or applications to determine the owner of the token based on its unique ID.

How do I know if my token is ERC20? ›

You can use a tool or library to call these functions on the target address. Evaluating Return Values: If the function calls succeed and return valid values (e.g., a non-zero balance or a total token supply), it's a strong indication that you're dealing with an ERC20 token contract.

Is ERC-721 free? ›

ERC-721 is a free, open standard that describes how to build non-fungible or unique tokens on the Ethereum blockchain. While most tokens are fungible (every token is the same as every other token), ERC-721 tokens are all unique.

How much does it cost to create an ERC token? ›

On average, the cost to create ERC20 token lies between $5000 to $10,000, depending on the type of token developed and business requirements.

What is ERC721 token example? ›

One of the examples that use the ERC-721 non-fungible tokens standard is the Cryptokitties game which is basically a game developed on the blockchain which allows users to sell, buy and breed virtual cats. Some other examples include Ethermon, MyCrypto, Cryptodoggies, etc.

What are the disadvantages of ERC-721? ›

Cons of ERC-721 Tokens
  • Limited Fungibility. The lack of fungibility can make ERC-721 tokens less suitable for certain financial transactions.
  • Scalability. High gas fees and network congestion can limit the efficiency of ERC-721 transactions.
  • Counterfeiting Concerns. Ensuring the authenticity of NFTs is a challenge.
Apr 2, 2024

Why use ERC-721? ›

ERC-721 tokens provide a secure and transparent way to prove ownership of unique assets. Their flexibility allows creators to add extra features. They work seamlessly on various platforms, ensuring transparent and protected digital ownership, and this sets the stage for innovative applications.

Can ERC-721 be fractionalized? ›

By definition, an ERC721 cannot be replicated as each token is completely unique. In order to fractionalize an NFT, a smart contract can be designed to generate a series of ERC20 tokens which are then linked to the specific ERC721 token.

What is the best ERC for NFT? ›

Thanks to its uniqueness, ERC-721 is the top choice for creating NFTs that represent one-of-a-kind digital assets including photographs, artwork, collectibles, DeFi projects, and in-game items. Ethereum's inaugural NFT token standard was Dapper Labs CryptoKitties NFT collection, which are ERC-721 tokens.

What is an example of erc1155 tokens? ›

ERC-1155 is a multi-token standard that supports both fungible and non-fungible tokens. An example of this in real life would be general admission event tickets. Before the event takes place, the tickets act like ERC-20 (fungible) tokens that can be exchanged for each other.

Is an ERC-20 token an NFT? ›

While ERC-20 tokens are fungible tokens that can be replaced by any other token, NFTs are unique tokens that are non-fungible, and can't be switched like-for-like. ERC-404 combines both ideas to create what the team calls a semi-fungible token.

What are ERC-721 tokens? ›

ERC-721 tokens are the standards for non-fungible tokens (NFTs). These tokens cannot be exchanged for anything of equal value since they are unique in themselves, representing a unique asset. Each NFT token is linked to different owners and has its own tokenID or metadata that makes them unique.

What is the function of the ERC-721 token? ›

The ERC-721 standard consists of a set of functions that developers can implement in their smart contracts to create, transfer, and manage NFTs. These functions allow for the creation of unique tokens with their own metadata, making them distinguishable from one another.

What is the difference between ERC-20 and native token? ›

Ether (ETH) is the native token used by the Ethereum blockchain and network as an internal payment system. ERC-20 is the standard for creating smart contract-enabled fungible tokens to be used in the Ethereum ecosystem.

What is the most popular ERC token standard? ›

Erc-20 is the most widely-used token standard, and it defines a set of rules for creating fungible tokens (tokens that are interchangeable with each other) on the ethereum network.

Top Articles
Latest Posts
Article information

Author: Patricia Veum II

Last Updated:

Views: 6647

Rating: 4.3 / 5 (44 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Patricia Veum II

Birthday: 1994-12-16

Address: 2064 Little Summit, Goldieton, MS 97651-0862

Phone: +6873952696715

Job: Principal Officer

Hobby: Rafting, Cabaret, Candle making, Jigsaw puzzles, Inline skating, Magic, Graffiti

Introduction: My name is Patricia Veum II, I am a vast, combative, smiling, famous, inexpensive, zealous, sparkling person who loves writing and wants to share my knowledge and understanding with you.