Jan 30, 2024
Tutorials
ZxStim
ERC-721 tokens need the following functions:
solidityfunction balanceOf(address _owner) external view returns (uint256); function ownerOf(uint256 _tokenId) external view returns (address); function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable; function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable; function transferFrom(address _from, address _to, uint256 _tokenId) external payable; function approve(address _approved, uint256 _tokenId) external payable; function setApprovalForAll(address _operator, bool _approved) external; function getApproved(uint256 _tokenId) external view returns (address); function isApprovedForAll(address _owner, address _operator) external view returns (bool);
and events:
solidityevent Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId); event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId); event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
To become proficient in writing the Solidity language, I will have a series that goes deeper into the features and syntax of the language. This article will focus more on how to create a simple ERC-20 token.
You can use OpenZeppelin Wizard to create ERC-721 tokens with many different features.
whenNotPause
After using the wizard to generate the ERC-20 token code, you can click the Open in Remix
button in the right corner to switch to Remix IDE.
Select the compiler version similar to the code pragma solidity ^0.8.4
and click Compile contract-xxxxxx.sol
After compiling you will see the interface as below
Next, you will deploy your contract on a local blockchain network to test out the features. This article will use Remix VM on Remix IDE.
You keep the values as they are and click on the Deploy
button.
After clicking Deploy
, your Deployed Contracts
section will display the functions in your smart contract as shown below. Here, you can interact with your ERC-20 tokens.
After testing the smart contract on Remix VM, you can deploy your contract on the Goerli or Sepolia testnet. Remember, you must have ETH testnet from the faucet. This article will deploy on Goerli testnet. You select the Environment
section as Injected Provider - Metamask
and change the network on Metamask to Goerli test network
After clicking Deploy
and signing the transaction on Metamask, your Deployed Contracts
section will display the functions in your smart contract as shown below. Here, you can interact with your ERC-721 tokens.
You can also check your deployment transaction on Etherscan by clicking on view on etherscan
.
After testing the smart contract on the testnet, you can deploy your contract on the Mainnet. Remember, you must have ETH to deploy. You select the Environment
section as Injected Provider - Metamask
and change the network on Metamask to Ethereum Mainnet
. Then click Deploy
and sign the transaction on Metamask and you're done.
Unfortunately, at this stage, the author ran out of funds, so I apologize that I don't have any illustrations 🥲.
So after 5 steps, you can deploy a smart contract of ERC-721 tokens to Ethereum's Mainnet network. Hope you find this article useful for your BUIDL journey.