> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tavchain.safeney.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Write and test a contract

> Create and compile a Solidity Greeter in Remix with the Tavchain tutorial settings, ready for deployment through an EVM wallet.

Build a small Solidity contract in [Remix](https://app.remix.live/), then deploy it with MetaMask on Tavchain Testnet. You do not need a node, terminal or private-key export for this browser workflow.

## Before you begin

Use a desktop browser with MetaMask installed. [Add Tavchain Testnet](https://docs.tavchain.safeney.com/tavchain/connect.md) and obtain [Test TAV](https://docs.tavchain.safeney.com/tavchain/faucet.md). Keep your seed phrase and private key inside your wallet.

## Create Greeter

Open Remix's file explorer, create `Greeter.sol` at the root of your workspace and paste the example below. It starts with `Hello`, lets anyone change the greeting and emits an event for each change. It is a demonstration contract with no ownership restriction.

```solidity Greeter.sol theme={null}
pragma solidity 0.8.21;

contract Greeter {
    string public greeting;

    event ChangeGreeting(address from, string value);

    constructor() public {
        greeting = "Hello";
    }

    function setGreeting(string memory _greeting) public {
        greeting = _greeting;
        emit ChangeGreeting(msg.sender, _greeting);
    }

    function greet() public view returns (string memory) {
        return greeting;
    }
}
```

Solidity reports warnings for this example's missing SPDX identifier and ignored constructor visibility; neither is a compilation error. This simple demonstration is not an audited application or a contract for holding funds.

## Compile Greeter

In **Solidity Compiler**, select:

| Setting | Value |
| - | - |
| Compiler | `0.8.21+commit.d9974bed` |
| Language | Solidity |
| EVM version | Shanghai |
| Optimization | Enabled |
| Runs | 200 |

Open **Advanced Configurations** to find the EVM target and optimizer. Click **Compile Greeter.sol**, then select **Greeter** in the contract selector. Resolve any compilation errors before continuing.

Retain the source, compiler settings, ABI and bytecode. Keep the original Standard JSON compiler input when your build produces it; it can be used for [source verification](https://docs.tavchain.safeney.com/tavchain/verify-contract.md). Changing the source filename can change Solidity's metadata and full bytecode even when the executable logic is unchanged.

## Continue to deployment

Follow [deploy and interact](https://docs.tavchain.safeney.com/tavchain/deploy-token.md) to connect MetaMask, deploy once and read `Hello`. You can then make the optional `Hello Tavchain` update and [verify the source](https://docs.tavchain.safeney.com/tavchain/verify-contract.md).

The [verified Greeter example](https://explorer.tavchain.safeney.com/address/0x065c1c017b8EF74f3B6001b51d188665bA9f4cd1?tab=contract) uses this source as `Greeter.sol` with the settings above. Use your own deployment for a predictable initial greeting.

Use the compiler and EVM settings above for this example. Check compatibility before changing compiler versions or targeting a different EVM revision.

## Related guides

* [EVM contract workflow](https://docs.tavchain.safeney.com/tavchain/contracts.md)
* [Network settings](https://docs.tavchain.safeney.com/tavchain/network.md)
* [Transaction receipts](https://docs.tavchain.safeney.com/tavchain/api/transaction.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.