Metamask: How can I send a custom token with web3? [duplicate]

Custom Marker Sending with Web3: Step by Step

As a developer who worships Web3, you are like the basics of intraactation with smart contracts and decentric applications (DAPP). However, one important aspect that is considered is to users shipping custom markers. In this article, we will look at how to send a customs marker to the Web3 and show the example of the sample.

What is Web3?

Before diving into the code, let’s have time web3. Web3 reference to them with a wide range of ecosystem blockchain technologies that are the most important decent applications (DAPP). These include cryptocurrency such as Ethereum, ERC-20 markers and others. In this article we focus on the correct web3.You.

Custom marker basics

A custom marker is the type or digital type of cryptocurrency or organization. Token currency, flexible and use are unique to its creators.

Custom Marker Sending with Web3: Step by Step

Here is a step in the step to send a custom marker using the Web3.JS:

Metamask: How can I send a custom token with web3? [duplicate]

1. Step: Place the required packages

First, make sure you have installed the Web3 in the project. You can only join yarns:

`bash

NPM install Web3

Or use yarn:

`bash

yarn add web3

2. Step: Set your Web3 Service Provider

In this example, we will use the infura service provider on the Western Ethereum network. You may have a free account [infura] ( and repance https: // Maine.

Step 3: Create a custom marker

Create a new file like

Javacript

Const web3 = ask ('web3');

Const Web3 = New Web3 (new Web3.Providers.httpprovider ('hnow.infura.io/v3/your_project_id'));

// Create a customs marker with a unique symbol, address and balance

CONST CUSTOMTOKEN = {

Symbol: 'my_token',

Inner: '0xyourokenaddress',

Balance: Web3.eth.GetBalance ('0xyourokenaddress'),

};

module.exports = customtoken;

This example is a custom with a unique symbol (“My_Token”), an associated transaction (0xyourokenaddress") and the original balance.

4. Step: send them custom markers

Now we will not be able to customs markers on another zer:

Javacript

// Get the recipient Ethereum donation to your wall or third party service

Const recipaddress = '0xrecipientaddress';

// Define Amont tokens you want to transfer (Wei)

Const Amun = Web3.Towei.Towei (amontpurchase, 'ether');

// CallMethods of Transfer to Marker Object

Customtoken.transfer (Seartantaddress, Amunt);

// If this is a different massage, print it

Console.Error (‘Error sending a custom marker:’, customtoken);

`

This is what you call the “transfer” methods that are the first to do its best. Summpurchase variable denotes the amont tokens you want to transform.

Example of use of use:

Let's say you have created a custom called "Ethereum" and want 10 units. YOUT YOUSE steps:

  • Create a new file likeEthereum.Js’, and define your ethereum adddress:

`Javacript

Const web3 = ask ('web3');

Const Web3 = New Web3 (new Web3.Providers.httpprovider ('hnow.infura.io/v3/your_project_id'));

module.exports = 'your_thereum_address';

  • Send customs markers to another with your Ethereum Adddress:

“ Javacript

// Get the recipient Ethereum donation to your wall or third party service

Const recipaddress = ‘0xrecipientaddress’;

// Define Amont tokens you want to transfer (Wei)

Const Amunpurchase = 10;

Customtoken.

WITHDRAW WITHDRAW CRYPTO SAFELY

Artigos relacionados

Deixe o primeiro comentário