ChainPortalChainPortal Docs
Features
Features

Contract Interaction

Interact directly with ChainPortal factory contracts for advanced use cases.

Direct Contract Interaction

For developers who want to interact with ChainPortal contracts directly (without the SDK or UI), this guide covers the factory contract ABIs, functions, and parameters.

EVM Factory Contracts

EVMEVM

ChainPortal deploys three factory contracts per EVM chain:

FactoryStandardDescription
ERC20FactoryERC-20Creates fungible tokens
ERC721FactoryERC-721Creates NFT collections
ERC1155FactoryERC-1155Creates multi-token collections

All factories use the Minimal Proxy Pattern (EIP-1167) for gas-efficient deployments.

Creating an ERC20 Token

function createToken(
    string memory name,
    string memory symbol,
    uint8 decimals,
    uint256 initialSupply,
    address owner,
    bool mintable,
    bool burnable,
    bool pausable,
    bool taxEnabled,
    uint256 buyTaxBps,    // basis points (100 = 1%)
    uint256 sellTaxBps,
    address taxRecipient,
    address referrer       // address(0) if no referral
) external payable returns (address tokenAddress);

Example with ethers.js:

import { ethers } from 'ethers';
 
const factory = new ethers.Contract(FACTORY_ADDRESS, ERC20_FACTORY_ABI, signer);
 
const tx = await factory.createToken(
  'My Token',        // name
  'MTK',             // symbol
  18,                // decimals
  ethers.parseUnits('1000000', 18), // initialSupply
  signer.address,    // owner
  true,              // mintable
  true,              // burnable
  false,             // pausable
  false,             // taxEnabled
  0,                 // buyTaxBps
  0,                 // sellTaxBps
  ethers.ZeroAddress, // taxRecipient
  ethers.ZeroAddress, // referrer
  { value: await factory.creationFee() }
);
 
const receipt = await tx.wait();
// Token address is in the TokenCreated event

Example with viem:

import { writeContract, parseUnits } from 'viem';
 
const hash = await writeContract(walletClient, {
  address: FACTORY_ADDRESS,
  abi: ERC20_FACTORY_ABI,
  functionName: 'createToken',
  args: [
    'My Token', 'MTK', 18,
    parseUnits('1000000', 18),
    ownerAddress,
    true, true, false, false,
    0n, 0n,
    '0x0000000000000000000000000000000000000000',
    '0x0000000000000000000000000000000000000000',
  ],
  value: creationFee,
});

Creating an ERC721 Collection

function createCollection(
    string memory name,
    string memory symbol,
    string memory baseURI_,
    uint256 maxSupply,
    uint256 mintPrice,
    uint96 royaltyBps,
    address royaltyRecipient,
    address owner,
    address referrer
) external payable returns (address collectionAddress);

Creating an ERC1155 Collection

function createCollection(
    string memory uri,
    string memory name,
    address owner,
    uint96 royaltyBps,
    address royaltyRecipient,
    address referrer
) external payable returns (address collectionAddress);

Reading Factory State

// Get the creation fee
function creationFee() external view returns (uint256);
 
// Get all tokens created by an address
function getTokensByCreator(address creator) external view returns (address[] memory);
 
// Get total number of tokens created
function totalTokens() external view returns (uint256);

Events

event TokenCreated(
    address indexed token,
    address indexed creator,
    string name,
    string symbol
);
 
event CollectionCreated(
    address indexed collection,
    address indexed creator,
    string name
);

Fee Structure

All factory contracts charge a creation fee. The fee is:

  • Paid in the chain's native token (ETH, MATIC, BNB, etc.)
  • Configurable by the factory owner
  • Discounted when using a valid referral address

Referral Discounts:

TierReferralsDiscount
Bronze1-95%
Silver10-4910%
Gold50-9915%
Platinum100-49920%
Diamond500+25%

Post-Creation Token Management

After creation, tokens support these management functions:

ERC20 (if features enabled)

// Minting (if mintable)
function mint(address to, uint256 amount) external;
 
// Burning (if burnable)
function burn(uint256 amount) external;
 
// Pausing (if pausable)
function pause() external;
function unpause() external;
 
// Tax management (if tax enabled)
function setBuyTax(uint256 bps) external;
function setSellTax(uint256 bps) external;
function setTaxRecipient(address recipient) external;
 
// Anti-bot (timelock-protected)
function queueAntiBotConfig(AntiBotConfig calldata config) external;
function applyAntiBotConfig() external;
function cancelAntiBotConfig() external;
 
// Ownership
function transferOwnership(address newOwner) external;
function renounceOwnership() external;

ERC721

// Minting
function mint(address to, uint256 quantity) external payable;
function ownerMint(address to, uint256 quantity) external;
 
// Mint phases
function setMintPhase(uint8 phase) external; // 0=closed, 1=whitelist, 2=public
 
// Whitelist
function addToWhitelist(address[] calldata addresses) external;
function removeFromWhitelist(address[] calldata addresses) external;
 
// Metadata
function setBaseURI(string memory baseURI_) external;
function setMintPrice(uint256 price) external;
 
// Royalties (EIP-2981)
function setDefaultRoyalty(address receiver, uint96 feeNumerator) external;

Contract Addresses

Factory addresses for each chain are available in the SDK config package:

import {
  getERC20FactoryAddress,
  getERC721FactoryAddress,
  getERC1155FactoryAddress,
  getAirdropAddress,
} from '@chainportal/config';
 
const erc20Factory = getERC20FactoryAddress(chainId);
const erc721Factory = getERC721FactoryAddress(chainId);

See Supported Chains for the full list of deployed chain IDs.


Verification

All factory-deployed contracts can be verified on block explorers. ChainPortal provides a source verification API to auto-verify your deployed contracts on Etherscan and compatible explorers.

On this page

Edit on GitHub