> For the complete documentation index, see [llms.txt](https://satuchain.gitbook.io/satuchain-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://satuchain.gitbook.io/satuchain-docs/quick-start/deploy-your-contract-remix.md).

# Deploy Your Contract (Remix)

## Deploy Your First Contract (Remix)

This guide shows how to deploy a simple Solidity contract to **SATUCHAIN Testnet** using **Remix** and **MetaMask**.

### Requirements

* MetaMask connected to **SATUCHAIN Testnet**
  * Chain ID: **17081945**
  * RPC: [https://rpc-testnet.satuchain.com](https://rpc-testnet.satuchain.com/)
  * Explorer: [https://testnet.satuchain.com](https://testnet.satuchain.com/)
* Some **tSTU** for gas (claim from faucet): <https://faucet.satuchain.com/>
* Remix IDE: <https://remix.ethereum.org/>

### Step 1 — Create a Contract in Remix

1. Open Remix: <https://remix.ethereum.org/>
2. In the left sidebar, open **File Explorers**.
3. Create a new file: `Mytoken.sol`
4. Paste the contract below:

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

/**
 * Standart Token Satuchain
 * ERC20 Standard Token
 * NST
 */

contract MyToken {

    string public constant name     = "Mytoken"; // Change your name token
    string public constant symbol   = "MTK"; // Change your Symbol token
    uint8  public constant decimals = 18; // Change your name token

    uint256 private _totalSupply;

    address public owner;

    mapping(address => uint256)                     private _balances;
    mapping(address => mapping(address => uint256)) private _allowances;

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner_, address indexed spender, uint256 value);
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    modifier onlyOwner() {
        require(msg.sender == owner, "The Token: caller is not the owner");
        _;
    }

    constructor() {
        owner = msg.sender;

        uint256 initialSupply = 10_000_000 * (10 ** uint256(decimals)); // Change your supply
        _totalSupply          = initialSupply;
        _balances[msg.sender] = initialSupply;

        emit Transfer(address(0), msg.sender, initialSupply);
    }

    function totalSupply() public view returns (uint256) {
        return _totalSupply;
    }

    function balanceOf(address account) public view returns (uint256) {
        return _balances[account];
    }

    function allowance(address owner_, address spender) public view returns (uint256) {
        return _allowances[owner_][spender];
    }

    function transfer(address to, uint256 amount) public returns (bool) {
        _transfer(msg.sender, to, amount);
        return true;
    }

    function approve(address spender, uint256 amount) public returns (bool) {
        _approve(msg.sender, spender, amount);
        return true;
    }

    function transferFrom(address from, address to, uint256 amount) public returns (bool) {
        uint256 currentAllowance = _allowances[from][msg.sender];
        require(currentAllowance >= amount, "The Token: insufficient allowance");

        unchecked {
            _approve(from, msg.sender, currentAllowance - amount);
        }

        _transfer(from, to, amount);
        return true;
    }

    function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
        _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue);
        return true;
    }

    function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
        uint256 currentAllowance = _allowances[msg.sender][spender];
        require(currentAllowance >= subtractedValue, "The Token: decreased allowance below zero");
        unchecked {
            _approve(msg.sender, spender, currentAllowance - subtractedValue);
        }
        return true;
    }

    function burn(uint256 amount) public onlyOwner {
        require(_balances[msg.sender] >= amount, "The Token: burn amount exceeds balance");
        unchecked {
            _balances[msg.sender] -= amount;
            _totalSupply          -= amount;
        }
        emit Transfer(msg.sender, address(0), amount);
    }

    function transferOwnership(address newOwner) public onlyOwner {
        require(newOwner != address(0), "The Token: new owner is zero address");
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }

    function renounceOwnership() public onlyOwner {
        emit OwnershipTransferred(owner, address(0));
        owner = address(0);
    }

    function _transfer(address from, address to, uint256 amount) internal {
        require(from != address(0), "The Token: transfer from zero address");
        require(to   != address(0), "The Token: transfer to zero address");
        require(_balances[from] >= amount, "The Token: insufficient balance");

        unchecked {
            _balances[from] -= amount;
            _balances[to]   += amount;
        }

        emit Transfer(from, to, amount);
    }

    function _approve(address owner_, address spender, uint256 amount) internal {
        require(owner_   != address(0), "The Token: approve from zero address");
        require(spender  != address(0), "The Token: approve to zero address");
        _allowances[owner_][spender] = amount;
        emit Approval(owner_, spender, amount);
    }
}
```

### Step 2 — Compile the Contract

1. Open the **Solidity Compiler** tab (left sidebar).
2. Select compiler version **0.8.20** (or any 0.8.x that matches the pragma).
3. Click **Compile Storage.sol**.
4. Ensure there are no errors.

### Step 3 — Connect Remix to MetaMask (Injected Provider)

1. Open the **Deploy & Run Transactions** tab.
2. In **Environment**, select **Injected Provider - MetaMask**.
3. MetaMask will prompt you to connect Remix. Approve it.
4. Confirm MetaMask shows you are on **SATUCHAIN Testnet**.

### Step 4 — Deploy

1. In Remix, make sure the contract dropdown shows **Storage**.
2. Click **Deploy**.
3. MetaMask will pop up with the deployment transaction:
   * Review gas fee (paid in tSTU)
   * Click **Confirm**
4. Wait until the transaction is mined.

After success, the deployed contract appears under **Deployed Contracts** in Remix.

### Step 5 — Interact With the Contract

1. Expand the deployed **Storage** contract in Remix.
2. Call `get` to read the current value (default is `0`).
3. In `set`, enter a number (example: `123`) and click `set`.
4. Confirm the transaction in MetaMask.
5. Call `get` again to confirm the value changed.

### Step 6 — Verify on the Explorer

1. Copy the deployment transaction hash from MetaMask (or from Remix console).
2. Open the explorer: [https://testnet.satuchain.com](https://testnet.satuchain.com/)
3. Search the **Tx Hash** to confirm:
   * Status: Success
   * Contract creation
   * Deployed contract address

Optional: search the **contract address** directly to view transactions and logs.

### Troubleshooting

**“Injected Provider” not available**

* Install MetaMask and refresh Remix.
* Make sure the browser allows pop-ups.

**Deployment fails / out of gas**

* Ensure you have enough tSTU.
* Try deploying again with a smaller contract or accept the default gas estimate.

**Wrong network**

* Switch MetaMask to **SATUCHAIN Testnet** and reload Remix, then reconnect “Injected Provider - MetaMask”.
