Create a fungible token
Creating a fungible token involves defining the parameters of the token, such as its name, symbol, and total supply, within a smart contract on a blockchain network like Ethereum. The distinguishing feature of fungible tokens, created using standards like ERC-20 or BEP-20, is their interchangeability. Each token is identical to the others in its set, meaning they can be exchanged on a one-for-one basis. This is in contrast to non-fungible tokens (NFTs), which are unique and not interchangeable, with each NFT representing a distinct asset or value.
Use the TatumSDK (
@tatumio/tatum
) to create the token.TypeScript
JavaScript
curl
1
// yarn add @tatumio/tatum
2
import { TatumSDK, Network, Ethereum, ResponseDto, TokenMetadata } from '@tatumio/tatum'
3
4
const tatum = await TatumSDK.init<Ethereum>({network: Network.ETHEREUM})
5
6
const result = await tatum.token.createNewFungibleToken({
7
name: 'Test Token',
8
symbol: 'MY_TKN',
9
initialHolder: '0x48fa1676cfd0dfa23a71829c4c6d56874a88fa48',
10
initialSupply: '1000000',
11
owner: '0x48fa1676cfd0dfa23a71829c4c6d56874a88fa48',
12
})
13
14
console.log(result)
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_SEPOLIA });
7
const result = await tatum.token.createNewFungibleToken({
8
name: 'Test Token',
9
symbol: 'MY_TKN',
10
initialHolder: '0x48fa1676cfd0dfa23a71829c4c6d56874a88fa48',
11
initialSupply: '1000000',
12
owner: '0x48fa1676cfd0dfa23a71829c4c6d56874a88fa48',
13
})
14
15
console.log(result.data);
16
} catch (error) {
17
console.error("Error fetching token metadata:", error);
18
}
19
})();
1
curl --location --request POST 'https://api.tatum.io/v4/contract/deploy?type=testnet' -H "Content-Type: application/json" -d '{"chain":"ethereum-sepolia","contractType":"fungible","name":"Test Token","symbol":"MY_TKN","initialHolder":"0x48fa1676cfd0dfa23a71829c4c6d56874a88fa48","initialSupply":"1000000","owner":"0x48fa1676cfd0dfa23a71829c4c6d56874a88fa48"}'
- Native Tokens for Platforms/Projects: For example, Binance Coin (BNB) is the native token of Binance, serving both as a cryptocurrency and a utility token within the platform. It's used for transaction fees, participating in new token sales, and more.
- Stablecoins: Tokens like USDT and USDC are examples of stablecoins, designed to maintain a stable value by being pegged to a reserve of assets, typically a fiat currency like USD. This provides stability in the volatile crypto markets.
- Governance Tokens: Governance tokens, such as Maker (MKR), grant voting rights within a Decentralized Autonomous Organization (DAO). Holders of these tokens can vote on key aspects of the project, influencing its direction and policies.
- Reward Tokens: Certain protocols, like Compound, use fungible tokens (in this case, COMP) as rewards to incentivise user engagement and participation within the platform. These tokens can also grant voting rights, enhancing the protocol's decentralised governance.
1
interface CreateFungibleToken {
2
/**
3
* Address of the fungible token owner
4
*/
5
owner: string
6
/**
7
* Optional. Address of the fungible token minter, it defaults to the owner address
8
*/
9
minter?: string
10
/**
11
* Optional. Address of the fungible token pauser, it defaults to the owner address
12
*/
13
pauser?: string
14
/**
15
* Name of fungible token
16
*/
17
name: string
18
/**
19
* Symbol of fungible token
20
*/
21
symbol: string
22
/**
23
* Initial supply of fungible token
24
*/
25
initialSupply: string
26
/**
27
* Initial holder of fungible token
28
*/
29
initialHolder: string
30
/**
31
* Optional. Number of decimal places for the fungible token, it defaults to 18
32
*/
33
decimals?: string
34
}
1
interface ResponseDto<T> {
2
/**
3
* Actual payload of the response
4
*/
5
data: T
6
/**
7
* Status of the response
8
*/
9
status: Status
10
/**
11
* In case of ERROR status, this field contains the error message and detailed description
12
*/
13
error?: ErrorWithMessage
14
}
15
16
interface TxIdResponse {
17
/**
18
* Id of the transaction
19
*/
20
txId: string
21
}
Network |
---|
Ethereum / Ethereum Sepolia / Ethereum Goerli
BNB Smart Chain / BNB Smart Chain Testnet
Celo / Celo Alfajores
Polygon / Polygon Mumbai |
Last modified 8d ago