How To Draw Up A Contract To Sell A Car On Payments

In this commodity, I'll show y'all how to make an NFT without software technology skills. Then we will learn how to brand unlimited customizable NFTs with Brownie, Python, and Chainlink. And we'll see how to return and sell our cosmos on the OpenSea NFT marketplace.
If you're looking for a tutorial that uses Truffle, JavaScript, and fun medieval characters, cheque out how to Build, Deploy, and Sell your NFT here.
What is an NFT?
NFTs (Non-Fungible Tokens) can be summed up with 1 discussion: "unique". These are smart contracts deployed on a blockchain that correspond something unique.
ERC20 vs ERC721
NFTs are a blockchain token standard like to the ERC20, like AAVE, SNX, and LINK (technically a ERC677). ERC20s are "fungible" tokens, which ways "replaceable" or "interchangeable."
For case, your dollar bill is going to be worth $ane no thing what dollar pecker you apply. The serial number on the dollar pecker might exist different, but the bills are interchangeable and they'll exist worth $one no thing what.
NFTs, on the other hand, are "non-fungible", and they follow their own token standard, the ERC721. For instance, the Mona Lisa is "non-fungible". Fifty-fifty though someone can make a copy of it, in that location will always only exist one Mona Lisa. If the Mona Lisa was created on a blockchain, information technology would be an NFT.

What are NFTs for?
NFTs provide value to creators, artists, game designers and more by having a permanent history of deployment stored on-chain.
You'll always know who created the NFT, who owned the NFT, where information technology came from, and more, giving them a lot of value over traditional art. In traditional fine art, it can be tricky to empathise what a "fake" is, whereas on-concatenation the history is easily traceable.
And since smart contracts and NFTs are 100% programmable, NFTs can besides take added built-in royalties and any other functionality. Compensating artists has e'er been an issue, since often times an artist's piece of work is spread around without any attribution.
More than and more artists and engineers are jumping on this massive value add, because it'southward finally a great way for artists to exist compensated for their work. And more than than only that, NFTs are a fun manner to bear witness off your inventiveness and get a collector in a digital world.
The Value of NFTs
NFTs have come up a long way, and we keep seeing record breaking NFT sales, like "Everydays: The First 5,000 Days" selling for $69.3 million.

So there is a lot of value here, and it's too a fun, dynamic, and engaging way to create art in the digital world and learn almost smart contract creation. So now I'll teach you everything you need to know about making NFTs.
How to Make an NFT
What we are not going to cover
Now, the easiest way to make an NFT is simply to go to a platform similar Opensea, Rarible, or Mintible and follow their pace-past-step guide to deploying on their platform.
Y'all tin 100% take this route, yet yous could exist bound to the platform, and you lot are shoehorned into the functionality the platform has. You can't achieve the unlimited customization, or really utilize any of the advantages NFTs have. Only if you're a beginner software engineer, or not very technical, this is the route for you.
If you're looking to become a stronger software engineer, learn some solidity, and have the ability to create something with unlimited creativity, then read on!
If you're new to solidity, don't worry, we will go over the basics there as well.
How to Make an NFT with Unlimited Customization
I'g going to become you jump started with this NFT Brownie Mix. This is a working repo with a lot of boilerplate code.
Prerequisites
We demand a few things installed to get started:
- Python
- Nodejs and npm
- Metamask
If y'all're unfamiliar with Metamask, yous tin follow this tutorial to go it set up.
Rinkeby Testnet ETH and LINK
We will also exist working on the Rinkeby Ethereum testnet, and so nosotros will be deploying our contracts to a real blockchain, for free!
Testnets are peachy ways to test how our smart contracts behave in the real world. Nosotros need Rinkeby ETH and Rinkeby LINK, which nosotros can get for free from the links to the latest faucets from the Chainlink documentation.
Nosotros will also demand to add together the rinkeby LINK token to our metamask, which nosotros can exercise past following the acquire LINK documentation.
If you're notwithstanding confused, you lot can following along with this video, just be sure to use Rinkeby instead of Ropsten.
When working with a smart contract platform similar Ethereum, nosotros need to pay a trivial chip of ETH, and when getting data from off-chain, we take to pay a little bit of LINK. This is why we need the testnet LINK and ETH.
Awesome, let's dive in. This is the NFT we are going to deploy to OpenSea.

Quickstart
git clone https://github.com/PatrickAlphaC/nft-mix cd nft-mix
Awesome! At present we need to install the ganache-cli
and eth-brownie
.
pip install eth-brownie npm install -g ganache-cli
Now nosotros can set our environment variables. If you're unfamiliar with environment variables, you tin simply add them into your .env
file, so run:
source .env
A sample .env
should be in the repo you simply cloned with the surroundings variables commented out. Uncomment them to use them!
You'll need a WEB3_INFURA_PROJECT_ID
and a PRIVATE_KEY
. The WEB3_INFURA_PROJECT_ID
tin can be institute be signing upward for a free Infura account. This will give the states a way to ship transactions to the blockchain.
Nosotros will also need a private key, which yous can get from your Metamask. Hit the 3 niggling dots, and click Account Details
and Export Private Key
. Delight do NOT share this key with anyone if you put existent money in it!
export PRIVATE_KEY=YOUR_KEY_HERE export WEB3_INFURA_PROJECT_ID=YOUR_PROJECT_ID_HERE
Now nosotros can deploy our NFT contract and create our first collectible with the following two commands.
brownie run scripts/simple_collectible/deploy_simple.py --network rinkeby brownie run scripts/simple_collectible/create_collectible.py --network rinkeby
The first script deploys our NFT contract to the Rinkeby blockchain, and the second i creates our outset collectible.
You've just deployed your beginning smart contract!
It doesn't exercise much at all, but don't worry – I'll prove you how to return it on OpenSea in the advanced office of this tutorial. But starting time, let'south look at the ERC721 token standard.
The ERC721 Token Standard
Let'southward take a look at the contract that we just deployed, in the SimpleCollectible.sol
file.
// SPDX-License-Identifier: MIT pragma solidity 0.6.6; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; contract SimpleCollectible is ERC721 { uint256 public tokenCounter; constructor () public ERC721 ("Dogie", "DOG"){ tokenCounter = 0; } function createCollectible(cord memory tokenURI) public returns (uint256) { uint256 newItemId = tokenCounter; _safeMint(msg.sender, newItemId); _setTokenURI(newItemId, tokenURI); tokenCounter = tokenCounter + 1; return newItemId; } }
We are using the OpenZepplin package for the ERC721 token. This package that nosotros've imported allows us to use all the functions of a typical ERC721 token. This defines all the functionality that our tokens are going to have, similar transfer
which moves tokens to new users, safeMint
which creates new tokens, and more.
You lot can detect all the functions that are given to our contract by checking out the OpenZepplin ERC721 token contract. Our contract inherits these functions on this line:
contract SimpleCollectible is ERC721 {
This is how solidity does inheritance. When we deploy a contract, the constructor
is automatically called, and it takes a few parameters.
constructor () public ERC721 ("Dogie", "DOG"){ tokenCounter = 0; }
We also use the constructor of the ERC721
, in our constructor, and we simply have to give it a proper name and a symbol. In our case, it's "Calf" and "Domestic dog". This means that every NFT that we create will be of blazon Calf/Dog.
This is similar how every Pokemon card is still a pokemon, or every baseball player on a trading carte is still a baseball player. Each baseball player is unique, but they are all the same all baseball players. We are just using type DOG
.
Nosotros have tokenCounter
at the top that counts how many NFTs we've created of this type. Each new token gets a tokenId
based on the current tokenCounter
.
We can actually create an NFT with the createCollectible
office. This is what we call in our create_collectible.py
script.
role createCollectible(string retentiveness tokenURI) public returns (uint256) { uint256 newItemId = tokenCounter; _safeMint(msg.sender, newItemId); _setTokenURI(newItemId, tokenURI); tokenCounter = tokenCounter + 1; render newItemId; }
The _safeMint
role creates the new NFT, and assigns information technology to whoever called createdCollectible
, aka the msg.sender
, with a newItemId
derived from the tokenCounter
. This is how we tin keep rail of who owns what, by checking the owner of the tokenId
.
You'll observe that we likewise call _setTokenURI
. Allow's talk near that.
When smart contracts were beingness created, and NFTs were being created, people quickly realized that it's reaaaally expensive to deploy a lot of data to the blockchain. Images equally small as one KB tin can hands toll over $1M to shop.
This is conspicuously an issue for NFTs, since having creative art means you take to store this data somewhere. They also wanted a lightweight way to shop attributes about an NFT – and this is where the tokenURI and metadata come into play.
TokenURI
The tokenURI
on an NFT is a unique identifier of what the token "looks" similar. A URI could be an API phone call over HTTPS, an IPFS hash, or anything else unique.
They follow a standard of showing metadata that looks like this:
{ "name": "name", "clarification": "description", "image": "https://ipfs.io/ipfs/QmTgqnhFBMkfT9s8PHKcdXBn1f5bG3Q5hmBaR4U6hoTvb1?filename=Chainlink_Elf.png", "attributes": [ { "trait_type": "trait", "value": 100 } ] }
These bear witness what an NFT looks similar, and its attributes. The epitome
section points to another URI of what the NFT looks similar. This makes it like shooting fish in a barrel for NFT platforms like Opensea, Rarible, and Mintable to render NFTs on their platforms, since they are all looking for this metadata.
Off-Chain Metadata vs On-Chain Metadata
Now yous might be thinking "wait... if the metadata isn't on-chain, does that hateful my NFT might go away at some indicate"? And you'd be correct.
You'd also be right in thinking that off-chain metadata means that yous tin can't apply that metadata to take your smart contracts interact with each other.
This is why nosotros want to focus on on-chain metadata, so that nosotros can program our NFTs to collaborate with each other.
We however need the image
function of the off-chain metadata, though, since we don't have a peachy manner to shop big images on-concatenation. Just don't worry, nosotros tin can do this for free on a decentralized network still by using IPFS.
Here's an example imageURI from IPFS that shows the Chainlink Elf created in the Dungeons and Dragons tutorial.

We didn't set a tokenURI for the elementary NFT considering we wanted to simply show a basic example.
Allow's jump into the advanced NFT now, so we can see some of the amazing features nosotros can do with on-concatenation metadata, have the NFT render on opeansea, and get our Dogie upward!
If you lot desire a refresher video on the section nosotros just went over, follow along with the deploying a simple NFT video.
Dynamic and Advanced NFTs
Dynamic NFTs are NFTs that can change over time, or have on-chain features that we tin use to interact with each other. These are the NFTs that have the unlimited customization for us to make entire games, worlds, or interactive fine art of some-kind. Let's bound into the advanced section.
Advanced Quickstart
Make sure you take plenty testnet ETH and LINK in your metamask, then run the following:
brownie run scripts/advanced_collectible/deploy_advanced.py --network rinkeby brownie run scripts/advanced_collectible/create_collectible.py --network rinkeby
Our collectible here is a random dog breed returned from the Chainlink VRF. Chainlink VRF is a manner to become provable random numbers, and therefore true scarcity in our NFTs. We then want to create its metadata.
brownie run scripts/advanced_collectible/create_metadata.py --network rinkeby
Nosotros can so optionally upload this data to IPFS so that we can have a tokenURI. I'll show you how to do that later. For now, we are but going to use the sample tokenURI of:
https://ipfs.io/ipfs/Qmd9MCGtdVz2miNumBHDbvj8bigSgTwnr4SbyH6DNnpWdt?filename=i-PUG.json
If y'all download IPFS Companion into your browser yous can utilise that URL to encounter what the URI returns. It'll look like this:
{ "name": "PUG", "description": "An adorable PUG pup!", "image": "https://ipfs.io/ipfs/QmSsYRx3LpDAb1GZQm7zZ1AuHZjfbPkD6J7s9r41xu1mf8?filename=pug.png", "attributes": [ { "trait_type": "cuteness", "value": 100 } ] }
And so we tin run our set_tokenuri.py
script:
credibility run scripts/advanced_collectible/set_tokenuri.py --network rinkeby
And we will get an output similar this:
Running 'scripts/advanced_collectible/set_tokenuri.py::main'... Working on rinkeby Transaction sent: 0x8a83a446c306d6255952880c0ca35fa420248a84ba7484c3798d8bbad421f88e Gas price: 1.0 gwei Gas limit: 44601 Nonce: 354 AdvancedCollectible.setTokenURI confirmed - Block: 8331653 Gas used: 40547 (90.91%) Awesome! You can view your NFT at https://testnets.opensea.io/assets/0x679c5f9adC630663a6e63Fa27153B215fe021b34/0 Delight surrender to 20 minutes, and hit the "refresh metadata" push button
And nosotros can hitting the link given to come across what it looks like on Opensea! You lot may accept to striking the refresh metadata
button and await a few minutes.

The Random Breed
Allow'due south talk about what nosotros simply did. Hither is our AdvancedCollectible.sol
:
pragma solidity 0.six.6; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol"; contract AdvancedCollectible is ERC721, VRFConsumerBase { uint256 public tokenCounter; enum Brood{PUG, SHIBA_INU, BRENARD} // add other things mapping(bytes32 => address) public requestIdToSender; mapping(bytes32 => string) public requestIdToTokenURI; mapping(uint256 => Breed) public tokenIdToBreed; mapping(bytes32 => uint256) public requestIdToTokenId; effect requestedCollectible(bytes32 indexed requestId); bytes32 internal keyHash; uint256 internal fee; uint256 public randomResult; constructor(address _VRFCoordinator, address _LinkToken, bytes32 _keyhash) public VRFConsumerBase(_VRFCoordinator, _LinkToken) ERC721("Dogie", "DOG") { tokenCounter = 0; keyHash = _keyhash; fee = 0.1 * 10 ** 18; } function createCollectible(string memory tokenURI, uint256 userProvidedSeed) public returns (bytes32){ bytes32 requestId = requestRandomness(keyHash, fee, userProvidedSeed); requestIdToSender[requestId] = msg.sender; requestIdToTokenURI[requestId] = tokenURI; emit requestedCollectible(requestId); } function fulfillRandomness(bytes32 requestId, uint256 randomNumber) internal override { address dogOwner = requestIdToSender[requestId]; string retention tokenURI = requestIdToTokenURI[requestId]; uint256 newItemId = tokenCounter; _safeMint(dogOwner, newItemId); _setTokenURI(newItemId, tokenURI); Breed breed = Breed(randomNumber % 3); tokenIdToBreed[newItemId] = brood; requestIdToTokenId[requestId] = newItemId; tokenCounter = tokenCounter + ane; } function setTokenURI(uint256 tokenId, string retentiveness _tokenURI) public { crave( _isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved" ); _setTokenURI(tokenId, _tokenURI); } }
Nosotros use the Chainlink VRF to create a random breed from a listing of PUG, SHIBA_INU, BRENARD
. When nosotros call createCollectible
this time, we actually kicked off a request to the Chainlink VRF node off-chain, and returned with a random number to create the NFT with one of those 3 breeds.
Using truthful randomness in your NFTs is a not bad way to create true scarcity, and using an Chainlink oracle random number ways that your number is provably random, and tin can't be influenced by the miners.
You can larn more than about Chainlink VRF in the documentation.
The Chainlink node responds past calling the fulfillRandomness
part, and creates the collectible based on the random number. We then all the same take to call _setTokenURI
to give our NFT the appearance that it needs.
Nosotros didn't give our NFT attributes here, but attributes are a bully way to have our NFTs boxing and interact. You can meet a great case of NFTs with attributes in this Dungeons and Dragons case.
Metadata from IPFS
We are using IPFS to store two files:
- The image of the NFT (the pug image)
- The tokenURI file (the JSON file which also includes the link of the paradigm)
We use IPFS considering information technology's a free decentralized platform. We tin add our tokenURIs and images to IPFS by downloading IPFS desktop, and hitting the import
button.

And so, we can share the URI by hitting the three dots side by side to the file we want to share, hitting share link
and copying the link given. We tin and then add this link into our set_tokenuri.py
file to alter the token URI that we want to utilise.
Persistance
However, if the tokenURI is only on our node, this means when our node is down, no one else can view information technology. And then nosotros want others to pin
our NFT. We can use a pinning service similar Pinata to help continue our data live even when our IPFS node is downwardly.
I imagine in the future more than and more metadata will be stored on IPFS and decentralized storage platforms. Centralized servers can go down, and would mean that the art on those NFTs is lost forever. Be sure to check where the tokenURI of the NFT you lot use is located!
I also expect down the line that more people volition use dStorage platforms like Filecoin, equally using a pinning service also isn't as decentralized as it should be.
Going forward
If you lot'd similar a video walkthrough of the advanced NFT, yous can watch the avant-garde NFT video.
Now you have the skills to make beautiful fun, customizable, interactive NFTs, and have them render on a market place.
NFTs are fun, powerful ways to have artists accurately compensated for all the hard work that they do. Good luck, and recollect to have fun!
Learn to lawmaking for gratis. freeCodeCamp'southward open source curriculum has helped more than 40,000 people get jobs as developers. Get started
Source: https://www.freecodecamp.org/news/how-to-make-an-nft-and-render-on-opensea-marketplace/
Posted by: ruckersoetted.blogspot.com
0 Response to "How To Draw Up A Contract To Sell A Car On Payments"
Post a Comment