hellolinux2021
hellolinux2021

欢迎拍手与交流,个人Channel:https://t.me/hellolinuxLab Sentinel DVPN中文社区管理,技术及使用支持 https://t.me/Sentinel_China 个人主页:https://hellolinux.uk/about

智能合约学习-(1)remix部署helloworld

智能合约helloworld

环境

实际操作

https://remix.ethereum.org/

windows的WSL中安装

npm install -g remixd

npm uninstall -g remixd

npm install -g @remix-project/remixd 由于出错,先卸载再用这个进行安装

设置共享文件夹

创建一个文件夹,在其中保存了 Solidity文件,然后运行以下命令告诉Remix使用文件夹中的文件

remixd -s <shared folder> — remix-ide https://remix.ethereum.org

remixd -s ./workspace-sol/ — remix-ide https://remix.ethereum.org

remix连接本地文件夹

到Remix的主页,单击“Connect to localhost(连接到本地主机)”


Remix将为你提供在浏览器中运行的虚拟区块链环境,先使用它来部署合约并与之交互。只需确保在“Deploy and run(部署并运行)”选项卡中选择Javascript VM作为环境即可。

源码:

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

contract HelloWorldContract {
    function helloWorld() external pure returns(string memory){
        return "hello world";
    }

}

然后编译,部署,看到部署后的合约,点击运行,能够看到打印的字符串。

参考

https://learnblockchain.cn/article/1755

CC BY-NC-ND 2.0 版权声明

喜欢我的文章吗?
别忘了给点支持与赞赏,让我知道创作的路上有你陪伴。

加载中…

发布评论