Guides

Compile and deploy

Write a contract in conversation, compile it with solc-mcp, and deploy it from your wallet.

You'll need solc-mcp and metamask-mcp enabled, a connected wallet, and some Sepolia ETH for gas.

Deploy a contract#

prompt
Write a Greeter contract whose greeting can be updated, and deploy it on Sepolia with the greeting "gm".
  1. Write the source

    The agent writes the Solidity itself, or uses yours. For example:

    Greeter.sol
    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.20;
    
    contract Greeter {
        string public greeting;
    
        constructor(string memory initial) {
            greeting = initial;
        }
    
        function setGreeting(string calldata next) external {
            greeting = next;
        }
    }
  2. Compile

    compile-solidity takes a fileName ending in .sol and the content, and returns each contract's abi, bytecode and compilerVersion. If the code doesn't compile, it returns the compiler's errors, and the agent can fix the source and try again.

  3. Deploy from your wallet

    deploy-contract on metamask-mcp takes the abi, the bytecode and the constructor args, here ["gm"]. MetaMask asks you to confirm the deployment.

  4. Get the address

    wait-for-transaction-receipt returns the receipt. The new contract's address is in its contractAddress field.

Tip. Once deployed, the agent can use read-contract to read greeting for free, and write-contract to call setGreeting, which asks for your signature.

Launch an ERC-20 token#

erc20-mcp includes a shortcut for tokens:

  1. Generate the contract

    The generate-erc20-contract prompt asks the agent to write an ERC-20, using a Solmate-based contract as its example.

  2. Compile it

    Compile with compile-solidity as above.

  3. Prepare the deployment

    prepare-deploy-erc20-contract takes the bytecode, name, symbol and decimal, and returns prepareForAction: "deploy-contract" with the ABI and constructor arguments filled in.

  4. Deploy and mint

    Deploy with deploy-contract, then use prepare-mint and send-transaction to mint the first supply. Each step asks for your signature.

Important. The example contract's mint function is public with no access control, so anyone can mint tokens once it's deployed. That's fine for a Sepolia test. For a real token, ask the agent to restrict mint to an owner, or remove it, before you deploy.