To enter a name on the marketplace’s dashboard and perceive fees when someone sells one of our NFTs, we need to implement the contract-level metadata.
Here are the values we will use:
{ "name":"My Super NFT on Auction", "description":"You’ve never seen NFTs this beautiful.", "image":"", "external_link":"", "seller_fee_basis_points":100, "fee_recipient":"PUT YOUR ADDRESS HERE" }
We now have the content of our metadata, we need to upload it on IPFS.
To upload our files on IPFS we will now use the Starton IPFS pinning service.
As the contract-level metadata only needs to be uploaded once, we can directly do it from our dashboard.
Go to IPFS.
Click Upload.
Select JSON.
Enter JSON content.
Enter a name for the file.
Click Upload.
Once done, a column “CID” appears with a value for our file. We will use this data for the Contract Uri Suffix of our smart contract!
We also use IPFS to store the content that will be referenced in our deployed contract.
We do not store the content directly on blockchain as it is too heavy and would induce a very high cost.
The best solution is to store it somewhere else and only store a reference on-chain.
Go to IPFS.
Click Upload.
Select File(s).
Select content.
Enter a name for the file.
Click Upload.
Once our image uploaded, let's upload its metadata so that we can call it from our smart contract function.
For the sale contract to be able to mint new tokens, you are going to need to grant the newly created contract the MINTER_ROLE over the base contract deployed.
To enter a name on the marketplace’s dashboard and perceive fees when someone sells one of our NFTs, we need to implement the contract-level metadata.
Here are the values we will use:
{ "name": "My Super NFT for Sale", "description": "You’ve never seen NFTs this beautiful.", "image": "",// the URI of your image, for example ipfs://CID_OF_YOUR_IMG "external_link": "", "seller_fee_basis_points": 100, "fee_recipient": "PUT YOUR ADDRESS HERE" }
We now have the content of our metadata, we need to upload it on IPFS.
To upload our files on IPFS we will now use the Starton IPFS pinning service.
As the contract-level metadata only needs to be uploaded once, we can directly do it from our dashboard.
Go to IPFS.
Click Upload.
Select JSON.
Enter JSON content.
Enter a name for the file.
Click Upload.
Once done, a column “CID” appears with a value for our file. We will use this data for the Contract Uri Suffix of our smart contract!
We also use IPFS to store the content that will be referenced in our deployed contract.
We do not store the content directly on blockchain as it is too heavy and would induce a very high cost.
The best solution is to store it somewhere else and only store a reference on-chain.
Go to IPFS.
Click Upload.
Select File(s).
Select content.
Enter a name for the file.
Click Upload.
Once our image uploaded, let's upload its metadata so that we can call it from our smart contract function.
To enter a name on the marketplace’s dashboard and perceive fees when someone sells one of our NFTs, we need to implement the contract-level metadata.
Here are the values we will use:
{ "name":"My Super NFT on Auction", "description":"You’ve never seen NFTs this beautiful.", "image":"", "external_link":"", "seller_fee_basis_points":100, "fee_recipient":"PUT YOUR ADDRESS HERE" }
We now have the content of our metadata, we need to upload it on IPFS.
To upload our files on IPFS we will now use the Starton IPFS pinning service.
As the contract-level metadata only needs to be uploaded once, we can directly do it from our dashboard.
Go to IPFS.
Click Upload.
Select JSON.
Enter JSON content.
Enter a name for the file.
Click Upload.
Once done, a column “CID” appears with a value for our file. We will use this data for the Contract Uri Suffix of our smart contract!
We also use IPFS to store the content that will be referenced in our deployed contract.
We do not store the content directly on blockchain as it is too heavy and would induce a very high cost.
The best solution is to store it somewhere else and only store a reference on-chain.
Go to IPFS.
Click Upload.
Select File(s).
Select content.
Enter a name for the file.
Click Upload.
Once our image uploaded, let's upload its metadata so that we can call it from our smart contract function.
If you want to mint more than one edition of your NFT, you'll need to create a smart contract using an ERC1155-flavored template.
When minting an NFT collection, you make multiple identical editions of the content. This is one type of collection. Multiple digital items will be issued. They will feature identical content with a different, unique token ID for each NFT. In this case, you will have a unique token ID for each digital item issued with its unique data.
You will need:
a wallet to fund the creation of your contract
the URI of the metadata of your collectionRead more.
the URI of the content of the NFT. You can upload your file on IPFS. Read more.
This is where we use the values we've listed earlier:
Name: "My first NFT collection"
Description: "This is my first collection of NFT "
Definitive Name: "myFirstCollection"
Initial Token URI: the link to the content of your NFT
Initial Contract URI: the link to the metadata of your contract
Initial Owner of Multi Sig Contract: The address of the owner of the contract
const axios =require("axios") const axiosInstance = axios.create({ baseURL:"https://api.starton.com", headers:{"x-api-key":"PUT HERE YOUR API KEY"}, }) axiosInstance .post("/v3/smart-contract/from-template",{ network:"", signerWallet:"", templateId:"ERC1155_META_TRANSACTION", name:"My first NFT collection", description:"This is my first collection of NFT ", params:[ "myFirstCollection", "",// Initial Token URI "",// Initial Contract URI "",// Initial Owner of Multi Sig Contract ], speed:"average", }) .then((response)=>{ console.log(response.data) })
Id: the identifer of the NFT within the collection
Amount: amount to mint
Click Interact.
In the function list, select mint.
Select the signer wallet.
Enter the receiving wallet in the field to. Enter the id for your mint. It will be the rank of your NFT
in your collection. And finally, enter an amount.
Click Run.
Select your Speed and click Validate.
Congratulations! You've minted the first NFT of your collection.
In this tutorial, we will create your own token. The fixed supply version of this standard guarantees no token will ever be created after the initial emission.
Fungible tokens are token from which the value of each token is equal to another.
You will need:
a wallet address with funds: You can use your default Starton wallet, at creation Starton provides you with faucets.
definitiveName: The name of your smart contract which will be reflected on-chain.
definitiveSymbol: The symbol of your smart contract which will be reflected on-chain
definitiveSupply: The total amount of tokens that will ever be minted.
initialOwnerOrMultisigContract: The address that will own the ERC20 contract.
const axios =require("axios") const axiosInstance = axios.create({ baseURL:"https://api.starton.com", headers:{ "x-api-key":"PUT HERE YOUR API KEY", }, }) axiosInstance .post("/v3/smart-contract/from-template",{ network:"",// The blockchain network on which you want to deploy your smart contract signerWallet:"",// The address of the signer wallet templateId:"ERC20_META_TRANSACTION", name:"",// The name of the contract on Starton description:"",// The description of the contract on Starton params:[ "",// The name of your smart contract which will be reflected on-chain. "",// The symbol of your smart contract which will be reflected on-chain "",// The total amount of tokens that will ever be minted. "",// The address that will own the ERC20 contract. ], }) .then((response)=>{ console.log(response.data) })
const axios =require("axios") const axiosInstance = axios.create({ baseURL:"https://api.starton.com", headers:{ "x-api-key":"PUT HERE YOUR API KEY", }, }) axiosInstance .post("/v3/smart-contract/YOUR_SMART_CONTRACT_NETWORK/YOUR_SMART_CONTRACT_ADDRESS/call",{ functionName:"transfer(address,uint256)", params:[ "",// Enter the wallet receiving tokens. "",//amount of token transferred ], signerWallet:"",// Enter the wallet from which tokens will be transferred. speed:"average", }) .then((response)=>{ console.log(response.data) })
In this tutorial, we will create your own token. The mintable supply version of this standard guarantees no token will ever be created after the initial emission.
Fungible tokens are token from which the value of each token is equal to another.
You will need:
a wallet address with funds: You can use your default Starton wallet, at creation Starton provides you with faucets.
definitiveName: The name of your smart contract which will be reflected on-chain.
definitiveSymbol: The symbol of your smart contract which will be reflected on-chain
initialSupply: The initial amount of tokens that will be minted.
initialOwnerOrMultisigContract: The address that will own the ERC20 contract.
const axios =require("axios") const axiosInstance = axios.create({ baseURL:"https://api.starton.com", headers:{ "x-api-key":"PUT HERE YOUR API KEY", }, }) axiosInstance .post("/v3/smart-contract/from-template",{ network:"",// The blockchain network on which you want to deploy your smart contract signerWallet:"",// The address of the signer wallet templateId:"ERC20_MINT_META_TRANSACTION", name:"",// The name of the contract on Starton description:"",// The description of the contract on Starton params:[ "",// The name of your smart contract which will be reflected on-chain. "",// The symbol of your smart contract which will be reflected on-chain "",// The total amount of tokens that will ever be minted. "",// The address that will own the ERC20 contract. ], }) .then((response)=>{ console.log(response.data) })
const axios =require("axios") const axiosInstance = axios.create({ baseURL:"https://api.starton.com", headers:{ "x-api-key":"PUT HERE YOUR API KEY", }, }) axiosInstance .post("/v3/smart-contract/YOUR_SMART_CONTRACT_NETWORK/YOUR_SMART_CONTRACT_ADDRESS/call",{ functionName:"transfer(address,uint256)", params:[ "",// Enter the wallet receiving tokens. "",//amount of token transferred ], signerWallet:"",// Enter the wallet from which tokens will be transferred. speed:"average", }) .then((response)=>{ console.log(response.data) })
Be sure to replace x-api-key value with your own api key!
When querying the API, it should return a list of template items:
{ "id":"ERC20_META_TRANSACTION", "name":"ERC20 Fungible Token with fixed supply", "description":"An ERC20 token contract keeps track of fungible tokens: any one token is exactly equal to any other token", "tags":["..."], "blockchains":["..."], "bytecode":"string", "constructorParams":["..."], "abi":["..."], "compilerVersion":"string", "source":"string", "isAudited":true, "isActivated":true, "createdAt":"string", "updatedAt":"string" }
This is the object associated with the template we’ll use for our crypto token.
We’ll be using an ERC20 template as it is the standard for token creation on EVM based blockchains.
Now that we know which template to use, we also need to choose a network on which to deploy.
The compatible blockchains for this template can be seen inside the blockchain objects in the previously returned template object.
For example for the Ethereum blockchain there are multiple available networks such as ethereum-mainnet or ethereum-sepolia (testnet).
We’ll choose to deploy our contract on the ethereum-sepolia network.
It is now important that we fuel our wallet with some Ether faucet otherwise the blockchain will reject our smart contract’s deployment as we will lack funds to cover the gas fees.
In order to claim test faucets we need to go on the Wallet section on Connect’s dashboard and find the address associated to the network we are interested in.
Here, it is the ethereum-sepolia network.
We can now claim free faucet on the official Ethereum faucet website.
Enter your address, click Send me test Ether and wait for the transaction to complete.
Most blockchains propose a blockchain explorer so we can inspect the state and history of the blockchain.
We can thus use the previously returned address and creation hash to check for our contract’s status on the blockchain.
The summary of the transaction created for the deployment of our contract (using the creationHash in the url) is available.
We can also track here our new DEMO token.
You can use Starton to integrate blockchain into your application in a few steps. Let's create a project to deploy a smart contract from Code with Starton's API.
not a developer?
To follow this tutorial, you will need coding experience. If it's not your case, you can still deploy your smart contract:
Before we can continue you will need a Starton Wallet to sign our transaction.
Starton Wallet
Starton Wallet uses a KMS. Metamask is unavailable when using Starton from code. Since it is a browser extension, Starton API cannot access it from your project.
For more information, see Understanding Key Management Systems.
We recommend you to create your wallet on Starton web application, but you can also create it from code if you'd like to automate it.
To interact with the blockchain you will need the native currency of this blockchain to pay the gas fees. On the testnet, you can claim free faucet here.
For this tutorial, you will deploy your own ERC20 token. Starton provides you with a library of smart contracts templates. Learn more.
Now, let's write your first API call!
starton.post("/v3/smart-contract/from-template",{ "network":"binance-testnet",// you can choose any network "signerWallet":"YOUR STARTON WALLET",// This will be the wallet that pay the fee. Must be on starton, cannot be a Metamask wallet "templateId":"ERC20_META_TRANSACTION",// you can choose another template "name":"My first smart token",// the name that will be displayed on the dashboard, not on chain "description":"This is the first smart contract I deploy. ",// same, dashboard description and optional "params":[ "My first token ",// Your smart contract name, on chain "MFT",// the symbol of your token "10000"+"000000000000000000",// 10000 token supply + 18 zero. "ANY WALLET YOU WANT"// The wallet that will receive the token supply, can be a starton wallet or metamask ], "speed":"average",// The fees you will pay on chain. More info HERE }).then((response)=>{ console.log({ transactionHash: response.data.transaction.transactionHash, smartContractAddress: response.data.smartContract.address, explorer:`https://testnet.bscscan.com/tx/${response.data.transaction.transactionHash}` }) }).catch(error=>console.error(error.response.data))
Congratulations on your first request. Let's dive into what we just did:
We used a ERC20 template. You can find more templates in Starton Library
We had to put 18 zeros after "10000" as the smart contract will read the amount in wei (the equivalent of cents, except there are 18 decimals and not 2).
Congratulations on deploying your first smart contract!
In this tutorial, you discovered how to deploy your first smart contract but this is only the first step.
In this tutorial, we will see how we can deploy a smart contract and interact with it to mint NFTs on BNB Chain testnet in 6 steps.
We will use random images uploaded on IPFS (a distributed file storage system) and assigned to an BNB Chain address.
You will:
Upload the contract-level metadata
Use a template from Starton for our smart contract (ERC721).
To enter a name on the marketplace’s dashboard and perceive fees when someone sells one of our NFTs, we need to implement the contract-level metadata.
Here are the values we will use:
{ name: "My Super NFT on BNB", description: "You’ve never seen NFTs this beautiful.", image: "URI of your image", // This will be used as the image of your collection external_link: "", seller_fee_basis_points: 100, fee_recipient: "PUT YOUR ADDRESS HERE", }
We now have the content of our metadata, we need to upload it on IPFS.
To upload our files on IPFS we will now use the Starton IPFS pinning service.
As the contract-level metadata only needs to be uploaded once, we can directly do it from our dashboard.
Several standards of smart contracts have been developed for NFTs.
The most used ones are ERC721 and the ERC1155.
If you want to see in more details the differences between the two standards, read The Difference Between ERC721 vs ERC1155.
Today, we will use the ERC721 smart contract template.
a blockchain / network on which to deploy, here BNB testnet.
the parameters of our contract.
For more information on parameters, check out the Deploying a Smart Contract.
For example, we can call our contract “Best NFTs on BNB” and deploy it on the BNB Testnet network.
The following constructor parameters are:
Name: This name stored on blockchain, we will use “Best NFTs on BNB”.
Symbol: The symbol that will be displayed on blockchain explorers for example. We’ll use “BNFTBNB”.
Base Uri: This corresponds to the root of the url that will be used to find the content. We’ll use “ipfs://ipfs/“ as we store the content on IPFS.
Owner Or Multi Sig Contract: This is the address of the owner of the smart contract. We will put our Starton account address that can be found in the “Wallets” section and should be the one chosen at the top as well.
Contract Uri Suffix: This corresponds to the CID of your contract-level metadata on IPFS. This is needed for example if you want to perceive fees when your NFTs are sold on OpenSea.
We can finally deploy our contract!
With our smart contract deployed, you are redirected on the page where we will interact with our contract.
The process of minting a new NFT and sending it to an address goes in three steps:
We upload the content of our NFT on IPFS (as it is too heavy to be stored on-chain) and get the CID of the content.
We upload a metadata object as a JSON file on IPFS as we do not reference the content directly in the contract. Instead, we put the CID of the content in a metadata object that we upload on IPFS.
We call the function “mint” of our smart contract, giving the CID of our metadata object and the address that will receive the NFT.
You can choose to mint NFT from code or from Starton's interface.
We’ll also use IPFS to store the content that will be referenced in our deployed contract.
We do not store the content directly on blockchain as it is too heavy and would induce a very high cost.
The best solution is to store it somewhere else and only store a reference on-chain.
We can create a simple function like this one:
// The image variable should be a buffer asyncfunctionuploadImageOnIpfs(image, name){ let data =newFormData() data.append("file", image, name) data.append("isSync","true") const ipfsImg =await starton.post("/ipfs/file", data,{ maxBodyLength:"Infinity", headers:{"Content-Type":`multipart/form-data; boundary=${data._boundary}`}, }) return ipfsImg.data }
By calling this function, providing our image as a buffer as a parameter, we should get back an object containing our image’s CID which we will use next in the metadata object.
Consult the metadata standard format on your marketplace's documentation.
We can define a new function using our image’s CID to upload the metadata on IPFS:
We’ll also use IPFS to store the content that will be referenced in our deployed contract.
We do not store the content directly on blockchain as it is too heavy and would induce a very high cost.
The best solution is to store it somewhere else and only store a reference on-chain.
Go to IPFS.
Click Upload.
Select File(s).
Select content.
Enter a name for the file.
Click Upload.
Once our image uploaded, let's upload its metadata so that we can call it from our smart contract function.
We have seen in this tutorial how to upload NFTs on a decentralised file system, how to deploy an ERC721 smart contract using Starton, how to make it compatible with marketplaces standards and how we can dynamically mint the NFTs from code to send them to people!
We hope you liked this tutorial and that you will follow along in this epic journey of making Web3 the new standard for Internet!
We are very eager to see what you can build with NFTs.
Do not hesitate to share what you’ve done!
In this tutorial, we will see how we can deploy a smart contract and interact with it to mint NFTs dynamically from code.
We will use random images uploaded on IPFS (a distributed file storage system) and assigned to an Ethereum address.
You will :
Use a template from Starton for our smart contract (ERC721).
Several standards of smart contracts have been developed for NFTs.
The most used ones are ERC721 and the ERC1155.
The main big difference between the two is that in an ERC721, every NFT is unique which means you will have to reference the content for each of them.
Meanwhile the ERC1155 enables you to create “collections” where there are several copies of the same NFT.
The ERC721, which is easier to use, still can be used to upload several copies of the same content, but is less optimised for this use case than the ERC1155.
If you want to see in more details the differences between the two standards, read The Difference Between ERC721 vs ERC1155.
Today, we will use the ERC721 smart contract template.
We’ll also use IPFS to store the content that will be referenced in our deployed contract.
We do not store the content directly on blockchain as it is too heavy and would induce a very high cost.
The best solution is to store it somewhere else and only store a reference on-chain.
the parameters of our contract.
For more information on parameters, check out the Deploying a Smart Contract.
For example, we can call our contract “My Super NFTs” and deploy it on the Polygon amoy network.
The following constructor parameters are:
Name: This name stored on blockchain, we will keep “My Super NFTs”.
Symbol: The symbol that will be displayed on blockchain explorers for example. We’ll use “MSNFT”.
Base Uri: This corresponds to the root of the url that will be used to find the content. We’ll use “ipfs://ipfs/“ as we store the content on IPFS.
Owner Or Multi Sig Contract: This is the address of the owner of the smart contract. We will put our Starton account address that can be found in the “Wallets” section and should be the one chosen at the top as well.
Contract Uri Suffix: This corresponds to the IPFS cid of your contract level metadata. This is needed for example if you want to perceive fees when your NFTs are sold on OpenSea.
To be able to fill this field we need to upload a JSON file that respects OpenSea’s specification for the contract level metadata on IPFS.
Lost on the Contract Uri Suffix part? Let’s see this in more details so we can finish the deployment of our contract.
This enables us to add a name on the OpenSea’s dashboard and perceive fees when someone sells one of our NFTs.
Here are the values we will use:
{ "name":"My Super NFTs", "description":"You’ve never seen NFTs this beautiful.", "image":"", "external_link":"", "seller_fee_basis_points":100, "fee_recipient":"PUT YOUR ADDRESS HERE" }
We now have the content of our metadata, we need to upload it on IPFS.
On IPFS, the content is not referred using an address like we are used to with urls, but by the content’s value.
Let’s see the difference:
When we query some content based on location we implicitly ask:
"Give me the content that is located at https://… no matter what it is that you find".
Whereas when we query some content based on its value on IPFS we implicitly ask:
"Find the content on the network with the hash XXXXXXX and give it to me, no matter who where it is".
With the location based approach we are specific on the “How” and not on the “What” while with the content based approach it is the opposite.
Using the content based approach, we are sure we get the content we want, without it being altered, replaced or infected as otherwise the hash would have changed as well.
And it is a game changer as we do no longer need to rely on trust!
The hash of the content is called a Content IDentifier (CID) on IPFS.
And when we will upload our contract-level metadata on IPFS we will get a CID back, which is the value we need to put as the Contract Suffix Uri in our smart contract.
To upload our files on IPFS we will now use the Starton IPFS pinning service.
As the contract-level metadata only needs to be uploaded once, we can directly do it from our dashboard
Once done, a column “CID” appears with a value for our file that starts with “Qm”. This is the value we need for the Contract Uri Suffix of our smart contract!
We can finally deploy our contract!
With our smart contract deployed, we are redirected on the page to interact with our contract.
We won’t interact with it from the dashboard but you can click on the smart contract address at the top to see our contract in the blockchain explorer.
You will see next how to upload dynamically our images on IPFS from code with the API.
The process of minting a new NFT and sending it to an address goes in three steps:
We upload the content on IPFS (as it is too heavy to be stored on-chain) and get the CID of the content.
We upload a metadata object as a JSON file on IPFS as we do not reference the content directly in the contract. Instead, we put the CID of the content in a metadata object that we upload on IPFS.
We call the function “mint” of our smart contract, giving the CID of our metadata object and the address that will receive the NFT.
// The image variable should be a buffer asyncfunctionuploadImageOnIpfs(image, name){ let data =newFormData() data.append("file", image, name) data.append("isSync","true") const ipfsImg =await starton.post("/ipfs/file", data,{ maxBodyLength:"Infinity", headers:{"Content-Type":`multipart/form-data; boundary=${data._boundary}`}, }) return ipfsImg.data }
By calling this function, providing our image as a buffer as a parameter, we should get back an object containing our image’s CID which we will use next in the metadata object.
Once all of this is executed, the content should be on IPFS, and associated to the given address in our ERC721 contract.
You should be able to see the NFTs on OpenSea or via this link https://testnets.opensea.io/collection/my-super-nfts.
We have seen in this tutorial how to upload NFTs on a decentralised file system, how to deploy an ERC721 smart contract using Starton, how to make it compatible with OpenSea’s standards and how we can dynamicaly mint the NFTs from code to send them to people!
We hope you liked this tutorial and that you will follow along in this epic journey of making Web3 the new standard for Internet!
We are very eager to see what you can build with NFTs.
Do not hesitate to share what you’ve done!
You can also deploy your smart contract from our web application.