remix 基本使用

365 阅读1分钟

网址: remix.ethereum.org/

remix 的基本使用

  1. 在 contract 文件夹下编写 4_My_contract.sol 文件

image.png

  1. 编写基本代码(注意指定编译版本)
pragma solidity 0.5.2;

contract MyContract {
    string value;

    constructor() public {
        value = "myValue";
    }

    function get() public view returns(string memory) {
        return value;
    }

    function set(string memory _value) public {
        value = _value;
    }
}
  1. 在 solidity compiler 下指定编译版本 compiler 为 0.5.2+ 编译 compile 4_My_contract.sol

image.png

  1. 在 deploy & run transactions 下, 选择 环境 environment 为 javascript VM (London) 并部署 deploy

image.png

  1. 进行测试前面编写的函数

image.png