Skip to main content

3 posts tagged with "crypto "

View All Tags

· 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: