Skip to content

Remix ERC20 default contract compiles to too large initcode size #233

@Tomen

Description

@Tomen

The default ERC20 contract template provided in Remix does not deploy when compiled as-is.

Image

Repro

  1. Visit https://remix.polkadot.io/
  2. Click on the big fat "ERC20" button on the start screen
  3. Select "MyToken.sol" in file explorer
  4. Click "Compile"
  5. Open "Deploy" menu
  6. Click "Deploy"
  7. Sign the tx

Error

creation of MyToken errored: Error occurred: the initcode size of this transaction is too large: it is 82059 while the max is 49152.

the initcode size of this transaction is too large: it is 82059 while the max is 49152

You may want to cautiously increase the gas limit if the transaction went out of gas.

Discussion

Apparently the ERC20Permit extension is too heavy to be compiled into the contract. Removing the import and extension bit makes the contract deploy.

Reducing the code to this works:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    constructor() ERC20("MyToken", "MTK") {}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions