# Remix本地环境搭建及hello world

By [XiaoShin](https://paragraph.com/@xiaoshin) · 2022-03-23

---

Solidity 是一门面向合约的、为实现智能合约而创建的高级编程语言。这门语言受到了 C++，Python 和 Javascript 语言的影响，设计的目的是能在以太坊虚拟机（EVM）上运行。

Remix是Solidity热门IDE，使用Remix docker + Remixd构建本地IDE，使用环境是ubuntu 20.04。

一、Pull Remix docker

    # 安装docker
    sudo apt install docker.io
    # pull Remix
    sudo docker pull remixproject/remix-ide:latest
    

二、安装Remixd

    # 安装npm
    sudo apt install npm
    # 安装remixd
    sudo npm install -g @remix-project/remixd
    

三、启动Remix

    # 启动 docker
    sudo docker run -p 10330:80 remixproject/remix-ide:latest
    # 创建local文件夹，并启动 remixd (10330后的/一定要加)
    mkdir remix-data
    cd remix-data
    sudo remixd -s ./ --remix-ide http://127.0.0.1:10330/
    

四、使用Remix

启动浏览器访问 [http://127.0.0.1:10330](http://127.0.0.1:10330)

![](https://storage.googleapis.com/papyrus_images/dbe7ab5904e758079944ebc98c6a978fd6fca4eb17445bd38b9c5c9aad2b7523.png)

启用Remixd插件

![](https://storage.googleapis.com/papyrus_images/cc0be810e1b3c146f8dd7f3bffd0b1ce2436a90c593269917e1800ef37bf2e5b.png)

![](https://storage.googleapis.com/papyrus_images/d11a9c4eae078a0f976dac5c6aeba82eea56febb0035b08a9b8dfa7d2536cb42.png)

选用localhost，即之前建的remix-data文件夹

在文件夹中创建helloworld.sol

![](https://storage.googleapis.com/papyrus_images/56f4201ceaa9ff3c3861c2df9f24c5184d3c96361432cf75920e8d64deb7e6de.png)

四、Helloworld编译

在helloworld.sol添加代码 (不修改链上变量的函数不消耗Gas，比如pure)

    // SPDX-License-Identifier: GPL-3.0
    
    pragma solidity >=0.7.0 <0.9.0;
    
    contract helloworld {
        string Name = "tigher";
    
        function get_name() public view returns(string memory)
        {
            return Name;
        }
    
        function set(string memory _value) public 
        {
            Name = _value;
        }
    
        function puretest(string memory _name) public pure returns(string memory)
        {
            return _name;
        }
    }
    

使用左侧插件编译和运行。

---

*Originally published on [XiaoShin](https://paragraph.com/@xiaoshin/remix-hello-world)*
