Skip to main content

2 posts tagged with "GETTING STARTED"

View All Tags

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

· 5 min read
Loubna Benzaama

With Starton, you can monitor blockchain activity using watchers. Whether it's to watch the activity of a wallet or a smart contract, you can create watchers, triggered by events.

not a developer?

To follow this tutorial, you will need coding experience. If it's not your case, you can still create a watcher:

Step 1 - Initialize the project

  1. Start by creating a directory for your project.

    mkdir monitor-blockchain
  2. Then, get into your project directory.

    cd monitor-blockchain
  3. With your project directory set up, install the dependencies.

    npm add axios

This library will allow you to make request to the Starton API. For more information on axios, check out Axios documentation.

  1. 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 watcher

What is a Watcher?

A watcher is a powerful tool that lets you monitor blockchain events in real-time. With Starton, you can set up watchers to monitor activities such as address activities, balance changes, or even smart contract events.

  1. Set up the watcher parameters

    // Let's create your watcher
    starton
    .post("/v3/watcher", {
    name: "Name of your watcher",
    type: "ADDRESS_ACTIVITY",
    address: "0x000000000000",
    network: "polygon-amoy",
    webhookUrl: "https://xxxxxxx/",
    confirmationsBlocks: 50,
    })
    .then((response) => {
    console.log(response.data)
    })
    .catch((error) => console.error(error.response.data))

    Let's go through the parameters provided to create a watcher:

    • name: This field specifies the name of your watcher. Useful for identification purposes, especially if you have multiple watchers set up for the same address or contract at different confirmation speeds different confirmation speeds.
    • type: The type of blockchain event that you want the watcher to monitor. The ADDRESS_ACTIVITY type, in this context, means the watcher will monitor and notify of any activity related to the provided address but Starton provides you with a list of events as well as the possibility to watch events from your own custom contract .
    • address: This is the specific blockchain address you want to monitor. It can be a wallet address or a smart contract address, depending on the event type you chose.
    • network: This specifies the blockchain network on which is the given address. In the provided example, polygon-amoy refers to the amoy testnet of the Polygon (previously known as Matic) network. For more, see Supported Networks.
    • webhookUrl: This URL is where the notifications will be sent when the watched event occurs. Essentially, once the watcher detects the specified event on the blockchain, it will send an HTTP POST request to this URL with details of the event. You can use https://webhook.site/ or test a webhook on your local environment using ngrok.
    • confirmationsBlocks: This is the number of confirmed blocks before an event triggers the watcher. It's a safety measure to ensure that the event (like a transaction) is well-confirmed on the blockchain and is not likely to be reversed. The higher the number, the more confirmations are required, and vice versa. Each network has its own default confirmation blocks number, for more information, see Understanding confirmation blocks.
  2. Almost done! Now we can execute it to get our first watcher!

    node list.js

And just like that, your first watcher is now live on Starton!


Check all triggered events on Starton Web Application



Congratulations on creating your first watcher! In this tutorial, you discovered how to monitor blockchain activity but this is only the first step.

What's next?

Learn how to: