Deploying Smart Contracts

1. Create Foundry Project & Write Contracts

Install Foundry:

curl -L <https://foundry.paradigm.xyz> | bash
foundryup

Initialize a new project:

forge init memecore-contract-demo
cd memecore-contract-demo

Open the folder in your preferred IDE (e.g. VS Code), and create src/Counter.sol:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

contract Counter {
    uint256 public number;

    function setNumber(uint256 newNumber) public {
        number = newNumber;
    }
    function increment() public {
        number++;
    }
}

Compile:

Test code example test/Counter.t.sol:

Run tests:

2. Deploying Contracts and Checking Results

The following examples are based on MemeCore’s testnet, the Insectarium network.

Requirements

  • Your EOA (e.g. MetaMask) wallet must have M tokens and your private key is needed (for signing transactions and paying fees).

    • If you are connecting to a testnet, you can obtain tokens from the testnet faucet; If you are connecting to the mainnet, you will need to prepare the necessary funds separately.

  • Keep your private key secure and never expose it.

Deploying Contracts

Deployment command:

For example:

If you are connecting to the mainnet, please refer to the Mainnet RPC URL in the Memecore Network Information.

If a constructor takes arguments:

Checking Results

  • After running the deployment command, the contract address and transaction hash will be displayed in the console upon success.

  • You can search for the contract address on the Block Explorer (e.g. Insectarium Explorer) to view the contract code, transactions, and event logs.

3. Common Issues & Solutions

  • Network connection failure: Ensure the RPC URL and PRIVATE KEY are correct.

  • Insufficient gas: Make sure your deployment account (with M tokens) has sufficient balance.

  • Transaction failure/Compile error: Review your contract code, command options, and environment variables for potential problems.

Last updated