thirdweb

Token module

Published on:

February 15, 2022

An ERC-20 standard token that enables you to create your own crypto token or currency

In a nutshell

The Token module is suited for projects in which you want to create your own currency. This currency can be purchased and traded between users on an exchange, utilized to buy and sell NFTs in a marketplace, and much more.

This can be combined with other contracts like NFT Drop , Splits , Bundle Drop , and Marketplace for even greater functionality.

The Token module is a smart contract, which is compliant with the ERC20 standard. A thirdweb module is actually more than just a smart contract.

Click here to learn more about modules and how to create them.

The settings

The following settings can be adjusted, when you create an Token module:

  • Name
  • Description
  • Image
  • Symbol (used to publicly identify your token)

What can you do with our module?

The following use cases are suited for the Token module

  1. Offering the sale of a token or currency in your own marketplace or another exchange
  2. Enable users to buy and sell NFTs within your marketplace
  3. Give your community a share of voice using governance tokens
  4. Restricted transfer (check out this use case with Bundle Drop here)
  5. Wrapping and unwrapping tokens along with the Bundle module

How it works

You can create your own token using the dashboard or SDK. When you mint tokens, the connected wallet pays for the gas fees. If you mint it via the dashboard, your wallet pops up to confirm the transactions. If you mint via code, you won't see this explicit request to authorize the transaction.

Once you've successfully minted your tokens, you can see the tokens in your dashboard or with the print/call function using the SDK.

How to use the module

You can use the Token module with or without code:

  1. TypeScript
  2. Python
  3. Dashboard Embed (our no-code solution)

Setup your dev environment

To interact with your Token with code, you need to follow 3 steps:

  1. Install the necessary packages on your (local) machine
    1. Ethers on typescript
    2. Dotenv / virtual-env
    3. Typescript / Python
    4. tslib when using Typescript
  2. Instantiate the SDK
  3. Passing the address of the Module inside your code

To install the necessary packages for TypeScript or Python on your (local) machine and instantiate the SDK in your code, check out this guide to help you with that. Note, you can instantiate the SDK in multiple ways, so make sure to check out that guide.

You can find the module address in the thirdweb dashboard, inside your project or inside the Token itself.

Module addresses

Module addresses

In order to make use of our SDK, you need to establish a connection to a blockchain. Click here to learn how to connect to the blockchain and instantiate our SDK.

For this guide, you will need to instantiate the SDK following these steps, using your own signer with thirdweb.

Here's an example of doing this in TypeScript👇

// Instantiate Token module const token = sdk.getTokenModule("0x74846071E984C0039c597b0f3975814d111eF5F6"); // Set the amount of currency you want to mint // (Actual amount, number of decimals) const amount = ethers.utils.parseUnits("1000", 18); // Minting the currency, 1000 Pratham coin async function mintCurrency() { console.log(await token.mint(amount)); } // Running the entire thing mintCurrency();

And here is one in Python 👇

#pick your module and enter the smart contract address token_module = sdk.get_currency_module("<TOKEN_MODULE_ADDRESS>") #blockchain converts numbers with 18 decimals input_amount = 1000 converted_amount = amount* (10**18) #mint the token token_module.mint(converted_amount)

Code Guide

  1. You can find code snippets for every method in our portal here.
  2. To check out guides for this module click here.
  3. To setup your local dev environment, click here.

Ready to build your first web3 app? Get early access & add web3 features to your project today.

Contents

In a nutshell

The settings

What can you do with our module?

How it works

How to use the module

Setup your dev environment

Code Guide