Skip to main content

11 posts tagged with "TEMPLATES'"

View All Tags

· 4 min read
Loubna Benzaama

In this tutorial, you will learn how to sell an NFT in an Auction.

Deploy an ERC721

You will start by deploying an ERC721 that will be the base of the NFT you want to sell in an auction.

Upload Contract-level metadata on IPFS

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.

  1. Go to IPFS.
  2. Click Upload.
  3. Select JSON.
  4. Enter JSON content.
  5. Enter a name for the file.
  6. 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!

Upload a file on IPFS

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.

  1. Go to IPFS.
  2. Click Upload.
  3. Select File(s).
  4. Select content.
  5. Enter a name for the file.
  6. Click Upload.

Once our image uploaded, let's upload its metadata so that we can call it from our smart contract function.

Upload the metadata of your content on IPFS

info

Consult the metadata standard format on your marketplace's documentation.

  1. Go to IPFS.
  2. Click Upload.
  3. Select JSON.
  4. Select content.
  5. Enter a name for the file.
  6. Click Upload.

Everything we need to sell your NFT is an auction is done.

Deploy the base contract

We will deploy the contract only once, so we will do it directly from Starton’s dashboard.

We can access the list of templates in the Smart contract section.

  1. Select the ERC721 NFT Smart Contract template.
  2. Enter:
  • a name for your contract,
  • a wallet to sign the transaction,
  • 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:

  • definitiveName: This name stored on blockchain, we will use “Best NFTs on BNB”.
  • initialTokenUri: This is the public URL that contains the metadata of the collection. Here it starts with ipfs://ipfs/,
  • initialContractUri: The URI of the metadata that will be used to give more details about the description.
  • initialOwnerOrMultisigContract: The address that will own the NFT Collection.

We can finally deploy our contract!

Deploy an ERC721 Auction

We will deploy the contract only once, so we will do it directly from Starton’s dashboard.

We can access the list of templates in the Smart contract section.

  1. Select the ERC721 Auction template.
  2. Enter:
  • definitiveTokenAddress: The token address of the ERC721 that you want to sell.
  • definitiveFeeReceiver: The address that will receive all the price paid to mint the NFTs.
  • initialStartingPrice: The initial price that the NFT will be sold for.
  • initialMinPriceDifference: The price increase that a user needs to at least put to bid on top of the current auction winner.
  • initialStartTime: The time when the sale will begin and users can bid.
  • initialEndTime: The time when the sale will end and users couldn't bid anymore.
  • initialTokenURI: The URI that will be append in the end of the base token URI for the token that will be minted.

Interact with your contract

You can now bid, claim, or start a new auction. The mint of your NFT is made when the bidder which has won the auction claims it.

· 3 min read
Loubna Benzaama

In this tutorial, you will learn how to sell an NFT collection in an Auction.

You will need

  • a deployed ERC1155 NFT contract

Deploy an ERC1155 Auction Sale smart contract

You can start by accessing the list of templates in the Smart contract section. Then, you can deploy the smart contract from code.

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_AUCTION_SALE",
name: "",
description: "",
params: [
"", //definitiveTokenAddress
"", //definitiveFeeReceiver
"", //initialStartingPrice
"", //initialMinPriceDifference
"", //initialStartTime
"", //initialEndTime
"", //initialTokenID
"", //initialTokenAmount
],
})
.then((response) => {
console.log(response.data)
})
  1. Select the ERC1155 Auction template.
  2. Enter:
  • definitiveTokenAddress: The token address of the ERC1155 that you want to sell.
  • definitiveFeeReceiver: The address that will receive all the price paid to mint the NFTs.
  • initialStartingPrice: The initial price that the NFT will be sold for.
  • initialMinPriceDifference: The price increase that a user needs to at least put to bid on top of the current auction winner.
  • initialStartTime: The time when the sale will begin and users can bid.
  • initialEndTime: The time when the sale will end and users couldn't bid anymore.
  • initialTokenURI: The URI that will be append in the end of the base token URI for the token that will be minted.
  • initialTokenID: The token id of the token that will be minted for the auction.
  • initialTokenAmount: The amount of tokens that will be minted for the auction.

Giving ownership to your sale contract

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.

You will need:

  • the address of the base ERC1155 contract
  • the address of the Sale contract
  • the data of the Minter Role (in bytes)

Retrieving the MINTER_ROLE

First, let's get the minter role:

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/{network}/{YOUR_BASE_CONTRACT}/read", {
functionName: "MINTER_ROLE",
params: [],
})
.then((response) => {
console.log(response.data)
})

Granting the minter role to your Sale contract

To grant the minter role to your contract, you can use the following request:

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/${network}/${YOUR SMART CONTRAT ADDRESS}/call", {
functionName: "grantRole(bytes32,address)",
params: [
"0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6", // MINTER_ROLE
"", // account
],
signerWallet: "",
speed: "average",
})
.then((response) => {
console.log(response.data)
})
  • account: The whitelist sale contract address

Interact with your contract

You can now bid, claim, or start a new auction. The mint of your NFT is made when the bider which has won the auction claims it.

· 4 min read
Loubna Benzaama

In this tutorial, you will learn how to sell an NFT.

Deploy an ERC721

You will start by deploying an ERC721 that will be the base of the NFT you want to sell.

Upload Contract-level metadata on IPFS

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.

  1. Go to IPFS.
  2. Click Upload.
  3. Select JSON.
  4. Enter JSON content.
  5. Enter a name for the file.
  6. 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!

Upload a file on IPFS

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.

  1. Go to IPFS.
  2. Click Upload.
  3. Select File(s).
  4. Select content.
  5. Enter a name for the file.
  6. Click Upload.

Once our image uploaded, let's upload its metadata so that we can call it from our smart contract function.

Upload the metadata of your content on IPFS

info

Consult the metadata standard format on your marketplace's documentation.

  1. Go to IPFS.
  2. Click Upload.
  3. Select JSON.
  4. Select content.
  5. Enter a name for the file.
  6. Click Upload.

Everything we need to sell your NFT is an auction is done.

Deploy the base contract

We will deploy the contract only once, so we will do it directly from Starton’s dashboard.

We can access the list of templates in the Smart contract section.

  1. Select the ERC721 NFT Smart Contract template.
  2. Enter:
    • a name for your contract,
    • a wallet to sign the transaction,
    • 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:

  • definitiveName: This name stored on blockchain, we will use “Best NFTs on BNB”.
  • initialTokenUri: This is the public URL that contains the metadata of the collection. Here it starts with ipfs://ipfs/,
  • initialContractUri: The URI of the metadata that will be used to give more details about the description.
  • initialOwnerOrMultisigContract: The address that will own the NFT Collection.

We can finally deploy our contract!

Deploy an ERC721 Sale

We will deploy the contract only once, so we will do it directly from Starton’s dashboard.

We can access the list of templates in the Smart contract section.

  1. Select the ERC721 Sale template.
  2. Enter:
  • definitiveTokenAddress: The token address of the ERC721 that you want to sell.
  • definitivePrice: The price that the NFTs will be sold for.
  • definitiveStartTime: The time when the sale will begin and users can mint tokens.
  • definitiveEndTime: The time when the sale will end and users couldn't mint anymore tokens.
  • definitiveMaxTokensPerAddress: The maximum amount of tokens that can be minted by a single address.
  • definitiveMaxSupply: The maximum amount of tokens that can be minted during the sale.
  • definitiveFeeReceiver: The address that will receive all the price paid to mint the NFTs.

Interact with your contract

Once your NFT is sold, you can withdraw the amount received during the sale by interacting with the smart contract.

  1. On the smart contract page, click Interact.
  2. Select the withdraw function.
  3. Click Run.

The amount is transferred from the address of the smart contract to the address of the fee receiver.

· 5 min read
Loubna Benzaama

In this tutorial, you will learn how to sell an NFT in an Auction.

You will need

  • The token address of the ERC721 that you want to sell.
  • The address that will receive the amount paid for the NFTs.
  • The initial price offered for the NFT.
  • The minimum bid increment to place a bid on top of the current maximum bid.
  • The time at which the sale will begin and end, where users can bid. Timestamp in seconds.
  • The URI that will be append in the end of the base token URI for the token that will be minted.

Deploy an ERC721

You will start by deploying an ERC721 that will be the base of the NFT you want to sell in an auction.

Upload Contract-level metadata on IPFS

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.

  1. Go to IPFS.
  2. Click Upload.
  3. Select JSON.
  4. Enter JSON content.
  5. Enter a name for the file.
  6. 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!

Upload a file on IPFS

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.

  1. Go to IPFS.
  2. Click Upload.
  3. Select File(s).
  4. Select content.
  5. Enter a name for the file.
  6. Click Upload.

Once our image uploaded, let's upload its metadata so that we can call it from our smart contract function.

Upload the metadata of your content on IPFS

info

Consult the metadata standard format on your marketplace's documentation.

  1. Go to IPFS.
  2. Click Upload.
  3. Select JSON.
  4. Select content.
  5. Enter a name for the file.
  6. Click Upload.

Everything we need to sell your NFT is an auction is done.

Deploy the base contract

We will deploy the contract only once, so we will do it directly from Starton’s dashboard.

We can access the list of templates in the Smart contract section.

  1. Select the ERC721 NFT Smart Contract template.
  2. Enter:
    • a name for your contract,
    • a wallet to sign the transaction,
    • 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:

  • definitiveName: This name stored on blockchain, we will use “Best NFTs on BNB”.
  • initialTokenUri: This is the public URL that contains the metadata of the collection. Here it starts with ipfs://ipfs/,
  • initialContractUri: The URI of the metadata that will be used to give more details about the description.
  • initialOwnerOrMultisigContract: The address that will own the NFT Collection.

We can finally deploy our contract!

Deploy an ERC721 Auction

We will deploy the contract only once, so we will do it directly from Starton’s dashboard.

We can access the list of templates in the Smart contract section.

  1. Select the ERC721 Auction template.
  2. Enter:
  • definitiveTokenAddress: The token address of the ERC721 that you want to sell.
  • definitiveFeeReceiver: The address that will receive all the price paid to mint the NFTs.
  • initialStartingPrice: The initial price that the NFT will be sold for.
  • initialMinPriceDifference: The price increase that a user needs to at least put to bid on top of the current auction winner.
  • initialStartTime: The time when the sale will begin and users can bid.
  • initialEndTime: The time when the sale will end and users couldn't bid anymore.
  • initialTokenURI: The URI that will be append in the end of the base token URI for the token that will be minted.

Interact with your contract

You can now bid, claim, or start a new auction. The mint of your NFT is made when the bidder which has won the auction claims it.

· 5 min read
Loubna Benzaama

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 collection Read more.
  • the URI of the content of the NFT. You can upload your file on IPFS. Read more.
  • the address of the initial owner
  • the network on which you want to deploy

In this tutorial, we will:

Deploying the smart contract

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)
})

Minting the first NFT of your collection

You will need the following information:

  • Wallet: the signer wallet
  • To: the wallet receiving your NFT
  • Id: the identifer of the NFT within the collection
  • Amount: amount to mint
    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/polygon-amoy/0xc900546AA43C88aBcAF70c20448DF45917c8363A/call",
{
functionName: "mint(address,uint256,uint256,bytes)",
params: [
"", // the signer wallet
"", // the receiving wallet
"1",// the ID
"1" // the amount
],
signerWallet: "",
speed: "average"
}).then((response) => {
console.log(response.data)
})

· 4 min read
Loubna Benzaama

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.

In this tutorial, we will:

Deploying the Smart contract from our template

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)
})

Transferring your first token

You will need the following information:

  • Wallet: the signer wallet
  • To: the wallet receiving your transfer
  • Amount: amount to transfer
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)
})

Congratulations! You've transferred your first token.

· 4 min read
Loubna Benzaama

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.

In this tutorial, we will:

Deploying the Smart contract from our template

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)
})

Congrats on deploying your smart contract.

Process your first token transfer

You will need the following information:

  • Wallet: the signer wallet
  • To: the wallet receiving your transfer
  • Amount: amount to transfer
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)
})

Congratulations! You've transferred your first token.

· 4 min read
Loubna Benzaama

In this tutorial, we’ll use Starton Connect to create our own crypto token!

We will deploy a smart contract directly from code using the Relayer.

The contract will be an instance of an audited premade template available in Starton.

The language used will be Javascript but any language would work in a similar manner.

Get the list of available templates

Before deploying our contract let's get the list of templates in order to find one that suits our need.

To do this, we’ll need to query Connect’s API and to authenticate ourselves using an API key.

We can create an API key from the dashboard in the Developer section. Using this API key we can call the API with the following JS code:

const axios = require("axios")

const http = axios.create({
baseURL: "https://api.starton.com/v3",
headers: {
"x-api-key": "YOUR_API_KEY",
},
})
http.get("/smart-contract-template").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.

Choose a Network and fuel wallet

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.

Deploying the contract

Everything is now in place so we can create an instance of the smart contract template we picked.

We’ll use the ID of the template we got in order to tell Deploy which template to use for the contract creation.

We also need to provide values for the parameters of our smart contract’s constructor.

For our ERC20, we’ll need to provide:

  • a name for our token
  • a ticker
  • the initial supply

Let’s call our token the DemoToken, with DEMO as its ticker and an initial supply of 1.000.000 tokens.

Here is the code to deploy the contract (Axios being configured as before):

http.post("/smart-contract/from-template", {
network: "ethereum-sepolia",
templateId: "ERC20_META_TRANSACTION",
name: "DemoToken",
description: "Our own crypto token.",
params: ["1000000", "DemoToken", "DEMO"],
}).then((response) => {
console.log(response.data)
})

The expected result:

{
"id": "sc_24dce9e26a7d46a7b707e257a6a6cfb2",
"name": "DemoToken",
"description": "Our own crypto token.",
"network": "ethereum-sepolia",
"bytecode": " … ",
"abi": ["..."],
"projectId": "prj_f2108b28949d47898a39939cbc7277c3",
"address": "0xDA96a733ec2C3eC1142A5A1Ef31cfd7755CAE037",
"creationHash": "0xef4313209959d6441e14db5d43905f674a78adba2173b522b7fe37311e135c05",
"createdAt": "Tue Jun 29 2021 13:09:17 GMT+0000 (Coordinated Universal Time)",
"updatedAt": "Tue Jun 29 2021 13:09:17 GMT+0000 (Coordinated Universal Time)"
}

If it worked, congrats! You just created your own crypto token in a few minutes and with a minimal amount of code.

Checking the contract creation

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.

Result

Or more generally, we can use the address of the contract to find out how it interacted with the world.

Congratulations for completing this tutorial!

You can also deploy your smart contract from our web application.

· 5 min read
Loubna Benzaama

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:

Step 1 - Initialize the project

  1. Start by creating a directory for your project:

    mkdir starton-deploy
  2. Then, get into your project directory:

    cd starton-deploy
  3. With your project directory set up, install the dependencies:

    npm add axios
  4. Then, usetouch to create a index.js file and open it with your favorite editor.

    touch list.js

Step 2 - Add starton to your project

  1. First, import axios.

    const axios = require("axios")
  2. Then, initialize axios using Starton URL and authenticate with your API KEY.

    Create an API key


       const starton = axios.create({
    baseURL: "https://api.starton.com",
    headers: {
    "x-api-key": "YOUR API KEY",
    },
    })

Step 3 - Creating a wallet

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.

  1. From Dashboard, go to Wallet.
  2. Click + Wallet.


Faucet

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.

Step 4 - Deploy your ERC20 token

Starton Library

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:

Almost done! Now we can execute it to get our first contract deployed!

node list.js

And voilà, your first contract is deployed!

{
"transactionHash": "0x43462af8448e34ea5cddbb73b4dcf5c0c04fa6155111273a1573ec6c4c9a59e8",
"smartContractAddress": "0xB4B4a180f065b2461eF64359909fb0cfCb04D986",
"explorer": "https://testnet.bscscan.com/tx/0x43462af8448e34ea5cddbb73b4dcf5c0c04fa6155111273a1573ec6c4c9a59e8"
}

Check all of your transactions on Starton Web Application



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.

What's next?

Learn how to:

· 9 min read
Loubna Benzaama

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).
  • Deploy it with Starton from the dashboard. To deploy contracts from code, see Deploying a smart contract from code.
  • Upload the content of our NFTs and their metadata on IPFS.
  • Interact with our smart contract using Starton API in order to mint the NFTs and give it to a specific address.

If you feel stuck or have questions, feel free to get in touch in our Discord. We’ll be glad to help you!

Upload the contract level metadata on IPFS

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.

  1. Go to IPFS.
  2. Click Upload.
  3. Select JSON.
  4. Enter JSON content.
  5. Enter a name for the file.
  6. 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!

Choose a smart contract template

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.

Deploy the contract with Starton

We will deploy the contract only once, so we will do it directly from Starton’s dashboard.

We can access the list of templates in the Smart contract section.

  1. Select the ERC721 template.
  2. Enter:
    • a name for your contract,
    • a wallet to sign the transaction,
    • 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.

Minting an NFT

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.

Minting an NFT from code

You will see next how to upload dynamically our images on IPFS from code with the API.

Prepare our connection to the Starton API

const axios = require("axios")
const FormData = require("form-data")
const starton = axios.create({
baseURL: "https://api.starton.com/v3",
headers: {
"x-api-key": "YOUR_STARTON_API_KEY",
},
})

caution

Do not forget the replace the x-api-key value by your own! It is needed to authenticate yourself with our API.

You can find your API keys and generate new ones in the API section.

Upload an image on IPFS with the Starton API

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
async function uploadImageOnIpfs(image, name) {
let data = new FormData()
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.

Upload the metadata json of our NFT

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:

async function uploadMetadataOnIpfs(imgCid) {
const metadataJson = {
name: `A Wonderful NFT`,
description: `Probably the most awesome NFT ever created !`,
image: `ipfs://ipfs/${imgCid}`,
}
const ipfsMetadata = await starton.post("/ipfs/json", {
name: "My NFT metadata Json",
content: metadataJson,
isSync: true,
})
return ipfsMetadata.data
}

Feel free to change the name and description that suit your needs.

Mint the NFT on the smart contract using the metadata’s CID

Finally, we can call our smart contract “mint” function with the receiver’s address and the CID of the metadata we just uploaded:

const SMART_CONTRACT_NETWORK = "binance-testnet"
const SMART_CONTRACT_ADDRESS = ""
const WALLET_IMPORTED_ON_STARTON = ""
async function mintNft(receiverAddress, metadataCid) {
const nft = await starton.post(`/smart-contract/${SMART_CONTRACT_NETWORK}/${SMART_CONTRACT_ADDRESS}/call`, {
functionName: "mint",
signerWallet: WALLET_IMPORTED_ON_STARTON,
speed: "low",
params: [receiverAddress, metadataCid],
})
return nft.data
}

You will need to modify the SMART_CONTRACT_ADDRESS and WALLET_IMPORTED_ON_STARTON variables so they match your contract and your wallet.

Assemble everything to complete the flow

We can now make the complete flow in only a few lines of code.

Notice that you need to define the receiver of the NFT and set the imgBuffer variable.

const RECEIVER_ADDRESS = ""
const imgBuffer = ""
const ipfsImg = await uploadImageOnIpfs(imgBuffer, "filename.png")
const ipfsMetadata = await uploadMetadataOnIpfs(ipfsImgData.cid)
const nft = await mintNft(RECEIVER_ADDRESS, ipfsMetadata.cid)

Results

Annnnnd it’s done! Congratulations!

Once all of this is executed, the content should be on IPFS, and associated to the given address in our ERC721 contract.

You can check our NFT on the market element marketplace. Use your contract address to modify the following link: https://testnets.element.market/assets/bsctest/YOUR_CONTRACT_ADDRESS/0

Conclusion

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!

· 9 min read
Loubna Benzaama

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).
  • Deploy it with Starton from the dashboard. To deploy contracts from code, see Deploying a smart contract from code.
  • Upload the content of our NFTs and their metadata on IPFS.
  • Interact with our smart contract using Starton API in order to mint the NFTs and give it to a specific address.

If you feel stuck or have questions, feel free to get in touch in our Discord. We’ll be glad to help you!

Choose a smart contract template

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.

Deploy the contract with Starton

We will deploy the contract only once, so we will do it directly from Starton’s dashboard.

We can access the list of templates in the Smart contract section.

  1. Select the ERC721 template.
  2. Enter:
  • a name for your contract,
  • a wallet to sign the transaction,
  • a blockchain / network on which to deploy,
  • 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.

Upload the contract level metadata on IPFS

We need to implement OpenSea’s specification the contract level metadata.

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.

Minting an NFT

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.

Prepare our connection to the Starton API

const axios = require("axios")
const FormData = require("form-data")

const starton = axios.create({
baseURL: "https://api.starton.com/v3",
headers: {
"x-api-key": "YOUR_STARTON_API_KEY",
},
})

Do not forget to replace the x-api-key value by your own! It is needed to authenticate yourself with our API.

You can find your API keys and generate new ones in the API section.

Upload an image on IPFS with the Starton API

We can create a simple function like this one:

// The image variable should be a buffer
async function uploadImageOnIpfs(image, name) {
let data = new FormData()
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.

Upload the metadata json of our NFT

Consult the metadata standard format on OpenSea documentation. We can define a new function using our image’s CID to upload the metadata on IPFS:

async function uploadMetadataOnIpfs(imgCid) {
const metadataJson = {
name: `A Wonderful NFT`,
description: `Probably the most awesome NFT ever created !`,
image: `ipfs://ipfs/${imgCid}`,
}
const ipfsMetadata = await starton.post("/ipfs/json", {
name: "My NFT metadata Json",
content: metadataJson,
isSync: true,
})
return ipfsMetadata.data
}

Feel free to change the name and description that suit your needs.

Mint the NFT on the smart contract using the metadata’s CID

Finally, we can call our smart contract “mint” function with the receiver’s address and the CID of the metadata we just uploaded:

const SMART_CONTRACT_NETWORK = "polygon-amoy"
const SMART_CONTRACT_ADDRESS = ""
const WALLET_IMPORTED_ON_STARTON = ""

async function mintNft(receiverAddress, metadataCid) {
const nft = await starton.post(`/smart-contract/${SMART_CONTRACT_NETWORK}/${SMART_CONTRACT_ADDRESS}/call`, {
functionName: "mint",
signerWallet: WALLET_IMPORTED_ON_STARTON,
speed: "low",
params: [receiverAddress, metadataCid],
})
return nft.data
}

You will need to modify the SMART_CONTRACT_ADDRESS and WALLET_IMPORTED_ON_STARTON variables so they match your contract and your wallet.

Assemble everything to complete the flow

We can now make the complete flow in only a few lines of code.

Notice that you need to define the receiver of the NFT and set the imgBuffer variable.

const RECEIVER_ADDRESS = ""
const imgBuffer = ""

async function uploadMint() {
const ipfsImg = await uploadImageOnIpfs(imgBuffer, "filename.png")
const ipfsMetadata = await uploadMetadataOnIpfs(ipfsImgData.cid)
const nft = await mintNft(RECEIVER_ADDRESS, ipfsMetadata.cid)
}

Annnnnd it’s done! Congratulations!

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.

Conclusion

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.