Documentation for eth_defi.token.create_token function.

create_token(web3, deployer, name, symbol, supply, decimals=18)[source]

Deploys a new ERC-20 token on local dev, testnet or mainnet.

  • Uses ERC20Mock contract for the deployment.

  • Waits until the transaction has completed


# Deploys an ERC-20 token where 100,000 tokens are allocated ato the deployer address
token = create_token(web3, deployer, "Hentai books token", "HENTAI", 100_000 * 10**18)
print(f"Deployed token contract address is {token.address}")
print(f"Deployer account {deployer} has {token.functions.balanceOf(user_1).call() / 10**18} tokens")

Find more examples in Tutorials and unit testing source code.

  • web3 (web3.main.Web3) – Web3 instance

  • deployer (str) –

    Deployer account as 0x address.

    Make sure this account has enough ETH or native token to cover the gas cost.

  • name (str) – Token name

  • symbol (str) – Token symbol

  • supply (int) –

    Token starting supply as raw units.

    E.g. 500 * 10**18 to have 500 tokens minted to the deployer at the start.

  • decimals (int) – How many decimals ERC-20 token values have


Instance to a deployed Web3 contract.

Return type