Search
⌃K
Links

Create your Fungible Token

MetaMask, a widely adopted Ethereum wallet, enables users to manage their Ether and ERC-20 tokens while providing a convenient interface for interacting with decentralized applications (dApps) and smart contracts. With the increasing significance of fungible tokens in the digital asset landscape, MetaMask offers a simple and accessible way to create your own ERC-20 token contract, opening the door to numerous possibilities and benefits.

Why create an ERC-20 token contract?

Fungible tokens like ERC-20 tokens are digital assets that can be exchanged on a one-to-one basis, making them an ideal choice for various applications, such as:
  • Creating a digital currency for your project or platform
  • Launching an initial coin offering (ICO) or token sale event
  • Developing a reward or loyalty program for your business
  • Establishing a decentralized governance system for your community
MetaMask is designed as a browser extension to provide a user-friendly interface and secure key management for interacting with dApps and web services. Connecting from Node.js is not supported because MetaMask focuses on end-user interactions within web browsers, while Node.js is a server-side JavaScript runtime typically used for backend development.

How to create your Fungible token with MetaMask from your browser-based application

Use the TatumSDK (@tatumio/tatum) to prepare, sign and broadcast the transaction using MetaMask.
You will leverage the WalletProvider submodule, which includes multiple browser-based wallet extensions. MetaMask is just one of them.
TypeScript
JavaScript
1
// yarn add @tatumio/tatum
2
import {TatumSDK, Network, Ethereum} from '@tatumio/tatum'
3
​
4
const tatum = await TatumSDK.init<Ethereum>({network: Network.ETHEREUM})
5
​
6
// We have prepared a deploy transaction of ERC-20 contract from your default connected MetaMask account to the recipient
7
// Result is a transaction IF of a broadcasted transaction
8
const txId: string = await tatum.walletProvider.metaMask.createFungibleToken({
9
name: 'Your Token Name',
10
symbol: 'Your Token Symbol',
11
decimals: 18,
12
initialSupply: 1_000_000})
13
​
14
console.log(txId)
15
​
16
// Once the transaction is included in a block, you can get the contract address of the newly created collection
17
const contractAddress: string | null = await tatum.rpc.getContractAddress(txId)
18
console.log(contractAddress)
1
// Install with: npm install @tatumio/tatum
2
const { TatumSDK, Network } = require("@tatumio/tatum");
3
​
4
(async () => {
5
try {
6
const tatum = await TatumSDK.init({ network: Network.ETHEREUM });
7
// We have prepared a deploy transaction of ERC-20 contract from your default connected MetaMask account to the recipient
8
// Result is a transaction IF of a broadcasted transaction
9
const txId = await tatum.walletProvider.metaMask.createFungibleToken({
10
name: 'Your Token Name',
11
symbol: 'Your Token Symbol',
12
decimals: 18,
13
initialSupply: 1_000_000})
14
15
console.log(txId);
16
17
// Once the transaction is included in a block, you can get the contract address of the newly created collection
18
const contractAddress: string | null = await tatum.rpc.getContractAddress(txId)
19
console.log(contractAddress)
20
} catch (error) {
21
console.error("Error signing a transaction using MetaMask:", error);
22
}
23
})();

Request object parameters

1
export interface CreateFungibleToken {
2
/**
3
* Name of the token.
4
*/
5
name: string
6
/**
7
* Symbol of the token.
8
*/
9
symbol: string
10
/**
11
* Number of decimals of the token. Defaults to 18.
12
*/
13
decimals?: number
14
/**
15
* Total supply of the token.
16
*/
17
initialSupply: string
18
/**
19
* (Optional) Address of the initial holder of the token. Defaults to the connected MetaMask account.
20
*/
21
initialHolder?: string
22
/**
23
* (Optional) Address of the admin of the token. Defaults to the connected MetaMask account. Admin can add new minters and pausers.
24
*/
25
admin?: string
26
/**
27
* (Optional) Address of the minter of the token. Defaults to the connected MetaMask account. Minters can mint new tokens.
28
*/
29
minter?: string
30
/**
31
* (Optional) Address of the pauser of the token. Defaults to the connected MetaMask account. Pausers can pause and unpause the token transactions.
32
*/
33
pauser?: string
34
}
35
​

Response

  • txId - string, transaction hash of signed and broadcasted transaction
    • Example: "0xdb1e03f4cea29265f031bfc0514b07c15a5fc5e5cc2fd47f7d9a54c74f5c5637"
© Tatum Technology, LLC